Skip to main content

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#[derive(Debug, PartialEq)]
163pub struct TrustedFlatlandFactoryCreateFlatlandRequest {
164    /// The server end of the `fuchsia.ui.composition.Flatland` protocol to be created.
165    pub server_end: fidl::endpoints::ServerEnd<FlatlandMarker>,
166    /// The configuration for the new Flatland instance. See `TrustedFlatlandConfig` for
167    /// details on available options.
168    pub config: TrustedFlatlandConfig,
169}
170
171impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
172    for TrustedFlatlandFactoryCreateFlatlandRequest
173{
174}
175
176/// Metadata about the frame rendered by [`GetNextFrame`].
177#[derive(Debug, Default, PartialEq)]
178pub struct FrameInfo {
179    /// The index of the VMO where the requested frame has been rendered. Required.
180    pub buffer_id: Option<u32>,
181    #[doc(hidden)]
182    pub __source_breaking: fidl::marker::SourceBreaking,
183}
184
185impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FrameInfo {}
186
187/// The arguments passed into the [`GetNextFrame`] call. All fields are necessary.
188#[derive(Debug, Default, PartialEq)]
189pub struct GetNextFrameArgs {
190    /// The event that will signal when the requested frame has been rendered. Required.
191    pub event: Option<fidl::Event>,
192    #[doc(hidden)]
193    pub __source_breaking: fidl::marker::SourceBreaking,
194}
195
196impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for GetNextFrameArgs {}
197
198/// Arguments passed into [`Present`]. All arguments are optional, and if an
199/// argument is omitted Flatland will use a reasonable default, specified below.
200#[derive(Debug, Default, PartialEq)]
201pub struct PresentArgs {
202    /// `requested_presentation_time` specifies the time on or after which the client would like the
203    /// enqueued operations to take visible effect (light up pixels on the screen), expressed in
204    /// nanoseconds in the `CLOCK_MONOTONIC` timebase.
205    ///
206    /// The default `requested_presentation_time` is 0.
207    ///
208    /// Using a `requested_presentation_time` in the present or past (such as 0) schedules enqueued
209    /// operations to take visible effect as soon as possible, during the next frame to be prepared.
210    ///
211    /// Using a `requested_presentation_time` in the future schedules the enqueued operations to
212    /// take visible effect on or as closely as possible after the stated time, but no earlier.
213    ///
214    /// Each rendered frame has a target presentation time. This is when Flatland aims to have the
215    /// frame presented to the user. Before rendering a frame, Flatland applies all
216    /// enqueued operations associated with all squashable calls to [`Present`] whose
217    /// `requested_presentation_time` is on or before the frame's target presentation time.
218    pub requested_presentation_time: Option<i64>,
219    /// Flatland will wait until all of a Flatland instance's `acquire_fences` are ready before it
220    /// will execute the presented commands. Not signaling `acquire_fences` will block the current
221    /// [`Present`] as well as the following ones even if their `acquire_fences` are signaled.
222    ///
223    /// The default `acquire_fences` value is the empty vector.
224    pub acquire_fences: Option<Vec<fidl::Event>>,
225    /// Flatland will signal all `release_fences` when it is safe to reuse resources which no longer
226    /// appear in the local scene graph at the time of the current [`Present`].  At the latest, this
227    /// will happen when the local scene graph (checkpointed at this [`Present`]) has been
228    /// integrated into the global scene graph, and the global scene has been displayed on screen.
229    ///
230    /// (Under some circumstances, the fences may be signaled earlier, but clients do not need to
231    /// worry about this: the fences will only be signaled when it is safe to reuse the associated
232    /// resources).
233    ///
234    /// These fences are intended to manage the reuse of shared memory resources such as sysmem
235    /// buffers.  For example, it is undesirable for the client to render into an image which is
236    /// currently displayed on screen, because this may result in graphical artifacts such as
237    /// tearing.
238    ///
239    /// It is up to the client to maintain the mapping between each fence and the resources which
240    /// will become reusable when the fence is signaled.  A common strategy is to keep track of
241    /// resources which were used by the previous [`Present`] but are no longer used by the current
242    /// [`Present`].  For example, if an image is removed from the scene by the current [`Present`],
243    /// the client would insert a fence here.  When the fence is later signaled, the client knows
244    /// that it is safe to render into the image and insert it into the local scene graph in a
245    /// subsequent [`Present`].
246    ///
247    /// If an error occurs, Flatland may close the channel without signaling these fences.  Clients
248    /// may immediately release shared buffers, but they should not immediately modify such buffers,
249    /// because they may still be displayed on screen.  There is currently no good signal available
250    /// to the client about when it is safe to reuse shared buffers.
251    ///
252    /// The default `release_fences` value is the empty vector.
253    pub release_fences: Option<Vec<fidl::Event>>,
254    /// If `unsquashable` is true, then the update is guaranteed to be uniquely shown for at
255    /// least one vsync interval.
256    ///
257    /// If `unsquashable` is false, then the update can be combined with those that come after
258    /// it.
259    ///
260    /// If absent, `unsquashable` is false.
261    pub unsquashable: Option<bool>,
262    #[doc(hidden)]
263    pub __source_breaking: fidl::marker::SourceBreaking,
264}
265
266impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PresentArgs {}
267
268/// The table of arguments for [`RegisterBufferCollection`]. Note that some
269/// fields below are REQUIRED.
270#[derive(Debug, Default, PartialEq)]
271pub struct RegisterBufferCollectionArgs {
272    /// Clients can send [`export_token`] to register buffer collections with Allocator to be used
273    /// later in [`fuchsia.ui.composition/Flatland`] instances or other Scenic APIs, such as
274    /// Screenshot.
275    ///
276    /// For example, by passing a [`BufferCollectionImportToken`] containing the matching peer of
277    /// [`BufferCollectionExportToken`], they can create image resources via
278    /// [`fuchsia.ui.composition/Flatland.CreateImage`].
279    ///
280    /// Clients should wait for the response before using `import_token`.
281    ///
282    /// This field is REQUIRED.
283    pub export_token: Option<BufferCollectionExportToken>,
284    pub buffer_collection_token:
285        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>>,
286    /// The client can register a buffer collection for various uses, each
287    /// coming with their own unique constraints.
288    ///
289    /// This field is OPTIONAL. If `usage` is omitted it will be treated as if
290    /// it has the DEFAULT option.
291    ///
292    /// # Deprecation
293    ///
294    /// This arg is deprecated at API version 9 with addition of |usages|.
295    ///
296    /// If both the `usages` and `usage` fields are set, `usages` takes precedence and `usage` is
297    /// ignored.
298    pub usage: Option<RegisterBufferCollectionUsage>,
299    /// The client can register a buffer collection for various uses and has the ability to
300    /// combine usages if multiple are needed.
301    ///
302    /// This field is OPTIONAL. If `usages` is omitted it will be treated as if
303    /// it has only the DEFAULT option.
304    pub usages: Option<RegisterBufferCollectionUsages>,
305    /// Flatland participates in the allocation of buffers by setting constraints on the
306    /// BufferCollection referenced by `buffer_collection_token`. It will not block on buffers
307    /// being allocated until the client creates content using the BufferCollection.
308    ///
309    /// The buffer collection registered with `export_token` is available and kept alive as long
310    /// as the client holds a valid [`BufferCollectionImportToken`]. They will be garbage collected
311    /// when all [`BufferCollectionImportToken`]s are closed and all the associated Image resources
312    /// are released.
313    ///
314    /// Exactly one of `buffer_collection_token2` / `buffer_collection_token` must be set.
315    pub buffer_collection_token2:
316        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>>,
317    #[doc(hidden)]
318    pub __source_breaking: fidl::marker::SourceBreaking,
319}
320
321impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
322    for RegisterBufferCollectionArgs
323{
324}
325
326/// The arguments passed into the [`Configure`] call. Note that not all fields are necessary.
327#[derive(Debug, Default, PartialEq)]
328pub struct ScreenCaptureConfig {
329    /// The import token referencing a BufferCollection registered with
330    /// Allocator. Required.
331    pub import_token: Option<BufferCollectionImportToken>,
332    /// The size of the image in pixels. Required.
333    pub size: Option<fidl_fuchsia_math::SizeU>,
334    /// The number of buffers in the BufferCollection. Required.
335    pub buffer_count: Option<u32>,
336    /// The rotation to be applied to the stream of images. Optional; if absent no rotation is
337    /// applied.
338    pub rotation: Option<Rotation>,
339    #[doc(hidden)]
340    pub __source_breaking: fidl::marker::SourceBreaking,
341}
342
343impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ScreenCaptureConfig {}
344
345#[derive(Debug, Default, PartialEq)]
346pub struct ScreenshotTakeFileRequest {
347    /// Format of the requested screenshot.
348    pub format: Option<ScreenshotFormat>,
349    #[doc(hidden)]
350    pub __source_breaking: fidl::marker::SourceBreaking,
351}
352
353impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ScreenshotTakeFileRequest {}
354
355#[derive(Debug, Default, PartialEq)]
356pub struct ScreenshotTakeFileResponse {
357    /// |fuchsia.io.File| channel used to read the generated screenshot file data.
358    /// The server side of the channel is stored on the device until ZX_CHANNEL_PEER_CLOSED
359    /// is detected.
360    ///
361    /// Basic usage: After the client recieves the client end of the file channel,
362    /// to avoid memory pile-ups, it should finish reading the data
363    /// before calling [`TakeFile`] again. When finished reading,
364    /// the client should call [`Close`] on the |fuchsia.io.File| channel, this will release
365    /// the memory allocated on the server side.
366    pub file: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
367    /// Size of the screenshot in pixels.
368    pub size: Option<fidl_fuchsia_math::SizeU>,
369    #[doc(hidden)]
370    pub __source_breaking: fidl::marker::SourceBreaking,
371}
372
373impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
374    for ScreenshotTakeFileResponse
375{
376}
377
378#[derive(Debug, Default, PartialEq)]
379pub struct ScreenshotTakeRequest {
380    /// Format of the requested screenshot.
381    pub format: Option<ScreenshotFormat>,
382    #[doc(hidden)]
383    pub __source_breaking: fidl::marker::SourceBreaking,
384}
385
386impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ScreenshotTakeRequest {}
387
388#[derive(Debug, Default, PartialEq)]
389pub struct ScreenshotTakeResponse {
390    /// CPU mappable read-only VMO that contains screenshot data. The server owns the VMO and
391    /// may reuse for the next [`Take`]. The VMO is guaranteed to be accessible after mapping.
392    /// In some allocations, VMO::read() might not be available, i.e. on emulator.
393    ///
394    /// Basic usage: After the client receives a VMO handle, to ensure data stability, it should
395    /// finish reading the VMO before calling [`Take`] again. When finished reading, the client
396    /// should drop the VMO handle.
397    ///
398    /// Advanced usage: To edit the data, or to persist it beyond the next [`Take`] call, the
399    /// client should copy the data to a private VMO.
400    pub vmo: Option<fidl::Vmo>,
401    /// Size of the screenshot in pixels.
402    pub size: Option<fidl_fuchsia_math::SizeU>,
403    #[doc(hidden)]
404    pub __source_breaking: fidl::marker::SourceBreaking,
405}
406
407impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ScreenshotTakeResponse {}
408
409/// All arguments are optional; default values will be provided if they are absent.
410/// By default, the resulting Flatland will behave identically to connecting
411/// to the `fuchsia.ui.composition.Flatland` service instead of connecting via the factory.
412#[derive(Debug, Default, PartialEq)]
413pub struct TrustedFlatlandConfig {
414    /// If true, a frame will be scheduled to be presented as soon as all acquire fences are
415    /// signaled, instead of waiting for other clients to present in the same vsync. This can reduce
416    /// latency for this client, but may increase power consumption.
417    ///
418    /// If absent, `schedule_asap` is false.
419    pub schedule_asap: Option<bool>,
420    /// If true, Scenic should pass acquire fences to the drivers for composition HW, instead of
421    /// waiting for them on CPU. This can improve performance by reducing CPU overhead.
422    ///
423    /// If absent, `pass_acquire_fences` is false.
424    pub pass_acquire_fences: Option<bool>,
425    /// If true, the client will not utilize Flatland's built in frame-scheduling mechanism and
426    /// will ignore present credits, instead relying on their own flow control system.
427    ///
428    /// If absent, `skips_present_credits` is false.
429    pub skips_present_credits: Option<bool>,
430    #[doc(hidden)]
431    pub __source_breaking: fidl::marker::SourceBreaking,
432}
433
434impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for TrustedFlatlandConfig {}
435
436/// The protocol endpoints bound to a Flatland ViewCreationToken. These protocols operate on the
437/// View that ViewCreationToken created in the Flatland session.
438#[derive(Debug, Default, PartialEq)]
439pub struct ViewBoundProtocols {
440    /// Learn when a View gains focus.
441    ///
442    /// Server-bound ViewRef. The [`view_ref_focused`] client does not specify the ViewRef
443    /// explicitly; instead, the server implementation uses the ViewRef used in View creation for
444    /// reporting focus movement on/off this View.
445    pub view_ref_focused:
446        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>>,
447    /// Enable a View to request focus transfer to a child (target) View.
448    ///
449    /// Server-bound ViewRef. The [`view_focuser`] client does not specify the "requestor" ViewRef
450    /// explicitly, only the "target" ViewRef. Instead, the server implementation uses the ViewRef
451    /// used in View creation as the "requestor" ViewRef.
452    pub view_focuser: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>,
453    /// Receive touch events that are associated with a View.
454    pub touch_source:
455        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>>,
456    /// Receive mouse events that are associated with a View.
457    pub mouse_source:
458        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
459    #[doc(hidden)]
460    pub __source_breaking: fidl::marker::SourceBreaking,
461}
462
463impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewBoundProtocols {}
464
465#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
466pub struct AllocatorMarker;
467
468impl fidl::endpoints::ProtocolMarker for AllocatorMarker {
469    type Proxy = AllocatorProxy;
470    type RequestStream = AllocatorRequestStream;
471    #[cfg(target_os = "fuchsia")]
472    type SynchronousProxy = AllocatorSynchronousProxy;
473
474    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.Allocator";
475}
476impl fidl::endpoints::DiscoverableProtocolMarker for AllocatorMarker {}
477pub type AllocatorRegisterBufferCollectionResult = Result<(), RegisterBufferCollectionError>;
478
479pub trait AllocatorProxyInterface: Send + Sync {
480    type RegisterBufferCollectionResponseFut: std::future::Future<Output = Result<AllocatorRegisterBufferCollectionResult, fidl::Error>>
481        + Send;
482    fn r#register_buffer_collection(
483        &self,
484        args: RegisterBufferCollectionArgs,
485    ) -> Self::RegisterBufferCollectionResponseFut;
486}
487#[derive(Debug)]
488#[cfg(target_os = "fuchsia")]
489pub struct AllocatorSynchronousProxy {
490    client: fidl::client::sync::Client,
491}
492
493#[cfg(target_os = "fuchsia")]
494impl fidl::endpoints::SynchronousProxy for AllocatorSynchronousProxy {
495    type Proxy = AllocatorProxy;
496    type Protocol = AllocatorMarker;
497
498    fn from_channel(inner: fidl::Channel) -> Self {
499        Self::new(inner)
500    }
501
502    fn into_channel(self) -> fidl::Channel {
503        self.client.into_channel()
504    }
505
506    fn as_channel(&self) -> &fidl::Channel {
507        self.client.as_channel()
508    }
509}
510
511#[cfg(target_os = "fuchsia")]
512impl AllocatorSynchronousProxy {
513    pub fn new(channel: fidl::Channel) -> Self {
514        let protocol_name = <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
515        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
516    }
517
518    pub fn into_channel(self) -> fidl::Channel {
519        self.client.into_channel()
520    }
521
522    /// Waits until an event arrives and returns it. It is safe for other
523    /// threads to make concurrent requests while waiting for an event.
524    pub fn wait_for_event(
525        &self,
526        deadline: zx::MonotonicInstant,
527    ) -> Result<AllocatorEvent, fidl::Error> {
528        AllocatorEvent::decode(self.client.wait_for_event(deadline)?)
529    }
530
531    /// A BufferCollection is a set of VMOs created by Sysmem and shared by a number of
532    /// participants, one of which is the Flatland Renderer. Some content, such as Images, use a
533    /// BufferCollection as their backing memory.
534    ///
535    /// See [`RegisterBufferCollectionArgs`] for information on each argument.
536    pub fn r#register_buffer_collection(
537        &self,
538        mut args: RegisterBufferCollectionArgs,
539        ___deadline: zx::MonotonicInstant,
540    ) -> Result<AllocatorRegisterBufferCollectionResult, fidl::Error> {
541        let _response = self
542            .client
543            .send_query::<AllocatorRegisterBufferCollectionRequest, fidl::encoding::ResultType<
544                fidl::encoding::EmptyStruct,
545                RegisterBufferCollectionError,
546            >>(
547                (&mut args,),
548                0x494b7ea578d1061e,
549                fidl::encoding::DynamicFlags::empty(),
550                ___deadline,
551            )?;
552        Ok(_response.map(|x| x))
553    }
554}
555
556#[cfg(target_os = "fuchsia")]
557impl From<AllocatorSynchronousProxy> for zx::NullableHandle {
558    fn from(value: AllocatorSynchronousProxy) -> Self {
559        value.into_channel().into()
560    }
561}
562
563#[cfg(target_os = "fuchsia")]
564impl From<fidl::Channel> for AllocatorSynchronousProxy {
565    fn from(value: fidl::Channel) -> Self {
566        Self::new(value)
567    }
568}
569
570#[cfg(target_os = "fuchsia")]
571impl fidl::endpoints::FromClient for AllocatorSynchronousProxy {
572    type Protocol = AllocatorMarker;
573
574    fn from_client(value: fidl::endpoints::ClientEnd<AllocatorMarker>) -> Self {
575        Self::new(value.into_channel())
576    }
577}
578
579#[derive(Debug, Clone)]
580pub struct AllocatorProxy {
581    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
582}
583
584impl fidl::endpoints::Proxy for AllocatorProxy {
585    type Protocol = AllocatorMarker;
586
587    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
588        Self::new(inner)
589    }
590
591    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
592        self.client.into_channel().map_err(|client| Self { client })
593    }
594
595    fn as_channel(&self) -> &::fidl::AsyncChannel {
596        self.client.as_channel()
597    }
598}
599
600impl AllocatorProxy {
601    /// Create a new Proxy for fuchsia.ui.composition/Allocator.
602    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
603        let protocol_name = <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
604        Self { client: fidl::client::Client::new(channel, protocol_name) }
605    }
606
607    /// Get a Stream of events from the remote end of the protocol.
608    ///
609    /// # Panics
610    ///
611    /// Panics if the event stream was already taken.
612    pub fn take_event_stream(&self) -> AllocatorEventStream {
613        AllocatorEventStream { event_receiver: self.client.take_event_receiver() }
614    }
615
616    /// A BufferCollection is a set of VMOs created by Sysmem and shared by a number of
617    /// participants, one of which is the Flatland Renderer. Some content, such as Images, use a
618    /// BufferCollection as their backing memory.
619    ///
620    /// See [`RegisterBufferCollectionArgs`] for information on each argument.
621    pub fn r#register_buffer_collection(
622        &self,
623        mut args: RegisterBufferCollectionArgs,
624    ) -> fidl::client::QueryResponseFut<
625        AllocatorRegisterBufferCollectionResult,
626        fidl::encoding::DefaultFuchsiaResourceDialect,
627    > {
628        AllocatorProxyInterface::r#register_buffer_collection(self, args)
629    }
630}
631
632impl AllocatorProxyInterface for AllocatorProxy {
633    type RegisterBufferCollectionResponseFut = fidl::client::QueryResponseFut<
634        AllocatorRegisterBufferCollectionResult,
635        fidl::encoding::DefaultFuchsiaResourceDialect,
636    >;
637    fn r#register_buffer_collection(
638        &self,
639        mut args: RegisterBufferCollectionArgs,
640    ) -> Self::RegisterBufferCollectionResponseFut {
641        fn _decode(
642            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
643        ) -> Result<AllocatorRegisterBufferCollectionResult, fidl::Error> {
644            let _response = fidl::client::decode_transaction_body::<
645                fidl::encoding::ResultType<
646                    fidl::encoding::EmptyStruct,
647                    RegisterBufferCollectionError,
648                >,
649                fidl::encoding::DefaultFuchsiaResourceDialect,
650                0x494b7ea578d1061e,
651            >(_buf?)?;
652            Ok(_response.map(|x| x))
653        }
654        self.client.send_query_and_decode::<
655            AllocatorRegisterBufferCollectionRequest,
656            AllocatorRegisterBufferCollectionResult,
657        >(
658            (&mut args,),
659            0x494b7ea578d1061e,
660            fidl::encoding::DynamicFlags::empty(),
661            _decode,
662        )
663    }
664}
665
666pub struct AllocatorEventStream {
667    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
668}
669
670impl std::marker::Unpin for AllocatorEventStream {}
671
672impl futures::stream::FusedStream for AllocatorEventStream {
673    fn is_terminated(&self) -> bool {
674        self.event_receiver.is_terminated()
675    }
676}
677
678impl futures::Stream for AllocatorEventStream {
679    type Item = Result<AllocatorEvent, fidl::Error>;
680
681    fn poll_next(
682        mut self: std::pin::Pin<&mut Self>,
683        cx: &mut std::task::Context<'_>,
684    ) -> std::task::Poll<Option<Self::Item>> {
685        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
686            &mut self.event_receiver,
687            cx
688        )?) {
689            Some(buf) => std::task::Poll::Ready(Some(AllocatorEvent::decode(buf))),
690            None => std::task::Poll::Ready(None),
691        }
692    }
693}
694
695#[derive(Debug)]
696pub enum AllocatorEvent {}
697
698impl AllocatorEvent {
699    /// Decodes a message buffer as a [`AllocatorEvent`].
700    fn decode(
701        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
702    ) -> Result<AllocatorEvent, fidl::Error> {
703        let (bytes, _handles) = buf.split_mut();
704        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
705        debug_assert_eq!(tx_header.tx_id, 0);
706        match tx_header.ordinal {
707            _ => Err(fidl::Error::UnknownOrdinal {
708                ordinal: tx_header.ordinal,
709                protocol_name: <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
710            }),
711        }
712    }
713}
714
715/// A Stream of incoming requests for fuchsia.ui.composition/Allocator.
716pub struct AllocatorRequestStream {
717    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
718    is_terminated: bool,
719}
720
721impl std::marker::Unpin for AllocatorRequestStream {}
722
723impl futures::stream::FusedStream for AllocatorRequestStream {
724    fn is_terminated(&self) -> bool {
725        self.is_terminated
726    }
727}
728
729impl fidl::endpoints::RequestStream for AllocatorRequestStream {
730    type Protocol = AllocatorMarker;
731    type ControlHandle = AllocatorControlHandle;
732
733    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
734        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
735    }
736
737    fn control_handle(&self) -> Self::ControlHandle {
738        AllocatorControlHandle { inner: self.inner.clone() }
739    }
740
741    fn into_inner(
742        self,
743    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
744    {
745        (self.inner, self.is_terminated)
746    }
747
748    fn from_inner(
749        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
750        is_terminated: bool,
751    ) -> Self {
752        Self { inner, is_terminated }
753    }
754}
755
756impl futures::Stream for AllocatorRequestStream {
757    type Item = Result<AllocatorRequest, fidl::Error>;
758
759    fn poll_next(
760        mut self: std::pin::Pin<&mut Self>,
761        cx: &mut std::task::Context<'_>,
762    ) -> std::task::Poll<Option<Self::Item>> {
763        let this = &mut *self;
764        if this.inner.check_shutdown(cx) {
765            this.is_terminated = true;
766            return std::task::Poll::Ready(None);
767        }
768        if this.is_terminated {
769            panic!("polled AllocatorRequestStream after completion");
770        }
771        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
772            |bytes, handles| {
773                match this.inner.channel().read_etc(cx, bytes, handles) {
774                    std::task::Poll::Ready(Ok(())) => {}
775                    std::task::Poll::Pending => return std::task::Poll::Pending,
776                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
777                        this.is_terminated = true;
778                        return std::task::Poll::Ready(None);
779                    }
780                    std::task::Poll::Ready(Err(e)) => {
781                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
782                            e.into(),
783                        ))));
784                    }
785                }
786
787                // A message has been received from the channel
788                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
789
790                std::task::Poll::Ready(Some(match header.ordinal {
791                    0x494b7ea578d1061e => {
792                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
793                        let mut req = fidl::new_empty!(
794                            AllocatorRegisterBufferCollectionRequest,
795                            fidl::encoding::DefaultFuchsiaResourceDialect
796                        );
797                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorRegisterBufferCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
798                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
799                        Ok(AllocatorRequest::RegisterBufferCollection {
800                            args: req.args,
801
802                            responder: AllocatorRegisterBufferCollectionResponder {
803                                control_handle: std::mem::ManuallyDrop::new(control_handle),
804                                tx_id: header.tx_id,
805                            },
806                        })
807                    }
808                    _ => Err(fidl::Error::UnknownOrdinal {
809                        ordinal: header.ordinal,
810                        protocol_name:
811                            <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
812                    }),
813                }))
814            },
815        )
816    }
817}
818
819#[derive(Debug)]
820pub enum AllocatorRequest {
821    /// A BufferCollection is a set of VMOs created by Sysmem and shared by a number of
822    /// participants, one of which is the Flatland Renderer. Some content, such as Images, use a
823    /// BufferCollection as their backing memory.
824    ///
825    /// See [`RegisterBufferCollectionArgs`] for information on each argument.
826    RegisterBufferCollection {
827        args: RegisterBufferCollectionArgs,
828        responder: AllocatorRegisterBufferCollectionResponder,
829    },
830}
831
832impl AllocatorRequest {
833    #[allow(irrefutable_let_patterns)]
834    pub fn into_register_buffer_collection(
835        self,
836    ) -> Option<(RegisterBufferCollectionArgs, AllocatorRegisterBufferCollectionResponder)> {
837        if let AllocatorRequest::RegisterBufferCollection { args, responder } = self {
838            Some((args, responder))
839        } else {
840            None
841        }
842    }
843
844    /// Name of the method defined in FIDL
845    pub fn method_name(&self) -> &'static str {
846        match *self {
847            AllocatorRequest::RegisterBufferCollection { .. } => "register_buffer_collection",
848        }
849    }
850}
851
852#[derive(Debug, Clone)]
853pub struct AllocatorControlHandle {
854    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
855}
856
857impl fidl::endpoints::ControlHandle for AllocatorControlHandle {
858    fn shutdown(&self) {
859        self.inner.shutdown()
860    }
861
862    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
863        self.inner.shutdown_with_epitaph(status)
864    }
865
866    fn is_closed(&self) -> bool {
867        self.inner.channel().is_closed()
868    }
869    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
870        self.inner.channel().on_closed()
871    }
872
873    #[cfg(target_os = "fuchsia")]
874    fn signal_peer(
875        &self,
876        clear_mask: zx::Signals,
877        set_mask: zx::Signals,
878    ) -> Result<(), zx_status::Status> {
879        use fidl::Peered;
880        self.inner.channel().signal_peer(clear_mask, set_mask)
881    }
882}
883
884impl AllocatorControlHandle {}
885
886#[must_use = "FIDL methods require a response to be sent"]
887#[derive(Debug)]
888pub struct AllocatorRegisterBufferCollectionResponder {
889    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
890    tx_id: u32,
891}
892
893/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
894/// if the responder is dropped without sending a response, so that the client
895/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
896impl std::ops::Drop for AllocatorRegisterBufferCollectionResponder {
897    fn drop(&mut self) {
898        self.control_handle.shutdown();
899        // Safety: drops once, never accessed again
900        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
901    }
902}
903
904impl fidl::endpoints::Responder for AllocatorRegisterBufferCollectionResponder {
905    type ControlHandle = AllocatorControlHandle;
906
907    fn control_handle(&self) -> &AllocatorControlHandle {
908        &self.control_handle
909    }
910
911    fn drop_without_shutdown(mut self) {
912        // Safety: drops once, never accessed again due to mem::forget
913        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
914        // Prevent Drop from running (which would shut down the channel)
915        std::mem::forget(self);
916    }
917}
918
919impl AllocatorRegisterBufferCollectionResponder {
920    /// Sends a response to the FIDL transaction.
921    ///
922    /// Sets the channel to shutdown if an error occurs.
923    pub fn send(
924        self,
925        mut result: Result<(), RegisterBufferCollectionError>,
926    ) -> Result<(), fidl::Error> {
927        let _result = self.send_raw(result);
928        if _result.is_err() {
929            self.control_handle.shutdown();
930        }
931        self.drop_without_shutdown();
932        _result
933    }
934
935    /// Similar to "send" but does not shutdown the channel if an error occurs.
936    pub fn send_no_shutdown_on_err(
937        self,
938        mut result: Result<(), RegisterBufferCollectionError>,
939    ) -> Result<(), fidl::Error> {
940        let _result = self.send_raw(result);
941        self.drop_without_shutdown();
942        _result
943    }
944
945    fn send_raw(
946        &self,
947        mut result: Result<(), RegisterBufferCollectionError>,
948    ) -> Result<(), fidl::Error> {
949        self.control_handle.inner.send::<fidl::encoding::ResultType<
950            fidl::encoding::EmptyStruct,
951            RegisterBufferCollectionError,
952        >>(
953            result,
954            self.tx_id,
955            0x494b7ea578d1061e,
956            fidl::encoding::DynamicFlags::empty(),
957        )
958    }
959}
960
961#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
962pub struct ChildViewWatcherMarker;
963
964impl fidl::endpoints::ProtocolMarker for ChildViewWatcherMarker {
965    type Proxy = ChildViewWatcherProxy;
966    type RequestStream = ChildViewWatcherRequestStream;
967    #[cfg(target_os = "fuchsia")]
968    type SynchronousProxy = ChildViewWatcherSynchronousProxy;
969
970    const DEBUG_NAME: &'static str = "(anonymous) ChildViewWatcher";
971}
972
973pub trait ChildViewWatcherProxyInterface: Send + Sync {
974    type GetStatusResponseFut: std::future::Future<Output = Result<ChildViewStatus, fidl::Error>>
975        + Send;
976    fn r#get_status(&self) -> Self::GetStatusResponseFut;
977    type GetViewRefResponseFut: std::future::Future<Output = Result<fidl_fuchsia_ui_views::ViewRef, fidl::Error>>
978        + Send;
979    fn r#get_view_ref(&self) -> Self::GetViewRefResponseFut;
980}
981#[derive(Debug)]
982#[cfg(target_os = "fuchsia")]
983pub struct ChildViewWatcherSynchronousProxy {
984    client: fidl::client::sync::Client,
985}
986
987#[cfg(target_os = "fuchsia")]
988impl fidl::endpoints::SynchronousProxy for ChildViewWatcherSynchronousProxy {
989    type Proxy = ChildViewWatcherProxy;
990    type Protocol = ChildViewWatcherMarker;
991
992    fn from_channel(inner: fidl::Channel) -> Self {
993        Self::new(inner)
994    }
995
996    fn into_channel(self) -> fidl::Channel {
997        self.client.into_channel()
998    }
999
1000    fn as_channel(&self) -> &fidl::Channel {
1001        self.client.as_channel()
1002    }
1003}
1004
1005#[cfg(target_os = "fuchsia")]
1006impl ChildViewWatcherSynchronousProxy {
1007    pub fn new(channel: fidl::Channel) -> Self {
1008        let protocol_name = <ChildViewWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1009        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1010    }
1011
1012    pub fn into_channel(self) -> fidl::Channel {
1013        self.client.into_channel()
1014    }
1015
1016    /// Waits until an event arrives and returns it. It is safe for other
1017    /// threads to make concurrent requests while waiting for an event.
1018    pub fn wait_for_event(
1019        &self,
1020        deadline: zx::MonotonicInstant,
1021    ) -> Result<ChildViewWatcherEvent, fidl::Error> {
1022        ChildViewWatcherEvent::decode(self.client.wait_for_event(deadline)?)
1023    }
1024
1025    /// A hanging get for receiving the status of a View. This provides information to the parent,
1026    /// such as whether or not the child has successfully presented content through this View.
1027    ///
1028    /// This hanging get will only fire when the ChildViewStatus is different than the previously
1029    /// returned ChildViewStatus.  This can happen immediately, and even if the creator of the
1030    /// Viewport hasn't yet called Present() after calling CreateViewport().  This allows the parent
1031    /// to know that the child has content ready to display before the parent modifies their own
1032    /// local scene graph to incorporate the child content.
1033    ///
1034    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
1035    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1036    /// closed.
1037    pub fn r#get_status(
1038        &self,
1039        ___deadline: zx::MonotonicInstant,
1040    ) -> Result<ChildViewStatus, fidl::Error> {
1041        let _response = self
1042            .client
1043            .send_query::<fidl::encoding::EmptyPayload, ChildViewWatcherGetStatusResponse>(
1044                (),
1045                0x1d622075f4fc8243,
1046                fidl::encoding::DynamicFlags::empty(),
1047                ___deadline,
1048            )?;
1049        Ok(_response.status)
1050    }
1051
1052    /// Hanging get to receive the ViewRef of the child View. This will only fire when the View ref
1053    /// is different from the previously-returned View ref. Note: currently the View ref will not
1054    /// change after it is first received, but this will change if/when the API changes to allow
1055    /// relinking of views.
1056    ///
1057    /// The ViewRef is not returned until the View is included in the View tree, in other words when
1058    /// there is a chain of ancestor transforms all the way back up to the root of the scene graph,
1059    /// i.e. the display.
1060    ///
1061    /// It is invalid to call `GetViewRef` while a previous call is still pending. Doing so will
1062    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1063    /// closed.
1064    ///
1065    /// A `GetViewRef` call will hang if the View was created using `CreateView`, but returns the
1066    /// View if the View was created using CreateView2. This is because `CreateView` does not mint
1067    /// a ViewRef for that View.
1068    pub fn r#get_view_ref(
1069        &self,
1070        ___deadline: zx::MonotonicInstant,
1071    ) -> Result<fidl_fuchsia_ui_views::ViewRef, fidl::Error> {
1072        let _response = self
1073            .client
1074            .send_query::<fidl::encoding::EmptyPayload, ChildViewWatcherGetViewRefResponse>(
1075                (),
1076                0x3b2f3ca31e8908b4,
1077                fidl::encoding::DynamicFlags::empty(),
1078                ___deadline,
1079            )?;
1080        Ok(_response.view_ref)
1081    }
1082}
1083
1084#[cfg(target_os = "fuchsia")]
1085impl From<ChildViewWatcherSynchronousProxy> for zx::NullableHandle {
1086    fn from(value: ChildViewWatcherSynchronousProxy) -> Self {
1087        value.into_channel().into()
1088    }
1089}
1090
1091#[cfg(target_os = "fuchsia")]
1092impl From<fidl::Channel> for ChildViewWatcherSynchronousProxy {
1093    fn from(value: fidl::Channel) -> Self {
1094        Self::new(value)
1095    }
1096}
1097
1098#[cfg(target_os = "fuchsia")]
1099impl fidl::endpoints::FromClient for ChildViewWatcherSynchronousProxy {
1100    type Protocol = ChildViewWatcherMarker;
1101
1102    fn from_client(value: fidl::endpoints::ClientEnd<ChildViewWatcherMarker>) -> Self {
1103        Self::new(value.into_channel())
1104    }
1105}
1106
1107#[derive(Debug, Clone)]
1108pub struct ChildViewWatcherProxy {
1109    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1110}
1111
1112impl fidl::endpoints::Proxy for ChildViewWatcherProxy {
1113    type Protocol = ChildViewWatcherMarker;
1114
1115    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1116        Self::new(inner)
1117    }
1118
1119    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1120        self.client.into_channel().map_err(|client| Self { client })
1121    }
1122
1123    fn as_channel(&self) -> &::fidl::AsyncChannel {
1124        self.client.as_channel()
1125    }
1126}
1127
1128impl ChildViewWatcherProxy {
1129    /// Create a new Proxy for fuchsia.ui.composition/ChildViewWatcher.
1130    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1131        let protocol_name = <ChildViewWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1132        Self { client: fidl::client::Client::new(channel, protocol_name) }
1133    }
1134
1135    /// Get a Stream of events from the remote end of the protocol.
1136    ///
1137    /// # Panics
1138    ///
1139    /// Panics if the event stream was already taken.
1140    pub fn take_event_stream(&self) -> ChildViewWatcherEventStream {
1141        ChildViewWatcherEventStream { event_receiver: self.client.take_event_receiver() }
1142    }
1143
1144    /// A hanging get for receiving the status of a View. This provides information to the parent,
1145    /// such as whether or not the child has successfully presented content through this View.
1146    ///
1147    /// This hanging get will only fire when the ChildViewStatus is different than the previously
1148    /// returned ChildViewStatus.  This can happen immediately, and even if the creator of the
1149    /// Viewport hasn't yet called Present() after calling CreateViewport().  This allows the parent
1150    /// to know that the child has content ready to display before the parent modifies their own
1151    /// local scene graph to incorporate the child content.
1152    ///
1153    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
1154    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1155    /// closed.
1156    pub fn r#get_status(
1157        &self,
1158    ) -> fidl::client::QueryResponseFut<
1159        ChildViewStatus,
1160        fidl::encoding::DefaultFuchsiaResourceDialect,
1161    > {
1162        ChildViewWatcherProxyInterface::r#get_status(self)
1163    }
1164
1165    /// Hanging get to receive the ViewRef of the child View. This will only fire when the View ref
1166    /// is different from the previously-returned View ref. Note: currently the View ref will not
1167    /// change after it is first received, but this will change if/when the API changes to allow
1168    /// relinking of views.
1169    ///
1170    /// The ViewRef is not returned until the View is included in the View tree, in other words when
1171    /// there is a chain of ancestor transforms all the way back up to the root of the scene graph,
1172    /// i.e. the display.
1173    ///
1174    /// It is invalid to call `GetViewRef` while a previous call is still pending. Doing so will
1175    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1176    /// closed.
1177    ///
1178    /// A `GetViewRef` call will hang if the View was created using `CreateView`, but returns the
1179    /// View if the View was created using CreateView2. This is because `CreateView` does not mint
1180    /// a ViewRef for that View.
1181    pub fn r#get_view_ref(
1182        &self,
1183    ) -> fidl::client::QueryResponseFut<
1184        fidl_fuchsia_ui_views::ViewRef,
1185        fidl::encoding::DefaultFuchsiaResourceDialect,
1186    > {
1187        ChildViewWatcherProxyInterface::r#get_view_ref(self)
1188    }
1189}
1190
1191impl ChildViewWatcherProxyInterface for ChildViewWatcherProxy {
1192    type GetStatusResponseFut = fidl::client::QueryResponseFut<
1193        ChildViewStatus,
1194        fidl::encoding::DefaultFuchsiaResourceDialect,
1195    >;
1196    fn r#get_status(&self) -> Self::GetStatusResponseFut {
1197        fn _decode(
1198            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1199        ) -> Result<ChildViewStatus, fidl::Error> {
1200            let _response = fidl::client::decode_transaction_body::<
1201                ChildViewWatcherGetStatusResponse,
1202                fidl::encoding::DefaultFuchsiaResourceDialect,
1203                0x1d622075f4fc8243,
1204            >(_buf?)?;
1205            Ok(_response.status)
1206        }
1207        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ChildViewStatus>(
1208            (),
1209            0x1d622075f4fc8243,
1210            fidl::encoding::DynamicFlags::empty(),
1211            _decode,
1212        )
1213    }
1214
1215    type GetViewRefResponseFut = fidl::client::QueryResponseFut<
1216        fidl_fuchsia_ui_views::ViewRef,
1217        fidl::encoding::DefaultFuchsiaResourceDialect,
1218    >;
1219    fn r#get_view_ref(&self) -> Self::GetViewRefResponseFut {
1220        fn _decode(
1221            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1222        ) -> Result<fidl_fuchsia_ui_views::ViewRef, fidl::Error> {
1223            let _response = fidl::client::decode_transaction_body::<
1224                ChildViewWatcherGetViewRefResponse,
1225                fidl::encoding::DefaultFuchsiaResourceDialect,
1226                0x3b2f3ca31e8908b4,
1227            >(_buf?)?;
1228            Ok(_response.view_ref)
1229        }
1230        self.client
1231            .send_query_and_decode::<fidl::encoding::EmptyPayload, fidl_fuchsia_ui_views::ViewRef>(
1232                (),
1233                0x3b2f3ca31e8908b4,
1234                fidl::encoding::DynamicFlags::empty(),
1235                _decode,
1236            )
1237    }
1238}
1239
1240pub struct ChildViewWatcherEventStream {
1241    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1242}
1243
1244impl std::marker::Unpin for ChildViewWatcherEventStream {}
1245
1246impl futures::stream::FusedStream for ChildViewWatcherEventStream {
1247    fn is_terminated(&self) -> bool {
1248        self.event_receiver.is_terminated()
1249    }
1250}
1251
1252impl futures::Stream for ChildViewWatcherEventStream {
1253    type Item = Result<ChildViewWatcherEvent, fidl::Error>;
1254
1255    fn poll_next(
1256        mut self: std::pin::Pin<&mut Self>,
1257        cx: &mut std::task::Context<'_>,
1258    ) -> std::task::Poll<Option<Self::Item>> {
1259        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1260            &mut self.event_receiver,
1261            cx
1262        )?) {
1263            Some(buf) => std::task::Poll::Ready(Some(ChildViewWatcherEvent::decode(buf))),
1264            None => std::task::Poll::Ready(None),
1265        }
1266    }
1267}
1268
1269#[derive(Debug)]
1270pub enum ChildViewWatcherEvent {}
1271
1272impl ChildViewWatcherEvent {
1273    /// Decodes a message buffer as a [`ChildViewWatcherEvent`].
1274    fn decode(
1275        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1276    ) -> Result<ChildViewWatcherEvent, fidl::Error> {
1277        let (bytes, _handles) = buf.split_mut();
1278        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1279        debug_assert_eq!(tx_header.tx_id, 0);
1280        match tx_header.ordinal {
1281            _ => Err(fidl::Error::UnknownOrdinal {
1282                ordinal: tx_header.ordinal,
1283                protocol_name:
1284                    <ChildViewWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1285            }),
1286        }
1287    }
1288}
1289
1290/// A Stream of incoming requests for fuchsia.ui.composition/ChildViewWatcher.
1291pub struct ChildViewWatcherRequestStream {
1292    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1293    is_terminated: bool,
1294}
1295
1296impl std::marker::Unpin for ChildViewWatcherRequestStream {}
1297
1298impl futures::stream::FusedStream for ChildViewWatcherRequestStream {
1299    fn is_terminated(&self) -> bool {
1300        self.is_terminated
1301    }
1302}
1303
1304impl fidl::endpoints::RequestStream for ChildViewWatcherRequestStream {
1305    type Protocol = ChildViewWatcherMarker;
1306    type ControlHandle = ChildViewWatcherControlHandle;
1307
1308    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1309        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1310    }
1311
1312    fn control_handle(&self) -> Self::ControlHandle {
1313        ChildViewWatcherControlHandle { inner: self.inner.clone() }
1314    }
1315
1316    fn into_inner(
1317        self,
1318    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1319    {
1320        (self.inner, self.is_terminated)
1321    }
1322
1323    fn from_inner(
1324        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1325        is_terminated: bool,
1326    ) -> Self {
1327        Self { inner, is_terminated }
1328    }
1329}
1330
1331impl futures::Stream for ChildViewWatcherRequestStream {
1332    type Item = Result<ChildViewWatcherRequest, fidl::Error>;
1333
1334    fn poll_next(
1335        mut self: std::pin::Pin<&mut Self>,
1336        cx: &mut std::task::Context<'_>,
1337    ) -> std::task::Poll<Option<Self::Item>> {
1338        let this = &mut *self;
1339        if this.inner.check_shutdown(cx) {
1340            this.is_terminated = true;
1341            return std::task::Poll::Ready(None);
1342        }
1343        if this.is_terminated {
1344            panic!("polled ChildViewWatcherRequestStream after completion");
1345        }
1346        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1347            |bytes, handles| {
1348                match this.inner.channel().read_etc(cx, bytes, handles) {
1349                    std::task::Poll::Ready(Ok(())) => {}
1350                    std::task::Poll::Pending => return std::task::Poll::Pending,
1351                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1352                        this.is_terminated = true;
1353                        return std::task::Poll::Ready(None);
1354                    }
1355                    std::task::Poll::Ready(Err(e)) => {
1356                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1357                            e.into(),
1358                        ))));
1359                    }
1360                }
1361
1362                // A message has been received from the channel
1363                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1364
1365                std::task::Poll::Ready(Some(match header.ordinal {
1366                    0x1d622075f4fc8243 => {
1367                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1368                        let mut req = fidl::new_empty!(
1369                            fidl::encoding::EmptyPayload,
1370                            fidl::encoding::DefaultFuchsiaResourceDialect
1371                        );
1372                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1373                        let control_handle =
1374                            ChildViewWatcherControlHandle { inner: this.inner.clone() };
1375                        Ok(ChildViewWatcherRequest::GetStatus {
1376                            responder: ChildViewWatcherGetStatusResponder {
1377                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1378                                tx_id: header.tx_id,
1379                            },
1380                        })
1381                    }
1382                    0x3b2f3ca31e8908b4 => {
1383                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1384                        let mut req = fidl::new_empty!(
1385                            fidl::encoding::EmptyPayload,
1386                            fidl::encoding::DefaultFuchsiaResourceDialect
1387                        );
1388                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1389                        let control_handle =
1390                            ChildViewWatcherControlHandle { inner: this.inner.clone() };
1391                        Ok(ChildViewWatcherRequest::GetViewRef {
1392                            responder: ChildViewWatcherGetViewRefResponder {
1393                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1394                                tx_id: header.tx_id,
1395                            },
1396                        })
1397                    }
1398                    _ => Err(fidl::Error::UnknownOrdinal {
1399                        ordinal: header.ordinal,
1400                        protocol_name:
1401                            <ChildViewWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1402                    }),
1403                }))
1404            },
1405        )
1406    }
1407}
1408
1409/// A protocol that provides information about a particular child View which is attached to the
1410/// Viewport owned by the parent client; connections to this protocol are estabished in
1411/// [`CreateViewport`].  Since a Flatland instance may contain any number of Viewports, each of
1412/// which may or may not be attached to a transform, the client can maintain connections to an
1413/// equal number of ChildViewWatcher instances.
1414///
1415/// Each ChildViewWatcher instance will remain connected as long as the corresponding child View
1416/// exists; the connection will also be closed if the child's ViewCreationToken is dropped without
1417/// using it to create a View.
1418#[derive(Debug)]
1419pub enum ChildViewWatcherRequest {
1420    /// A hanging get for receiving the status of a View. This provides information to the parent,
1421    /// such as whether or not the child has successfully presented content through this View.
1422    ///
1423    /// This hanging get will only fire when the ChildViewStatus is different than the previously
1424    /// returned ChildViewStatus.  This can happen immediately, and even if the creator of the
1425    /// Viewport hasn't yet called Present() after calling CreateViewport().  This allows the parent
1426    /// to know that the child has content ready to display before the parent modifies their own
1427    /// local scene graph to incorporate the child content.
1428    ///
1429    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
1430    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1431    /// closed.
1432    GetStatus { responder: ChildViewWatcherGetStatusResponder },
1433    /// Hanging get to receive the ViewRef of the child View. This will only fire when the View ref
1434    /// is different from the previously-returned View ref. Note: currently the View ref will not
1435    /// change after it is first received, but this will change if/when the API changes to allow
1436    /// relinking of views.
1437    ///
1438    /// The ViewRef is not returned until the View is included in the View tree, in other words when
1439    /// there is a chain of ancestor transforms all the way back up to the root of the scene graph,
1440    /// i.e. the display.
1441    ///
1442    /// It is invalid to call `GetViewRef` while a previous call is still pending. Doing so will
1443    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1444    /// closed.
1445    ///
1446    /// A `GetViewRef` call will hang if the View was created using `CreateView`, but returns the
1447    /// View if the View was created using CreateView2. This is because `CreateView` does not mint
1448    /// a ViewRef for that View.
1449    GetViewRef { responder: ChildViewWatcherGetViewRefResponder },
1450}
1451
1452impl ChildViewWatcherRequest {
1453    #[allow(irrefutable_let_patterns)]
1454    pub fn into_get_status(self) -> Option<(ChildViewWatcherGetStatusResponder)> {
1455        if let ChildViewWatcherRequest::GetStatus { responder } = self {
1456            Some((responder))
1457        } else {
1458            None
1459        }
1460    }
1461
1462    #[allow(irrefutable_let_patterns)]
1463    pub fn into_get_view_ref(self) -> Option<(ChildViewWatcherGetViewRefResponder)> {
1464        if let ChildViewWatcherRequest::GetViewRef { responder } = self {
1465            Some((responder))
1466        } else {
1467            None
1468        }
1469    }
1470
1471    /// Name of the method defined in FIDL
1472    pub fn method_name(&self) -> &'static str {
1473        match *self {
1474            ChildViewWatcherRequest::GetStatus { .. } => "get_status",
1475            ChildViewWatcherRequest::GetViewRef { .. } => "get_view_ref",
1476        }
1477    }
1478}
1479
1480#[derive(Debug, Clone)]
1481pub struct ChildViewWatcherControlHandle {
1482    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1483}
1484
1485impl fidl::endpoints::ControlHandle for ChildViewWatcherControlHandle {
1486    fn shutdown(&self) {
1487        self.inner.shutdown()
1488    }
1489
1490    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1491        self.inner.shutdown_with_epitaph(status)
1492    }
1493
1494    fn is_closed(&self) -> bool {
1495        self.inner.channel().is_closed()
1496    }
1497    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1498        self.inner.channel().on_closed()
1499    }
1500
1501    #[cfg(target_os = "fuchsia")]
1502    fn signal_peer(
1503        &self,
1504        clear_mask: zx::Signals,
1505        set_mask: zx::Signals,
1506    ) -> Result<(), zx_status::Status> {
1507        use fidl::Peered;
1508        self.inner.channel().signal_peer(clear_mask, set_mask)
1509    }
1510}
1511
1512impl ChildViewWatcherControlHandle {}
1513
1514#[must_use = "FIDL methods require a response to be sent"]
1515#[derive(Debug)]
1516pub struct ChildViewWatcherGetStatusResponder {
1517    control_handle: std::mem::ManuallyDrop<ChildViewWatcherControlHandle>,
1518    tx_id: u32,
1519}
1520
1521/// Set the the channel to be shutdown (see [`ChildViewWatcherControlHandle::shutdown`])
1522/// if the responder is dropped without sending a response, so that the client
1523/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1524impl std::ops::Drop for ChildViewWatcherGetStatusResponder {
1525    fn drop(&mut self) {
1526        self.control_handle.shutdown();
1527        // Safety: drops once, never accessed again
1528        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1529    }
1530}
1531
1532impl fidl::endpoints::Responder for ChildViewWatcherGetStatusResponder {
1533    type ControlHandle = ChildViewWatcherControlHandle;
1534
1535    fn control_handle(&self) -> &ChildViewWatcherControlHandle {
1536        &self.control_handle
1537    }
1538
1539    fn drop_without_shutdown(mut self) {
1540        // Safety: drops once, never accessed again due to mem::forget
1541        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1542        // Prevent Drop from running (which would shut down the channel)
1543        std::mem::forget(self);
1544    }
1545}
1546
1547impl ChildViewWatcherGetStatusResponder {
1548    /// Sends a response to the FIDL transaction.
1549    ///
1550    /// Sets the channel to shutdown if an error occurs.
1551    pub fn send(self, mut status: ChildViewStatus) -> Result<(), fidl::Error> {
1552        let _result = self.send_raw(status);
1553        if _result.is_err() {
1554            self.control_handle.shutdown();
1555        }
1556        self.drop_without_shutdown();
1557        _result
1558    }
1559
1560    /// Similar to "send" but does not shutdown the channel if an error occurs.
1561    pub fn send_no_shutdown_on_err(self, mut status: ChildViewStatus) -> Result<(), fidl::Error> {
1562        let _result = self.send_raw(status);
1563        self.drop_without_shutdown();
1564        _result
1565    }
1566
1567    fn send_raw(&self, mut status: ChildViewStatus) -> Result<(), fidl::Error> {
1568        self.control_handle.inner.send::<ChildViewWatcherGetStatusResponse>(
1569            (status,),
1570            self.tx_id,
1571            0x1d622075f4fc8243,
1572            fidl::encoding::DynamicFlags::empty(),
1573        )
1574    }
1575}
1576
1577#[must_use = "FIDL methods require a response to be sent"]
1578#[derive(Debug)]
1579pub struct ChildViewWatcherGetViewRefResponder {
1580    control_handle: std::mem::ManuallyDrop<ChildViewWatcherControlHandle>,
1581    tx_id: u32,
1582}
1583
1584/// Set the the channel to be shutdown (see [`ChildViewWatcherControlHandle::shutdown`])
1585/// if the responder is dropped without sending a response, so that the client
1586/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1587impl std::ops::Drop for ChildViewWatcherGetViewRefResponder {
1588    fn drop(&mut self) {
1589        self.control_handle.shutdown();
1590        // Safety: drops once, never accessed again
1591        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1592    }
1593}
1594
1595impl fidl::endpoints::Responder for ChildViewWatcherGetViewRefResponder {
1596    type ControlHandle = ChildViewWatcherControlHandle;
1597
1598    fn control_handle(&self) -> &ChildViewWatcherControlHandle {
1599        &self.control_handle
1600    }
1601
1602    fn drop_without_shutdown(mut self) {
1603        // Safety: drops once, never accessed again due to mem::forget
1604        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1605        // Prevent Drop from running (which would shut down the channel)
1606        std::mem::forget(self);
1607    }
1608}
1609
1610impl ChildViewWatcherGetViewRefResponder {
1611    /// Sends a response to the FIDL transaction.
1612    ///
1613    /// Sets the channel to shutdown if an error occurs.
1614    pub fn send(self, mut view_ref: fidl_fuchsia_ui_views::ViewRef) -> Result<(), fidl::Error> {
1615        let _result = self.send_raw(view_ref);
1616        if _result.is_err() {
1617            self.control_handle.shutdown();
1618        }
1619        self.drop_without_shutdown();
1620        _result
1621    }
1622
1623    /// Similar to "send" but does not shutdown the channel if an error occurs.
1624    pub fn send_no_shutdown_on_err(
1625        self,
1626        mut view_ref: fidl_fuchsia_ui_views::ViewRef,
1627    ) -> Result<(), fidl::Error> {
1628        let _result = self.send_raw(view_ref);
1629        self.drop_without_shutdown();
1630        _result
1631    }
1632
1633    fn send_raw(&self, mut view_ref: fidl_fuchsia_ui_views::ViewRef) -> Result<(), fidl::Error> {
1634        self.control_handle.inner.send::<ChildViewWatcherGetViewRefResponse>(
1635            (&mut view_ref,),
1636            self.tx_id,
1637            0x3b2f3ca31e8908b4,
1638            fidl::encoding::DynamicFlags::empty(),
1639        )
1640    }
1641}
1642
1643#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1644pub struct FlatlandMarker;
1645
1646impl fidl::endpoints::ProtocolMarker for FlatlandMarker {
1647    type Proxy = FlatlandProxy;
1648    type RequestStream = FlatlandRequestStream;
1649    #[cfg(target_os = "fuchsia")]
1650    type SynchronousProxy = FlatlandSynchronousProxy;
1651
1652    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.Flatland";
1653}
1654impl fidl::endpoints::DiscoverableProtocolMarker for FlatlandMarker {}
1655
1656pub trait FlatlandProxyInterface: Send + Sync {
1657    fn r#release_image_immediately(&self, image_id: &ContentId) -> Result<(), fidl::Error>;
1658    fn r#present(&self, args: PresentArgs) -> Result<(), fidl::Error>;
1659    fn r#create_view(
1660        &self,
1661        token: fidl_fuchsia_ui_views::ViewCreationToken,
1662        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1663    ) -> Result<(), fidl::Error>;
1664    fn r#create_view2(
1665        &self,
1666        token: fidl_fuchsia_ui_views::ViewCreationToken,
1667        view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
1668        protocols: ViewBoundProtocols,
1669        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1670    ) -> Result<(), fidl::Error>;
1671    fn r#create_transform(&self, transform_id: &TransformId) -> Result<(), fidl::Error>;
1672    fn r#set_translation(
1673        &self,
1674        transform_id: &TransformId,
1675        translation: &fidl_fuchsia_math::Vec_,
1676    ) -> Result<(), fidl::Error>;
1677    fn r#set_orientation(
1678        &self,
1679        transform_id: &TransformId,
1680        orientation: Orientation,
1681    ) -> Result<(), fidl::Error>;
1682    fn r#set_scale(
1683        &self,
1684        transform_id: &TransformId,
1685        scale: &fidl_fuchsia_math::VecF,
1686    ) -> Result<(), fidl::Error>;
1687    fn r#set_opacity(&self, transform_id: &TransformId, value: f32) -> Result<(), fidl::Error>;
1688    fn r#set_clip_boundary(
1689        &self,
1690        transform_id: &TransformId,
1691        rect: Option<&fidl_fuchsia_math::Rect>,
1692    ) -> Result<(), fidl::Error>;
1693    fn r#add_child(
1694        &self,
1695        parent_transform_id: &TransformId,
1696        child_transform_id: &TransformId,
1697    ) -> Result<(), fidl::Error>;
1698    fn r#remove_child(
1699        &self,
1700        parent_transform_id: &TransformId,
1701        child_transform_id: &TransformId,
1702    ) -> Result<(), fidl::Error>;
1703    fn r#replace_children(
1704        &self,
1705        parent_transform_id: &TransformId,
1706        new_child_transform_ids: &[TransformId],
1707    ) -> Result<(), fidl::Error>;
1708    fn r#set_root_transform(&self, transform_id: &TransformId) -> Result<(), fidl::Error>;
1709    fn r#set_hit_regions(
1710        &self,
1711        transform_id: &TransformId,
1712        regions: &[HitRegion],
1713    ) -> Result<(), fidl::Error>;
1714    fn r#set_infinite_hit_region(
1715        &self,
1716        transform_id: &TransformId,
1717        hit_test: HitTestInteraction,
1718    ) -> Result<(), fidl::Error>;
1719    fn r#create_viewport(
1720        &self,
1721        viewport_id: &ContentId,
1722        token: fidl_fuchsia_ui_views::ViewportCreationToken,
1723        properties: &ViewportProperties,
1724        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
1725    ) -> Result<(), fidl::Error>;
1726    fn r#create_image(
1727        &self,
1728        image_id: &ContentId,
1729        import_token: BufferCollectionImportToken,
1730        vmo_index: u32,
1731        properties: &ImageProperties,
1732    ) -> Result<(), fidl::Error>;
1733    fn r#set_image_sample_region(
1734        &self,
1735        image_id: &ContentId,
1736        rect: &fidl_fuchsia_math::RectF,
1737    ) -> Result<(), fidl::Error>;
1738    fn r#set_image_destination_size(
1739        &self,
1740        image_id: &ContentId,
1741        size: &fidl_fuchsia_math::SizeU,
1742    ) -> Result<(), fidl::Error>;
1743    fn r#set_image_blending_function(
1744        &self,
1745        image_id: &ContentId,
1746        blend_mode: BlendMode,
1747    ) -> Result<(), fidl::Error>;
1748    fn r#set_image_blend_mode(
1749        &self,
1750        image_id: &ContentId,
1751        blend_mode: BlendMode2,
1752    ) -> Result<(), fidl::Error>;
1753    fn r#set_image_opacity(&self, image_id: &ContentId, val: f32) -> Result<(), fidl::Error>;
1754    fn r#set_image_flip(&self, image_id: &ContentId, flip: ImageFlip) -> Result<(), fidl::Error>;
1755    fn r#create_filled_rect(&self, rect_id: &ContentId) -> Result<(), fidl::Error>;
1756    fn r#set_solid_fill(
1757        &self,
1758        rect_id: &ContentId,
1759        color: &ColorRgba,
1760        size: &fidl_fuchsia_math::SizeU,
1761    ) -> Result<(), fidl::Error>;
1762    fn r#release_filled_rect(&self, rect_id: &ContentId) -> Result<(), fidl::Error>;
1763    fn r#set_content(
1764        &self,
1765        transform_id: &TransformId,
1766        content_id: &ContentId,
1767    ) -> Result<(), fidl::Error>;
1768    fn r#set_viewport_properties(
1769        &self,
1770        viewport_id: &ContentId,
1771        properties: &ViewportProperties,
1772    ) -> Result<(), fidl::Error>;
1773    fn r#release_transform(&self, transform_id: &TransformId) -> Result<(), fidl::Error>;
1774    fn r#release_view(&self) -> Result<(), fidl::Error>;
1775    type ReleaseViewportResponseFut: std::future::Future<
1776            Output = Result<fidl_fuchsia_ui_views::ViewportCreationToken, fidl::Error>,
1777        > + Send;
1778    fn r#release_viewport(&self, viewport_id: &ContentId) -> Self::ReleaseViewportResponseFut;
1779    fn r#release_image(&self, image_id: &ContentId) -> Result<(), fidl::Error>;
1780    fn r#clear(&self) -> Result<(), fidl::Error>;
1781    fn r#set_debug_name(&self, name: &str) -> Result<(), fidl::Error>;
1782}
1783#[derive(Debug)]
1784#[cfg(target_os = "fuchsia")]
1785pub struct FlatlandSynchronousProxy {
1786    client: fidl::client::sync::Client,
1787}
1788
1789#[cfg(target_os = "fuchsia")]
1790impl fidl::endpoints::SynchronousProxy for FlatlandSynchronousProxy {
1791    type Proxy = FlatlandProxy;
1792    type Protocol = FlatlandMarker;
1793
1794    fn from_channel(inner: fidl::Channel) -> Self {
1795        Self::new(inner)
1796    }
1797
1798    fn into_channel(self) -> fidl::Channel {
1799        self.client.into_channel()
1800    }
1801
1802    fn as_channel(&self) -> &fidl::Channel {
1803        self.client.as_channel()
1804    }
1805}
1806
1807#[cfg(target_os = "fuchsia")]
1808impl FlatlandSynchronousProxy {
1809    pub fn new(channel: fidl::Channel) -> Self {
1810        let protocol_name = <FlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1811        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1812    }
1813
1814    pub fn into_channel(self) -> fidl::Channel {
1815        self.client.into_channel()
1816    }
1817
1818    /// Waits until an event arrives and returns it. It is safe for other
1819    /// threads to make concurrent requests while waiting for an event.
1820    pub fn wait_for_event(
1821        &self,
1822        deadline: zx::MonotonicInstant,
1823    ) -> Result<FlatlandEvent, fidl::Error> {
1824        FlatlandEvent::decode(self.client.wait_for_event(deadline)?)
1825    }
1826
1827    /// Releases an image immediately, without waiting for the next present.
1828    pub fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
1829        self.client.send::<TrustedFlatlandReleaseImageImmediatelyRequest>(
1830            (image_id,),
1831            0x245e1ac080772c8,
1832            fidl::encoding::DynamicFlags::empty(),
1833        )
1834    }
1835
1836    /// Complete execution of all feed-forward operations.
1837    ///
1838    /// If executing an operation produces an error (e.g., CreateTransform(0)), an [`OnError`] event
1839    /// is emitted. Operations that produce errors are ignored and the channel is closed.
1840    ///
1841    /// If the execution is completed successfully, [`OnNextFrameBegin`] emits NO_ERROR along
1842    /// with other valid fields.
1843    ///
1844    /// The client may only call [`Present`] when they have a non-zero number of present credits,
1845    /// which are tracked by the server. The server may increment the number of credits when it
1846    /// fires the [`OnNextFrameBegin`] event, which informs the client when it receives additional
1847    /// present credits. Each [`Present`] call uses one present credit and decrements the server
1848    /// count by one. If the client calls [`Present`] with no present credits, the server will
1849    /// return a `NO_PRESENTS_REMAINING` error.
1850    ///
1851    /// The client should assume that prior to receiving any [`OnNextFrameBegin`] events, they have
1852    /// one present credit.
1853    ///
1854    /// Every [`Present`] call results in one [`OnNextFrameBegin`] event, and one
1855    /// [`OnFramePresented`] event, typically in that order.
1856    ///
1857    /// When the commands flushed by [`Present`] make it to display, an [`OnFramePresented`] event
1858    /// is fired. This event includes information pertaining to all [`Present`]s that had content
1859    /// that were part of that frame.
1860    ///
1861    /// See [`fuchsia.ui.composition/PresentArgs`] documentation above for more detailed information
1862    /// on what arguments are passed in and their role.
1863    pub fn r#present(&self, mut args: PresentArgs) -> Result<(), fidl::Error> {
1864        self.client.send::<FlatlandPresentRequest>(
1865            (&mut args,),
1866            0x50acc2aa1f0acec7,
1867            fidl::encoding::DynamicFlags::empty(),
1868        )
1869    }
1870
1871    /// Two Flatland instances may be connected in a parent-child relationship. The parent endpoint
1872    /// is held in a Viewport, and the child endpoint is held in a View. The parent Flatland
1873    /// instance that creates a Viewport has control over how the child's View is integrated into
1874    /// its own View.
1875    ///
1876    /// The lifecycle of a parent-child connection starts with two endpoints of a channel object:
1877    /// a ViewportCreationToken and a ViewCreationToken. Out-of-band protocols pass the
1878    /// ViewportCreationToken to the parent, which calls [`CreateViewport`], and the
1879    /// ViewCreationToken to the child, which calls [`CreateView`].
1880    ///
1881    /// Only nodes connected to the Root Transform in this Flatland instance will be rendered into
1882    /// the parent's Viewport.
1883    ///
1884    /// Calling [`CreateView`] a second time will disconnect the Root Transform from the existing
1885    /// parent's Viewport, and attach it to a new parent's Viewport. In other words, each View can
1886    /// only have one parent.
1887    ///
1888    /// This function is queued, meaning that the Root Transform will not be attached to the
1889    /// parent Viewport until [`Present`] is called. However, clients will receive information
1890    /// through their ParentViewportWatcher (e.g., LayoutInfo) immediately after calling this
1891    /// function, even if they have not called [`Present`] or [`SetRootTransform`]. This allows
1892    /// clients to wait for layout information from their parent before calling [`Present`].
1893    ///
1894    /// Any illegal operations on ParentViewportWatcher will cause both ParentViewportWatcher
1895    /// channel and this Flatland channel to be torn down.
1896    ///
1897    /// Lifecycle note. The lifetime of the ParentViewportWatcher channel is bound by the peer
1898    /// ViewportCreationToken. When the ViewportCreationToken dies, this ParentViewportWatcher
1899    /// channel is destroyed.
1900    ///
1901    /// Views and subgraphs of Views created using `CreateView` will not be represented in the
1902    /// ViewTree, and hence will not be able to participate in any ViewTree-dependent interactions
1903    /// such as touch, mouse or focus.
1904    /// The Flatland protocol provides no way for Views in the subgraph of a View created with
1905    /// `CreateView` to know that they are excluded from the ViewTree.
1906    pub fn r#create_view(
1907        &self,
1908        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
1909        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1910    ) -> Result<(), fidl::Error> {
1911        self.client.send::<FlatlandCreateViewRequest>(
1912            (&mut token, parent_viewport_watcher),
1913            0x504686eb25864780,
1914            fidl::encoding::DynamicFlags::empty(),
1915        )
1916    }
1917
1918    /// Identical to [`CreateView`], except it allows association of View identity (ViewRef) and
1919    /// view-bound protocols.
1920    pub fn r#create_view2(
1921        &self,
1922        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
1923        mut view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
1924        mut protocols: ViewBoundProtocols,
1925        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1926    ) -> Result<(), fidl::Error> {
1927        self.client.send::<FlatlandCreateView2Request>(
1928            (&mut token, &mut view_identity, &mut protocols, parent_viewport_watcher),
1929            0x340a3a40c2fdbd5e,
1930            fidl::encoding::DynamicFlags::empty(),
1931        )
1932    }
1933
1934    /// Creates a new Transform node. Transforms are a hierarchical piece of a Flatland graph. They
1935    /// can have children, and can reference Content. A sub-graph represented by a Transform and its
1936    /// descendants can be rendered to a display.
1937    ///
1938    /// Transforms are kept alive, even when released, as long as they are children of either an
1939    /// unreleased Transform, or the Root Transform.
1940    ///
1941    /// Each Transform can have a single piece of attached Content. Common types of Content include
1942    /// bitmaps, asynchronous streams of images, and Viewports to Views hosted in other Flatland
1943    /// instances.
1944    ///
1945    /// Transforms have attributes. Child Transforms inherit the combined attributes of their
1946    /// parents. Content attached to a Transform is also affected by that Transform's attributes.
1947    ///
1948    /// When a sub-graph of Transforms is rendered, Content will be rendered back-to-front, starting
1949    /// with the Content on the root transform, and continuing recursively through all of its child
1950    /// Transforms in the order the children were added. See [`AddChild`] for more information.
1951    ///
1952    /// Zero is not a valid transform id. All other values are valid, assuming they are not already
1953    /// in use (see [`ReleaseTransform`] for more details).
1954    pub fn r#create_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
1955        self.client.send::<FlatlandCreateTransformRequest>(
1956            (transform_id,),
1957            0x5e042a4d3de3efb0,
1958            fidl::encoding::DynamicFlags::empty(),
1959        )
1960    }
1961
1962    /// All Transform objects support all attributes.
1963    ///
1964    /// Geometric attributes are applied in the following order:
1965    /// 1. Scale (relative to the parent transform's coordinate space)
1966    /// 2. Orientation (relative to the parent transform's coordinate space)
1967    /// 3. Translation (relative to the parent transforms's coordinate space,
1968    ///    unaffected by scale applied to the current transform).
1969    /// 4. Clipping (relative to the current transform's coordinate space)
1970    ///
1971    /// The effects of each of these attributes are cumulative. This means the transform's position
1972    /// in the view space, and its clip boundary, will be calculated based on that chain of
1973    /// geometric attributes going up to the root transform.
1974    ///
1975    /// For instance, in a nested hierarchy such as the following:
1976    ///     [Root-Transform -> Transform1 -> Transform2 -> CurrentTransform]
1977    /// If Transform1 is translated by [2,0] and Transform2 is translated by [0,1] then the
1978    /// view-space position of CurrentTransform will be [2,1].
1979    ///
1980    /// Sets the translation on a Transform. The order of geometric attribute application is
1981    /// addressed above.
1982    pub fn r#set_translation(
1983        &self,
1984        mut transform_id: &TransformId,
1985        mut translation: &fidl_fuchsia_math::Vec_,
1986    ) -> Result<(), fidl::Error> {
1987        self.client.send::<FlatlandSetTranslationRequest>(
1988            (transform_id, translation),
1989            0x7863398291fba346,
1990            fidl::encoding::DynamicFlags::empty(),
1991        )
1992    }
1993
1994    /// Sets the orientation on a Transform. The order of geometric attribute application is
1995    /// addressed in the documentation for [`SetTranslation`]. In Flatland, the +X axis is
1996    /// to the right and the +Y axis is down. There is no notion of a Z axis. CCW is defined
1997    /// from the POV of the user, as if a skeuomorphoic clock is displayed on the screen.
1998    pub fn r#set_orientation(
1999        &self,
2000        mut transform_id: &TransformId,
2001        mut orientation: Orientation,
2002    ) -> Result<(), fidl::Error> {
2003        self.client.send::<FlatlandSetOrientationRequest>(
2004            (transform_id, orientation),
2005            0x4915310bc4928edc,
2006            fidl::encoding::DynamicFlags::empty(),
2007        )
2008    }
2009
2010    /// Sets the scale on a transform. The order of geometric attribute application is
2011    /// addressed above. The (x,y) values in the VecF |scale| refer to the scale factor in the
2012    /// x-axis (width) and y-axis (height) respectively. Scale values must be normal 32-bit
2013    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29
2014    pub fn r#set_scale(
2015        &self,
2016        mut transform_id: &TransformId,
2017        mut scale: &fidl_fuchsia_math::VecF,
2018    ) -> Result<(), fidl::Error> {
2019        self.client.send::<FlatlandSetScaleRequest>(
2020            (transform_id, scale),
2021            0x1ea1766fd8996bb4,
2022            fidl::encoding::DynamicFlags::empty(),
2023        )
2024    }
2025
2026    /// Sets an opacity in linear space to be applied to a transform and its descendents,
2027    /// which include other transforms and content. Opacity values must be in the range
2028    /// of [0.0, 1.0], where 0.0 is completely transparent and 1.0 is completely opaque.
2029    /// Attempting to call this function with values outside that range will result in
2030    /// an error. A transform's opacity value is multiplied with that of its parent. This
2031    /// effect works differently from group opacity. Using group opacity, child nodes are
2032    /// rendered together first, and then have the parent's opacity applied as a post-effect.
2033    /// Here, opacity is applied to each child individually. This may result in a very
2034    /// different effect.
2035    pub fn r#set_opacity(
2036        &self,
2037        mut transform_id: &TransformId,
2038        mut value: f32,
2039    ) -> Result<(), fidl::Error> {
2040        self.client.send::<FlatlandSetOpacityRequest>(
2041            (transform_id, value),
2042            0x3775fc2c00b432fa,
2043            fidl::encoding::DynamicFlags::empty(),
2044        )
2045    }
2046
2047    /// Sets the bounds, expressed in the local coordinate space of the transform, that
2048    /// constrains the region that content attached to this transform can be rendered to.
2049    /// If the content's area exceeds the clip bounds, the area outside the bounds will
2050    /// not be rendered. These bounds are valid for all children of this transform node as
2051    /// well, which includes nested Flatland instances and their node hierarchies.
2052    /// If a child transform attempts to set clip bounds larger than that of its parent,
2053    /// it will be clipped to the parent's clip bounds. The default state is for a transform
2054    /// to be unclipped, meaning it will not have any bounds placed on its render region.
2055    /// The clip width/height must be positive. Negative values will result in an error.
2056    /// Passing in an empty box to the |rect| parameter will remove the clip bounds.
2057    pub fn r#set_clip_boundary(
2058        &self,
2059        mut transform_id: &TransformId,
2060        mut rect: Option<&fidl_fuchsia_math::Rect>,
2061    ) -> Result<(), fidl::Error> {
2062        self.client.send::<FlatlandSetClipBoundaryRequest>(
2063            (transform_id, rect),
2064            0x6507843df12222d2,
2065            fidl::encoding::DynamicFlags::empty(),
2066        )
2067    }
2068
2069    /// Adds a child Transform to a parent Transform. The new child Transform,
2070    /// and any Content attached to it or its children, will be rendered on top
2071    /// of the parent's Content, as well as any previously added children.
2072    ///
2073    /// The caller must ensure that `child_transform_id` is valid and that there
2074    /// are no repetitions.  Sending a repeated `child_transform_id` over
2075    /// multiple calls will result in session closure.
2076    pub fn r#add_child(
2077        &self,
2078        mut parent_transform_id: &TransformId,
2079        mut child_transform_id: &TransformId,
2080    ) -> Result<(), fidl::Error> {
2081        self.client.send::<FlatlandAddChildRequest>(
2082            (parent_transform_id, child_transform_id),
2083            0x67a8abd2f19b1a74,
2084            fidl::encoding::DynamicFlags::empty(),
2085        )
2086    }
2087
2088    /// Removes a child Transform from a parent Transform.
2089    pub fn r#remove_child(
2090        &self,
2091        mut parent_transform_id: &TransformId,
2092        mut child_transform_id: &TransformId,
2093    ) -> Result<(), fidl::Error> {
2094        self.client.send::<FlatlandRemoveChildRequest>(
2095            (parent_transform_id, child_transform_id),
2096            0x41d6cd90b298b67a,
2097            fidl::encoding::DynamicFlags::empty(),
2098        )
2099    }
2100
2101    /// Removes all child Transforms from a parent Transform and replaces them
2102    /// with the new child transforms in `new_child_transform_ids`.  The caller
2103    /// must ensure that all `TransformId` values in `new_child_transform_ids`
2104    /// are valid and that there are no repetitions.  Sending a repeated
2105    /// `TransformId` in `new_child_transform_ids` will result in session
2106    /// closure.
2107    pub fn r#replace_children(
2108        &self,
2109        mut parent_transform_id: &TransformId,
2110        mut new_child_transform_ids: &[TransformId],
2111    ) -> Result<(), fidl::Error> {
2112        self.client.send::<FlatlandReplaceChildrenRequest>(
2113            (parent_transform_id, new_child_transform_ids),
2114            0x5b6d86cbbff81316,
2115            fidl::encoding::DynamicFlags::empty(),
2116        )
2117    }
2118
2119    /// Sets the Root Transform for the graph.
2120    ///
2121    /// The sub-graph defined by the Root Transform and its children will be rendered as View
2122    /// in the connected parent's Viewport (see [`CreateView`]). Any parents of the Root Transform
2123    /// in this Graph will be ignored.
2124    ///
2125    /// The Root Transform, and all children of the Root Transform, are kept alive if they are
2126    /// released (see [`ReleaseTransform`] for more details).
2127    ///
2128    /// There is only ever one Root. Since 0 is not a valid transform id (see [`CreateTransform`]),
2129    /// calling SetRootTransform(0) clears the current Root, destroying any previously released
2130    /// objects that are not referenced by the new root.
2131    ///
2132    /// Note that every View has a clip boundary equivalent to its logical size. Anything outside
2133    /// that clip boundary will not be rendered. Hence, the Root Transform has a useful coordinate
2134    /// space of (0, 0) to (logical_size.width, logical_size.height), where (0, 0) is the upper left
2135    /// corner.
2136    ///
2137    /// Setting the root transform installs a full screen hit region on the root transform. Clients
2138    /// may remove this hit region if they don't want users to be able to interact with the root
2139    /// transform's content. For additional details on hit regions, see the [`SetHitRegions`]
2140    /// documentation.
2141    ///
2142    /// Default hit region rules
2143    ///
2144    ///   A default hit region follows these rules:
2145    ///   - When [`SetRootTransform`](T) is called, T receives a maximal hit region, covering the
2146    ///   entire view.
2147    ///   - If [`SetHitRegions`] is called on T, either before or after [`SetRootTransform`](T),
2148    ///   then no default hit region is active and the client specified hit regions are used.
2149    ///   - If a transform is no longer the root transform, i.e., [`SetRootTransform`](U) is
2150    ///   called, then the original transform no longer has its default hit region.
2151    ///   - Clients can remove or modify the root transform's hit regions the same way they would
2152    ///   reset any other transform's hit regions, by calling [`SetHitRegions`] with the appropriate
2153    ///   vector.
2154    pub fn r#set_root_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2155        self.client.send::<FlatlandSetRootTransformRequest>(
2156            (transform_id,),
2157            0x6e80ca5bcc566cd8,
2158            fidl::encoding::DynamicFlags::empty(),
2159        )
2160    }
2161
2162    /// Sets the interactive areas for a Transform. By default, Content is not interactive; hit
2163    /// regions must be placed for a user to interact with the Content in a View. Because hit
2164    /// regions are described in the Flatland protocol, a Flatland instance can synchronize Content
2165    /// and hit regions.
2166    ///
2167    /// Each hit region is placed in the coordinate space of the owning Transform, and may or may
2168    /// not interact with different types of hit testing, depending on its [`HitTestInteraction`]
2169    /// type. When there are multiple hit regions that intersect with a hit test, the precedence
2170    /// rules given below dictate which hit region has interacted with the hit test. Only Transforms
2171    /// that transitively connect to the root Transform have their hit regions interact with a hit
2172    /// test.
2173    ///
2174    /// Calling this function replaces any previous values set on this Transform. To reset a
2175    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2176    ///
2177    /// Note that root transforms get a default hit region installed by Flatland. For more details,
2178    /// see the [`SetRootTransform`] documentation.
2179    ///
2180    /// Precedence rules
2181    ///   Within a Transform, if multiple hit regions overlap, the hit test examines each
2182    ///   intersecting hit region for a possible interaction. Thus, for a regular hit test R and an
2183    ///   accessibility hit test A, where R and A both intersect two hit regions D ([`DEFAULT`]) and
2184    ///   S ([`SEMANTICALLY_INVISIBLE`]) on the same Transform, (1) R interacts with both D and S,
2185    ///   and (2) A only interacts with D. Generally, hit regions that overlap in a single Transform
2186    ///   can cause confusing behavior.
2187    ///
2188    ///   Within a View, for a given hit test, the front-most Transform's hit regions take
2189    ///   precedence over those behind. This follows the expected reverse "render order" of
2190    ///   Transforms (described in [`CreateTransform`]), where a user expects to interact with
2191    ///   Content that is visible, or front-most.
2192    ///
2193    ///   Across Flatland instances, for a given hit test, the front-most instance's front-most
2194    ///   Transform's hit regions take precedence over those behind. This follows the expected
2195    ///   reverse "render order" of views, where a user expects to interact with the View that is
2196    ///   visible, or front-most. For example, if a child View owns Content that is rendered over
2197    ///   the parent View, the user expects to interact with the child's Content.
2198    pub fn r#set_hit_regions(
2199        &self,
2200        mut transform_id: &TransformId,
2201        mut regions: &[HitRegion],
2202    ) -> Result<(), fidl::Error> {
2203        self.client.send::<FlatlandSetHitRegionsRequest>(
2204            (transform_id, regions),
2205            0x31c9d17b07c37ce4,
2206            fidl::encoding::DynamicFlags::empty(),
2207        )
2208    }
2209
2210    /// Identical to [`SetHitRegions`], except the hit region associated with [`transform_id`]
2211    /// covers an infinite region. The hit region is invariant against translation, scaling, and
2212    /// orientation of the Transform.
2213    ///
2214    /// An infinite hit region is still limited in extent by the View's clip boundary, just like a
2215    /// finite hit region.
2216    ///
2217    /// Calling this function replaces any previous values set on this Transform. To reset a
2218    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2219    pub fn r#set_infinite_hit_region(
2220        &self,
2221        mut transform_id: &TransformId,
2222        mut hit_test: HitTestInteraction,
2223    ) -> Result<(), fidl::Error> {
2224        self.client.send::<FlatlandSetInfiniteHitRegionRequest>(
2225            (transform_id, hit_test),
2226            0x26d81af852d29562,
2227            fidl::encoding::DynamicFlags::empty(),
2228        )
2229    }
2230
2231    /// The Viewport and View pair, together, represent the connection between two Flatland
2232    /// instances. The Viewport is created in the parent, and the View is created in the child. The
2233    /// parent has control over how the child's View is integrated into its own View.
2234    ///
2235    /// Any illegal operations on ChildViewWatcher will cause both ChildViewWatcher channel and this
2236    /// Flatland channel to be torn down.
2237    ///
2238    /// `ViewportProperties` must have logical_size set. This is the initial size that will drive
2239    /// the layout of the child. The logical_size is also used as the default Content size, but
2240    /// subsequent changes to the logical_size will have no effect on the Content size.
2241    ///
2242    /// `ViewportProperties` may have inset field not set. In that case, the default value of
2243    /// (0, 0, 0, 0) is used.
2244    ///
2245    /// The logical_size must have positive X and Y components.
2246    ///
2247    /// Zero is not a valid ContentId. All other values are valid, assuming they are not already
2248    /// in use for another piece of Content (see [`ReleaseViewport`] for more details).
2249    ///
2250    /// Lifecycle note. The lifetime of the ChildViewWatcher channel is bound by the peer
2251    /// ViewCreationToken. When the ViewCreationToken dies, this ChildViewWatcher channel is
2252    /// destroyed.
2253    pub fn r#create_viewport(
2254        &self,
2255        mut viewport_id: &ContentId,
2256        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
2257        mut properties: &ViewportProperties,
2258        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
2259    ) -> Result<(), fidl::Error> {
2260        self.client.send::<FlatlandCreateViewportRequest>(
2261            (viewport_id, &mut token, properties, child_view_watcher),
2262            0x2485fbcab7f943c,
2263            fidl::encoding::DynamicFlags::empty(),
2264        )
2265    }
2266
2267    /// An Image is a bitmap backed by a specific VMO in a BufferCollection.
2268    ///
2269    /// Image creation requires an allocated BufferCollection registered with Allocator. This
2270    /// function will fail unless all clients of the specified BufferCollection have set their
2271    /// constraints.
2272    ///
2273    /// The Image must reference a valid VMO index and must have ImageProperties that fall within
2274    /// the constraints specified by the backing BufferCollection (i.e. width and height within a
2275    /// valid range, etc.)
2276    ///
2277    /// Zero is not a valid Image id. All other values are valid, assuming they are not already in
2278    /// use for another piece of Content (see [`ReleaseImage`] for more details).
2279    pub fn r#create_image(
2280        &self,
2281        mut image_id: &ContentId,
2282        mut import_token: BufferCollectionImportToken,
2283        mut vmo_index: u32,
2284        mut properties: &ImageProperties,
2285    ) -> Result<(), fidl::Error> {
2286        self.client.send::<FlatlandCreateImageRequest>(
2287            (image_id, &mut import_token, vmo_index, properties),
2288            0x26fae823c4ebedad,
2289            fidl::encoding::DynamicFlags::empty(),
2290        )
2291    }
2292
2293    /// This function is used to determine the region (in texel space) of an image that will be used
2294    /// by Flatland when rendering. The image to be sampled is referenced by [`image_id`] and the
2295    /// sample region is specified by [`rect`] which itself is comprised of an origin point (x,y) as
2296    /// well as a width and height, in unnormalized coordinates. It is illegal to call this function
2297    /// on non-image content, or to sample a region outside of the texel space of the image. In
2298    /// other words, the region specifed by [`rect`] must not exceed the ranges (0, image_width) and
2299    /// (0, image_height). If (rect.x + rect.width > image_width) or (rect.y + rect.height >
2300    /// image_height) or if any of the values are negative, this will result in an error.
2301    ///
2302    /// If this method is not called, the default sample region is the rectangle with origin at
2303    /// (0, 0) and width and height set at ImageProperties from [`CreateImage`].
2304    pub fn r#set_image_sample_region(
2305        &self,
2306        mut image_id: &ContentId,
2307        mut rect: &fidl_fuchsia_math::RectF,
2308    ) -> Result<(), fidl::Error> {
2309        self.client.send::<FlatlandSetImageSampleRegionRequest>(
2310            (image_id, rect),
2311            0x8039391d715eb28,
2312            fidl::encoding::DynamicFlags::empty(),
2313        )
2314    }
2315
2316    /// The content size for an Image is the size of the rectangle in the parent's logical
2317    /// coordinate space that the image occupies. This combined with the global translation of the
2318    /// transform it is attached to determines the size and location of where the content is
2319    /// rendered on the display.
2320    ///
2321    /// If this method is not called, the default image destination size is the width and height set
2322    /// at ImageProperties from [`CreateImage`]. The destination size will be affected by scaling if
2323    /// [`SetScale`] is used on the attached Transform or its parents.
2324    pub fn r#set_image_destination_size(
2325        &self,
2326        mut image_id: &ContentId,
2327        mut size: &fidl_fuchsia_math::SizeU,
2328    ) -> Result<(), fidl::Error> {
2329        self.client.send::<FlatlandSetImageDestinationSizeRequest>(
2330            (image_id, size),
2331            0x766cf99a2ec58446,
2332            fidl::encoding::DynamicFlags::empty(),
2333        )
2334    }
2335
2336    /// Determines the blend function to use when rendering the content specified by
2337    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
2338    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
2339    /// that are available, please refer to the BlendMode enum. If this function is not called, then
2340    /// the default blendmode is BlendMode::SRC.
2341    pub fn r#set_image_blending_function(
2342        &self,
2343        mut image_id: &ContentId,
2344        mut blend_mode: BlendMode,
2345    ) -> Result<(), fidl::Error> {
2346        self.client.send::<FlatlandSetImageBlendingFunctionRequest>(
2347            (image_id, blend_mode),
2348            0x10f5da1356275b7b,
2349            fidl::encoding::DynamicFlags::empty(),
2350        )
2351    }
2352
2353    /// Determines the blend function to use when rendering the content specified by
2354    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
2355    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
2356    /// that are available, please refer to the BlendMode2 enum. If this function is not called,
2357    /// the default blendmode is BlendMode2::REPLACE.
2358    pub fn r#set_image_blend_mode(
2359        &self,
2360        mut image_id: &ContentId,
2361        mut blend_mode: BlendMode2,
2362    ) -> Result<(), fidl::Error> {
2363        self.client.send::<FlatlandSetImageBlendModeRequest>(
2364            (image_id, blend_mode),
2365            0x5b1667f130c3de67,
2366            fidl::encoding::DynamicFlags::empty(),
2367        )
2368    }
2369
2370    /// Sets an opacity in linear space to be applied to a flatland image. Opacity values must
2371    /// be in the range [0.0, 1.0].
2372    pub fn r#set_image_opacity(
2373        &self,
2374        mut image_id: &ContentId,
2375        mut val: f32,
2376    ) -> Result<(), fidl::Error> {
2377        self.client.send::<FlatlandSetImageOpacityRequest>(
2378            (image_id, val),
2379            0x2da9e4ef4c2cff6f,
2380            fidl::encoding::DynamicFlags::empty(),
2381        )
2382    }
2383
2384    /// Sets the image flip to be applied to a flatland image. This call must be performed after a
2385    /// successful |CreateImage| call. If an invalid |image_id| is supplied, the channel will be
2386    /// closed due to FlatlandError::BAD_OPERATION. This flip will be applied to the Image before
2387    /// parent Transform Orientations. If this function is not called, then the default flip value
2388    /// is ImageFlip::NONE.
2389    pub fn r#set_image_flip(
2390        &self,
2391        mut image_id: &ContentId,
2392        mut flip: ImageFlip,
2393    ) -> Result<(), fidl::Error> {
2394        self.client.send::<FlatlandSetImageFlipRequest>(
2395            (image_id, flip),
2396            0x21b20f2c14aae6bc,
2397            fidl::encoding::DynamicFlags::empty(),
2398        )
2399    }
2400
2401    /// Creates a solid-color rectangle. By default a filled-rect does not have a defined
2402    /// color or size. It is necessary to call |SetSolidFill| to specify a color and size
2403    /// before a filled rect can be used for rendering. Not doing so will result the
2404    pub fn r#create_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
2405        self.client.send::<FlatlandCreateFilledRectRequest>(
2406            (rect_id,),
2407            0x5e62355abc1c4c5d,
2408            fidl::encoding::DynamicFlags::empty(),
2409        )
2410    }
2411
2412    /// Defines the color and size of a filled rect. |rect_id| must refer to content that
2413    /// was created via a call to CreateFilledRect. The color is not premultiplied. Color values
2414    /// must be within the range [0,1] inclusive, and normal 32-bit
2415    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29. Values
2416    /// that do not conform to these specifications will cause the channel to close.
2417    /// The rectangle's top left corner will be at (0, 0) in its transform's coordinate space.
2418    /// Hence, its bottom right corner will be at (size.width, size.height).
2419    pub fn r#set_solid_fill(
2420        &self,
2421        mut rect_id: &ContentId,
2422        mut color: &ColorRgba,
2423        mut size: &fidl_fuchsia_math::SizeU,
2424    ) -> Result<(), fidl::Error> {
2425        self.client.send::<FlatlandSetSolidFillRequest>(
2426            (rect_id, color, size),
2427            0x32d6ef41e182dfa5,
2428            fidl::encoding::DynamicFlags::empty(),
2429        )
2430    }
2431
2432    /// Automatically garbage collects the rectangle when it is no longer needed for
2433    /// rendering. |rect_id| must have been instantiated with a call to
2434    /// |CreateFilledRect|. Once released, the ID immediately goes out of scope and is free
2435    /// to be used again.
2436    pub fn r#release_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
2437        self.client.send::<FlatlandReleaseFilledRectRequest>(
2438            (rect_id,),
2439            0x7392cabe45618f9b,
2440            fidl::encoding::DynamicFlags::empty(),
2441        )
2442    }
2443
2444    /// Setting a piece of Content on a Transform makes that Content visible in the render tree as
2445    /// long as the Transform is visible from the root Transform. The Content will be rendered
2446    /// before, and therefore "behind", any Content attached to the descendants of the Transform.
2447    ///
2448    /// Because each Transform can have, at most, a single piece of Content on it, calling this
2449    /// function on a Transform that already has Content will replace that Content.
2450    ///
2451    /// A Content may be set on more than one Transform.
2452    ///
2453    /// Calling this function with a Content id of 0 will remove any Content currently on the
2454    /// Transform.
2455    pub fn r#set_content(
2456        &self,
2457        mut transform_id: &TransformId,
2458        mut content_id: &ContentId,
2459    ) -> Result<(), fidl::Error> {
2460        self.client.send::<FlatlandSetContentRequest>(
2461            (transform_id, content_id),
2462            0x4ed2cfc0ce130862,
2463            fidl::encoding::DynamicFlags::empty(),
2464        )
2465    }
2466
2467    /// Transforms are usually sufficient to change how Content is presented. Viewports, however,
2468    /// have special properties that are not part of the Transform hierarchy. Those properties can
2469    /// be set using this function.
2470    pub fn r#set_viewport_properties(
2471        &self,
2472        mut viewport_id: &ContentId,
2473        mut properties: &ViewportProperties,
2474    ) -> Result<(), fidl::Error> {
2475        self.client.send::<FlatlandSetViewportPropertiesRequest>(
2476            (viewport_id, properties),
2477            0x66ab67e9608ddb9f,
2478            fidl::encoding::DynamicFlags::empty(),
2479        )
2480    }
2481
2482    /// Released Transforms will be garbage collected by the system once they are no longer
2483    /// necessary for rendering. For Transforms, this means there is no path from any unreleased
2484    /// Transform to the newly-released Transform.
2485    ///
2486    /// Once released, the id immediately goes out of scope for future function calls and can be
2487    /// reused when creating new Transforms.
2488    ///
2489    /// It is an error to call functions with a released id (unless that id has been reused to
2490    /// construct a new Transform).
2491    pub fn r#release_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2492        self.client.send::<FlatlandReleaseTransformRequest>(
2493            (transform_id,),
2494            0xab9328419451c22,
2495            fidl::encoding::DynamicFlags::empty(),
2496        )
2497    }
2498
2499    pub fn r#release_view(&self) -> Result<(), fidl::Error> {
2500        self.client.send::<fidl::encoding::EmptyPayload>(
2501            (),
2502            0x5b35aab9baffecae,
2503            fidl::encoding::DynamicFlags::empty(),
2504        )
2505    }
2506
2507    /// Releases a Viewport from the scene, even if the Viewport is still connected to a Transform.
2508    /// Unlike other resources, Viewports are garbage collected by the system during the next
2509    /// [`Present`] because a removed Viewport is guaranteed to provide no renderable content.
2510    ///
2511    /// Use SetContent(transform_id, 0) to clean up references to released Viewports.
2512    ///
2513    /// Despite having a return type, this function is still feed-forward like [`CreateView`] and
2514    /// requires a call to [`Present`] to be executed. The ViewportCreationToken will be returned
2515    /// after the presented operations have been executed.
2516    pub fn r#release_viewport(
2517        &self,
2518        mut viewport_id: &ContentId,
2519        ___deadline: zx::MonotonicInstant,
2520    ) -> Result<fidl_fuchsia_ui_views::ViewportCreationToken, fidl::Error> {
2521        let _response = self
2522            .client
2523            .send_query::<FlatlandReleaseViewportRequest, FlatlandReleaseViewportResponse>(
2524                (viewport_id,),
2525                0xbad474aeb5293f9,
2526                fidl::encoding::DynamicFlags::empty(),
2527                ___deadline,
2528            )?;
2529        Ok(_response.token)
2530    }
2531
2532    /// Released Images will be garbage collected by the system once they are no longer necessary
2533    /// for rendering. For Images, this means the Image is no longer attached to any Transform and
2534    /// any pending rendering that references the Image is complete.
2535    ///
2536    /// Use SetContent(transform_id, 0) to clean up references to released Images.
2537    ///
2538    /// Once released, the id immediately goes out of scope for future function calls and can be
2539    /// reused when creating new Images.
2540    ///
2541    /// It is an error to call functions with a released id (unless that id has been reused to
2542    /// construct a new Image).
2543    pub fn r#release_image(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
2544        self.client.send::<FlatlandReleaseImageRequest>(
2545            (image_id,),
2546            0xb884ffdbc72c111,
2547            fidl::encoding::DynamicFlags::empty(),
2548        )
2549    }
2550
2551    /// This function will reset all state on this interface. This includes destroying all existing
2552    /// View and Viewports without returning the associated Token to the caller.
2553    pub fn r#clear(&self) -> Result<(), fidl::Error> {
2554        self.client.send::<fidl::encoding::EmptyPayload>(
2555            (),
2556            0x4ec8817c02828c3e,
2557            fidl::encoding::DynamicFlags::empty(),
2558        )
2559    }
2560
2561    /// Set debug name of the current client that can be used by Flatland to print as a prefix to
2562    /// logs to help client distinguish what is theirs. [`name`] can be an arbitrary string, but the
2563    /// current process name (see fsl::GetCurrentProcessName()) is a good default.
2564    pub fn r#set_debug_name(&self, mut name: &str) -> Result<(), fidl::Error> {
2565        self.client.send::<FlatlandSetDebugNameRequest>(
2566            (name,),
2567            0x46a8b397e68a8888,
2568            fidl::encoding::DynamicFlags::empty(),
2569        )
2570    }
2571}
2572
2573#[cfg(target_os = "fuchsia")]
2574impl From<FlatlandSynchronousProxy> for zx::NullableHandle {
2575    fn from(value: FlatlandSynchronousProxy) -> Self {
2576        value.into_channel().into()
2577    }
2578}
2579
2580#[cfg(target_os = "fuchsia")]
2581impl From<fidl::Channel> for FlatlandSynchronousProxy {
2582    fn from(value: fidl::Channel) -> Self {
2583        Self::new(value)
2584    }
2585}
2586
2587#[cfg(target_os = "fuchsia")]
2588impl fidl::endpoints::FromClient for FlatlandSynchronousProxy {
2589    type Protocol = FlatlandMarker;
2590
2591    fn from_client(value: fidl::endpoints::ClientEnd<FlatlandMarker>) -> Self {
2592        Self::new(value.into_channel())
2593    }
2594}
2595
2596#[derive(Debug, Clone)]
2597pub struct FlatlandProxy {
2598    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2599}
2600
2601impl fidl::endpoints::Proxy for FlatlandProxy {
2602    type Protocol = FlatlandMarker;
2603
2604    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2605        Self::new(inner)
2606    }
2607
2608    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2609        self.client.into_channel().map_err(|client| Self { client })
2610    }
2611
2612    fn as_channel(&self) -> &::fidl::AsyncChannel {
2613        self.client.as_channel()
2614    }
2615}
2616
2617impl FlatlandProxy {
2618    /// Create a new Proxy for fuchsia.ui.composition/Flatland.
2619    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2620        let protocol_name = <FlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2621        Self { client: fidl::client::Client::new(channel, protocol_name) }
2622    }
2623
2624    /// Get a Stream of events from the remote end of the protocol.
2625    ///
2626    /// # Panics
2627    ///
2628    /// Panics if the event stream was already taken.
2629    pub fn take_event_stream(&self) -> FlatlandEventStream {
2630        FlatlandEventStream { event_receiver: self.client.take_event_receiver() }
2631    }
2632
2633    /// Releases an image immediately, without waiting for the next present.
2634    pub fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
2635        FlatlandProxyInterface::r#release_image_immediately(self, image_id)
2636    }
2637
2638    /// Complete execution of all feed-forward operations.
2639    ///
2640    /// If executing an operation produces an error (e.g., CreateTransform(0)), an [`OnError`] event
2641    /// is emitted. Operations that produce errors are ignored and the channel is closed.
2642    ///
2643    /// If the execution is completed successfully, [`OnNextFrameBegin`] emits NO_ERROR along
2644    /// with other valid fields.
2645    ///
2646    /// The client may only call [`Present`] when they have a non-zero number of present credits,
2647    /// which are tracked by the server. The server may increment the number of credits when it
2648    /// fires the [`OnNextFrameBegin`] event, which informs the client when it receives additional
2649    /// present credits. Each [`Present`] call uses one present credit and decrements the server
2650    /// count by one. If the client calls [`Present`] with no present credits, the server will
2651    /// return a `NO_PRESENTS_REMAINING` error.
2652    ///
2653    /// The client should assume that prior to receiving any [`OnNextFrameBegin`] events, they have
2654    /// one present credit.
2655    ///
2656    /// Every [`Present`] call results in one [`OnNextFrameBegin`] event, and one
2657    /// [`OnFramePresented`] event, typically in that order.
2658    ///
2659    /// When the commands flushed by [`Present`] make it to display, an [`OnFramePresented`] event
2660    /// is fired. This event includes information pertaining to all [`Present`]s that had content
2661    /// that were part of that frame.
2662    ///
2663    /// See [`fuchsia.ui.composition/PresentArgs`] documentation above for more detailed information
2664    /// on what arguments are passed in and their role.
2665    pub fn r#present(&self, mut args: PresentArgs) -> Result<(), fidl::Error> {
2666        FlatlandProxyInterface::r#present(self, args)
2667    }
2668
2669    /// Two Flatland instances may be connected in a parent-child relationship. The parent endpoint
2670    /// is held in a Viewport, and the child endpoint is held in a View. The parent Flatland
2671    /// instance that creates a Viewport has control over how the child's View is integrated into
2672    /// its own View.
2673    ///
2674    /// The lifecycle of a parent-child connection starts with two endpoints of a channel object:
2675    /// a ViewportCreationToken and a ViewCreationToken. Out-of-band protocols pass the
2676    /// ViewportCreationToken to the parent, which calls [`CreateViewport`], and the
2677    /// ViewCreationToken to the child, which calls [`CreateView`].
2678    ///
2679    /// Only nodes connected to the Root Transform in this Flatland instance will be rendered into
2680    /// the parent's Viewport.
2681    ///
2682    /// Calling [`CreateView`] a second time will disconnect the Root Transform from the existing
2683    /// parent's Viewport, and attach it to a new parent's Viewport. In other words, each View can
2684    /// only have one parent.
2685    ///
2686    /// This function is queued, meaning that the Root Transform will not be attached to the
2687    /// parent Viewport until [`Present`] is called. However, clients will receive information
2688    /// through their ParentViewportWatcher (e.g., LayoutInfo) immediately after calling this
2689    /// function, even if they have not called [`Present`] or [`SetRootTransform`]. This allows
2690    /// clients to wait for layout information from their parent before calling [`Present`].
2691    ///
2692    /// Any illegal operations on ParentViewportWatcher will cause both ParentViewportWatcher
2693    /// channel and this Flatland channel to be torn down.
2694    ///
2695    /// Lifecycle note. The lifetime of the ParentViewportWatcher channel is bound by the peer
2696    /// ViewportCreationToken. When the ViewportCreationToken dies, this ParentViewportWatcher
2697    /// channel is destroyed.
2698    ///
2699    /// Views and subgraphs of Views created using `CreateView` will not be represented in the
2700    /// ViewTree, and hence will not be able to participate in any ViewTree-dependent interactions
2701    /// such as touch, mouse or focus.
2702    /// The Flatland protocol provides no way for Views in the subgraph of a View created with
2703    /// `CreateView` to know that they are excluded from the ViewTree.
2704    pub fn r#create_view(
2705        &self,
2706        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
2707        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
2708    ) -> Result<(), fidl::Error> {
2709        FlatlandProxyInterface::r#create_view(self, token, parent_viewport_watcher)
2710    }
2711
2712    /// Identical to [`CreateView`], except it allows association of View identity (ViewRef) and
2713    /// view-bound protocols.
2714    pub fn r#create_view2(
2715        &self,
2716        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
2717        mut view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
2718        mut protocols: ViewBoundProtocols,
2719        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
2720    ) -> Result<(), fidl::Error> {
2721        FlatlandProxyInterface::r#create_view2(
2722            self,
2723            token,
2724            view_identity,
2725            protocols,
2726            parent_viewport_watcher,
2727        )
2728    }
2729
2730    /// Creates a new Transform node. Transforms are a hierarchical piece of a Flatland graph. They
2731    /// can have children, and can reference Content. A sub-graph represented by a Transform and its
2732    /// descendants can be rendered to a display.
2733    ///
2734    /// Transforms are kept alive, even when released, as long as they are children of either an
2735    /// unreleased Transform, or the Root Transform.
2736    ///
2737    /// Each Transform can have a single piece of attached Content. Common types of Content include
2738    /// bitmaps, asynchronous streams of images, and Viewports to Views hosted in other Flatland
2739    /// instances.
2740    ///
2741    /// Transforms have attributes. Child Transforms inherit the combined attributes of their
2742    /// parents. Content attached to a Transform is also affected by that Transform's attributes.
2743    ///
2744    /// When a sub-graph of Transforms is rendered, Content will be rendered back-to-front, starting
2745    /// with the Content on the root transform, and continuing recursively through all of its child
2746    /// Transforms in the order the children were added. See [`AddChild`] for more information.
2747    ///
2748    /// Zero is not a valid transform id. All other values are valid, assuming they are not already
2749    /// in use (see [`ReleaseTransform`] for more details).
2750    pub fn r#create_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2751        FlatlandProxyInterface::r#create_transform(self, transform_id)
2752    }
2753
2754    /// All Transform objects support all attributes.
2755    ///
2756    /// Geometric attributes are applied in the following order:
2757    /// 1. Scale (relative to the parent transform's coordinate space)
2758    /// 2. Orientation (relative to the parent transform's coordinate space)
2759    /// 3. Translation (relative to the parent transforms's coordinate space,
2760    ///    unaffected by scale applied to the current transform).
2761    /// 4. Clipping (relative to the current transform's coordinate space)
2762    ///
2763    /// The effects of each of these attributes are cumulative. This means the transform's position
2764    /// in the view space, and its clip boundary, will be calculated based on that chain of
2765    /// geometric attributes going up to the root transform.
2766    ///
2767    /// For instance, in a nested hierarchy such as the following:
2768    ///     [Root-Transform -> Transform1 -> Transform2 -> CurrentTransform]
2769    /// If Transform1 is translated by [2,0] and Transform2 is translated by [0,1] then the
2770    /// view-space position of CurrentTransform will be [2,1].
2771    ///
2772    /// Sets the translation on a Transform. The order of geometric attribute application is
2773    /// addressed above.
2774    pub fn r#set_translation(
2775        &self,
2776        mut transform_id: &TransformId,
2777        mut translation: &fidl_fuchsia_math::Vec_,
2778    ) -> Result<(), fidl::Error> {
2779        FlatlandProxyInterface::r#set_translation(self, transform_id, translation)
2780    }
2781
2782    /// Sets the orientation on a Transform. The order of geometric attribute application is
2783    /// addressed in the documentation for [`SetTranslation`]. In Flatland, the +X axis is
2784    /// to the right and the +Y axis is down. There is no notion of a Z axis. CCW is defined
2785    /// from the POV of the user, as if a skeuomorphoic clock is displayed on the screen.
2786    pub fn r#set_orientation(
2787        &self,
2788        mut transform_id: &TransformId,
2789        mut orientation: Orientation,
2790    ) -> Result<(), fidl::Error> {
2791        FlatlandProxyInterface::r#set_orientation(self, transform_id, orientation)
2792    }
2793
2794    /// Sets the scale on a transform. The order of geometric attribute application is
2795    /// addressed above. The (x,y) values in the VecF |scale| refer to the scale factor in the
2796    /// x-axis (width) and y-axis (height) respectively. Scale values must be normal 32-bit
2797    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29
2798    pub fn r#set_scale(
2799        &self,
2800        mut transform_id: &TransformId,
2801        mut scale: &fidl_fuchsia_math::VecF,
2802    ) -> Result<(), fidl::Error> {
2803        FlatlandProxyInterface::r#set_scale(self, transform_id, scale)
2804    }
2805
2806    /// Sets an opacity in linear space to be applied to a transform and its descendents,
2807    /// which include other transforms and content. Opacity values must be in the range
2808    /// of [0.0, 1.0], where 0.0 is completely transparent and 1.0 is completely opaque.
2809    /// Attempting to call this function with values outside that range will result in
2810    /// an error. A transform's opacity value is multiplied with that of its parent. This
2811    /// effect works differently from group opacity. Using group opacity, child nodes are
2812    /// rendered together first, and then have the parent's opacity applied as a post-effect.
2813    /// Here, opacity is applied to each child individually. This may result in a very
2814    /// different effect.
2815    pub fn r#set_opacity(
2816        &self,
2817        mut transform_id: &TransformId,
2818        mut value: f32,
2819    ) -> Result<(), fidl::Error> {
2820        FlatlandProxyInterface::r#set_opacity(self, transform_id, value)
2821    }
2822
2823    /// Sets the bounds, expressed in the local coordinate space of the transform, that
2824    /// constrains the region that content attached to this transform can be rendered to.
2825    /// If the content's area exceeds the clip bounds, the area outside the bounds will
2826    /// not be rendered. These bounds are valid for all children of this transform node as
2827    /// well, which includes nested Flatland instances and their node hierarchies.
2828    /// If a child transform attempts to set clip bounds larger than that of its parent,
2829    /// it will be clipped to the parent's clip bounds. The default state is for a transform
2830    /// to be unclipped, meaning it will not have any bounds placed on its render region.
2831    /// The clip width/height must be positive. Negative values will result in an error.
2832    /// Passing in an empty box to the |rect| parameter will remove the clip bounds.
2833    pub fn r#set_clip_boundary(
2834        &self,
2835        mut transform_id: &TransformId,
2836        mut rect: Option<&fidl_fuchsia_math::Rect>,
2837    ) -> Result<(), fidl::Error> {
2838        FlatlandProxyInterface::r#set_clip_boundary(self, transform_id, rect)
2839    }
2840
2841    /// Adds a child Transform to a parent Transform. The new child Transform,
2842    /// and any Content attached to it or its children, will be rendered on top
2843    /// of the parent's Content, as well as any previously added children.
2844    ///
2845    /// The caller must ensure that `child_transform_id` is valid and that there
2846    /// are no repetitions.  Sending a repeated `child_transform_id` over
2847    /// multiple calls will result in session closure.
2848    pub fn r#add_child(
2849        &self,
2850        mut parent_transform_id: &TransformId,
2851        mut child_transform_id: &TransformId,
2852    ) -> Result<(), fidl::Error> {
2853        FlatlandProxyInterface::r#add_child(self, parent_transform_id, child_transform_id)
2854    }
2855
2856    /// Removes a child Transform from a parent Transform.
2857    pub fn r#remove_child(
2858        &self,
2859        mut parent_transform_id: &TransformId,
2860        mut child_transform_id: &TransformId,
2861    ) -> Result<(), fidl::Error> {
2862        FlatlandProxyInterface::r#remove_child(self, parent_transform_id, child_transform_id)
2863    }
2864
2865    /// Removes all child Transforms from a parent Transform and replaces them
2866    /// with the new child transforms in `new_child_transform_ids`.  The caller
2867    /// must ensure that all `TransformId` values in `new_child_transform_ids`
2868    /// are valid and that there are no repetitions.  Sending a repeated
2869    /// `TransformId` in `new_child_transform_ids` will result in session
2870    /// closure.
2871    pub fn r#replace_children(
2872        &self,
2873        mut parent_transform_id: &TransformId,
2874        mut new_child_transform_ids: &[TransformId],
2875    ) -> Result<(), fidl::Error> {
2876        FlatlandProxyInterface::r#replace_children(
2877            self,
2878            parent_transform_id,
2879            new_child_transform_ids,
2880        )
2881    }
2882
2883    /// Sets the Root Transform for the graph.
2884    ///
2885    /// The sub-graph defined by the Root Transform and its children will be rendered as View
2886    /// in the connected parent's Viewport (see [`CreateView`]). Any parents of the Root Transform
2887    /// in this Graph will be ignored.
2888    ///
2889    /// The Root Transform, and all children of the Root Transform, are kept alive if they are
2890    /// released (see [`ReleaseTransform`] for more details).
2891    ///
2892    /// There is only ever one Root. Since 0 is not a valid transform id (see [`CreateTransform`]),
2893    /// calling SetRootTransform(0) clears the current Root, destroying any previously released
2894    /// objects that are not referenced by the new root.
2895    ///
2896    /// Note that every View has a clip boundary equivalent to its logical size. Anything outside
2897    /// that clip boundary will not be rendered. Hence, the Root Transform has a useful coordinate
2898    /// space of (0, 0) to (logical_size.width, logical_size.height), where (0, 0) is the upper left
2899    /// corner.
2900    ///
2901    /// Setting the root transform installs a full screen hit region on the root transform. Clients
2902    /// may remove this hit region if they don't want users to be able to interact with the root
2903    /// transform's content. For additional details on hit regions, see the [`SetHitRegions`]
2904    /// documentation.
2905    ///
2906    /// Default hit region rules
2907    ///
2908    ///   A default hit region follows these rules:
2909    ///   - When [`SetRootTransform`](T) is called, T receives a maximal hit region, covering the
2910    ///   entire view.
2911    ///   - If [`SetHitRegions`] is called on T, either before or after [`SetRootTransform`](T),
2912    ///   then no default hit region is active and the client specified hit regions are used.
2913    ///   - If a transform is no longer the root transform, i.e., [`SetRootTransform`](U) is
2914    ///   called, then the original transform no longer has its default hit region.
2915    ///   - Clients can remove or modify the root transform's hit regions the same way they would
2916    ///   reset any other transform's hit regions, by calling [`SetHitRegions`] with the appropriate
2917    ///   vector.
2918    pub fn r#set_root_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2919        FlatlandProxyInterface::r#set_root_transform(self, transform_id)
2920    }
2921
2922    /// Sets the interactive areas for a Transform. By default, Content is not interactive; hit
2923    /// regions must be placed for a user to interact with the Content in a View. Because hit
2924    /// regions are described in the Flatland protocol, a Flatland instance can synchronize Content
2925    /// and hit regions.
2926    ///
2927    /// Each hit region is placed in the coordinate space of the owning Transform, and may or may
2928    /// not interact with different types of hit testing, depending on its [`HitTestInteraction`]
2929    /// type. When there are multiple hit regions that intersect with a hit test, the precedence
2930    /// rules given below dictate which hit region has interacted with the hit test. Only Transforms
2931    /// that transitively connect to the root Transform have their hit regions interact with a hit
2932    /// test.
2933    ///
2934    /// Calling this function replaces any previous values set on this Transform. To reset a
2935    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2936    ///
2937    /// Note that root transforms get a default hit region installed by Flatland. For more details,
2938    /// see the [`SetRootTransform`] documentation.
2939    ///
2940    /// Precedence rules
2941    ///   Within a Transform, if multiple hit regions overlap, the hit test examines each
2942    ///   intersecting hit region for a possible interaction. Thus, for a regular hit test R and an
2943    ///   accessibility hit test A, where R and A both intersect two hit regions D ([`DEFAULT`]) and
2944    ///   S ([`SEMANTICALLY_INVISIBLE`]) on the same Transform, (1) R interacts with both D and S,
2945    ///   and (2) A only interacts with D. Generally, hit regions that overlap in a single Transform
2946    ///   can cause confusing behavior.
2947    ///
2948    ///   Within a View, for a given hit test, the front-most Transform's hit regions take
2949    ///   precedence over those behind. This follows the expected reverse "render order" of
2950    ///   Transforms (described in [`CreateTransform`]), where a user expects to interact with
2951    ///   Content that is visible, or front-most.
2952    ///
2953    ///   Across Flatland instances, for a given hit test, the front-most instance's front-most
2954    ///   Transform's hit regions take precedence over those behind. This follows the expected
2955    ///   reverse "render order" of views, where a user expects to interact with the View that is
2956    ///   visible, or front-most. For example, if a child View owns Content that is rendered over
2957    ///   the parent View, the user expects to interact with the child's Content.
2958    pub fn r#set_hit_regions(
2959        &self,
2960        mut transform_id: &TransformId,
2961        mut regions: &[HitRegion],
2962    ) -> Result<(), fidl::Error> {
2963        FlatlandProxyInterface::r#set_hit_regions(self, transform_id, regions)
2964    }
2965
2966    /// Identical to [`SetHitRegions`], except the hit region associated with [`transform_id`]
2967    /// covers an infinite region. The hit region is invariant against translation, scaling, and
2968    /// orientation of the Transform.
2969    ///
2970    /// An infinite hit region is still limited in extent by the View's clip boundary, just like a
2971    /// finite hit region.
2972    ///
2973    /// Calling this function replaces any previous values set on this Transform. To reset a
2974    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2975    pub fn r#set_infinite_hit_region(
2976        &self,
2977        mut transform_id: &TransformId,
2978        mut hit_test: HitTestInteraction,
2979    ) -> Result<(), fidl::Error> {
2980        FlatlandProxyInterface::r#set_infinite_hit_region(self, transform_id, hit_test)
2981    }
2982
2983    /// The Viewport and View pair, together, represent the connection between two Flatland
2984    /// instances. The Viewport is created in the parent, and the View is created in the child. The
2985    /// parent has control over how the child's View is integrated into its own View.
2986    ///
2987    /// Any illegal operations on ChildViewWatcher will cause both ChildViewWatcher channel and this
2988    /// Flatland channel to be torn down.
2989    ///
2990    /// `ViewportProperties` must have logical_size set. This is the initial size that will drive
2991    /// the layout of the child. The logical_size is also used as the default Content size, but
2992    /// subsequent changes to the logical_size will have no effect on the Content size.
2993    ///
2994    /// `ViewportProperties` may have inset field not set. In that case, the default value of
2995    /// (0, 0, 0, 0) is used.
2996    ///
2997    /// The logical_size must have positive X and Y components.
2998    ///
2999    /// Zero is not a valid ContentId. All other values are valid, assuming they are not already
3000    /// in use for another piece of Content (see [`ReleaseViewport`] for more details).
3001    ///
3002    /// Lifecycle note. The lifetime of the ChildViewWatcher channel is bound by the peer
3003    /// ViewCreationToken. When the ViewCreationToken dies, this ChildViewWatcher channel is
3004    /// destroyed.
3005    pub fn r#create_viewport(
3006        &self,
3007        mut viewport_id: &ContentId,
3008        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
3009        mut properties: &ViewportProperties,
3010        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
3011    ) -> Result<(), fidl::Error> {
3012        FlatlandProxyInterface::r#create_viewport(
3013            self,
3014            viewport_id,
3015            token,
3016            properties,
3017            child_view_watcher,
3018        )
3019    }
3020
3021    /// An Image is a bitmap backed by a specific VMO in a BufferCollection.
3022    ///
3023    /// Image creation requires an allocated BufferCollection registered with Allocator. This
3024    /// function will fail unless all clients of the specified BufferCollection have set their
3025    /// constraints.
3026    ///
3027    /// The Image must reference a valid VMO index and must have ImageProperties that fall within
3028    /// the constraints specified by the backing BufferCollection (i.e. width and height within a
3029    /// valid range, etc.)
3030    ///
3031    /// Zero is not a valid Image id. All other values are valid, assuming they are not already in
3032    /// use for another piece of Content (see [`ReleaseImage`] for more details).
3033    pub fn r#create_image(
3034        &self,
3035        mut image_id: &ContentId,
3036        mut import_token: BufferCollectionImportToken,
3037        mut vmo_index: u32,
3038        mut properties: &ImageProperties,
3039    ) -> Result<(), fidl::Error> {
3040        FlatlandProxyInterface::r#create_image(self, image_id, import_token, vmo_index, properties)
3041    }
3042
3043    /// This function is used to determine the region (in texel space) of an image that will be used
3044    /// by Flatland when rendering. The image to be sampled is referenced by [`image_id`] and the
3045    /// sample region is specified by [`rect`] which itself is comprised of an origin point (x,y) as
3046    /// well as a width and height, in unnormalized coordinates. It is illegal to call this function
3047    /// on non-image content, or to sample a region outside of the texel space of the image. In
3048    /// other words, the region specifed by [`rect`] must not exceed the ranges (0, image_width) and
3049    /// (0, image_height). If (rect.x + rect.width > image_width) or (rect.y + rect.height >
3050    /// image_height) or if any of the values are negative, this will result in an error.
3051    ///
3052    /// If this method is not called, the default sample region is the rectangle with origin at
3053    /// (0, 0) and width and height set at ImageProperties from [`CreateImage`].
3054    pub fn r#set_image_sample_region(
3055        &self,
3056        mut image_id: &ContentId,
3057        mut rect: &fidl_fuchsia_math::RectF,
3058    ) -> Result<(), fidl::Error> {
3059        FlatlandProxyInterface::r#set_image_sample_region(self, image_id, rect)
3060    }
3061
3062    /// The content size for an Image is the size of the rectangle in the parent's logical
3063    /// coordinate space that the image occupies. This combined with the global translation of the
3064    /// transform it is attached to determines the size and location of where the content is
3065    /// rendered on the display.
3066    ///
3067    /// If this method is not called, the default image destination size is the width and height set
3068    /// at ImageProperties from [`CreateImage`]. The destination size will be affected by scaling if
3069    /// [`SetScale`] is used on the attached Transform or its parents.
3070    pub fn r#set_image_destination_size(
3071        &self,
3072        mut image_id: &ContentId,
3073        mut size: &fidl_fuchsia_math::SizeU,
3074    ) -> Result<(), fidl::Error> {
3075        FlatlandProxyInterface::r#set_image_destination_size(self, image_id, size)
3076    }
3077
3078    /// Determines the blend function to use when rendering the content specified by
3079    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
3080    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
3081    /// that are available, please refer to the BlendMode enum. If this function is not called, then
3082    /// the default blendmode is BlendMode::SRC.
3083    pub fn r#set_image_blending_function(
3084        &self,
3085        mut image_id: &ContentId,
3086        mut blend_mode: BlendMode,
3087    ) -> Result<(), fidl::Error> {
3088        FlatlandProxyInterface::r#set_image_blending_function(self, image_id, blend_mode)
3089    }
3090
3091    /// Determines the blend function to use when rendering the content specified by
3092    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
3093    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
3094    /// that are available, please refer to the BlendMode2 enum. If this function is not called,
3095    /// the default blendmode is BlendMode2::REPLACE.
3096    pub fn r#set_image_blend_mode(
3097        &self,
3098        mut image_id: &ContentId,
3099        mut blend_mode: BlendMode2,
3100    ) -> Result<(), fidl::Error> {
3101        FlatlandProxyInterface::r#set_image_blend_mode(self, image_id, blend_mode)
3102    }
3103
3104    /// Sets an opacity in linear space to be applied to a flatland image. Opacity values must
3105    /// be in the range [0.0, 1.0].
3106    pub fn r#set_image_opacity(
3107        &self,
3108        mut image_id: &ContentId,
3109        mut val: f32,
3110    ) -> Result<(), fidl::Error> {
3111        FlatlandProxyInterface::r#set_image_opacity(self, image_id, val)
3112    }
3113
3114    /// Sets the image flip to be applied to a flatland image. This call must be performed after a
3115    /// successful |CreateImage| call. If an invalid |image_id| is supplied, the channel will be
3116    /// closed due to FlatlandError::BAD_OPERATION. This flip will be applied to the Image before
3117    /// parent Transform Orientations. If this function is not called, then the default flip value
3118    /// is ImageFlip::NONE.
3119    pub fn r#set_image_flip(
3120        &self,
3121        mut image_id: &ContentId,
3122        mut flip: ImageFlip,
3123    ) -> Result<(), fidl::Error> {
3124        FlatlandProxyInterface::r#set_image_flip(self, image_id, flip)
3125    }
3126
3127    /// Creates a solid-color rectangle. By default a filled-rect does not have a defined
3128    /// color or size. It is necessary to call |SetSolidFill| to specify a color and size
3129    /// before a filled rect can be used for rendering. Not doing so will result the
3130    pub fn r#create_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3131        FlatlandProxyInterface::r#create_filled_rect(self, rect_id)
3132    }
3133
3134    /// Defines the color and size of a filled rect. |rect_id| must refer to content that
3135    /// was created via a call to CreateFilledRect. The color is not premultiplied. Color values
3136    /// must be within the range [0,1] inclusive, and normal 32-bit
3137    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29. Values
3138    /// that do not conform to these specifications will cause the channel to close.
3139    /// The rectangle's top left corner will be at (0, 0) in its transform's coordinate space.
3140    /// Hence, its bottom right corner will be at (size.width, size.height).
3141    pub fn r#set_solid_fill(
3142        &self,
3143        mut rect_id: &ContentId,
3144        mut color: &ColorRgba,
3145        mut size: &fidl_fuchsia_math::SizeU,
3146    ) -> Result<(), fidl::Error> {
3147        FlatlandProxyInterface::r#set_solid_fill(self, rect_id, color, size)
3148    }
3149
3150    /// Automatically garbage collects the rectangle when it is no longer needed for
3151    /// rendering. |rect_id| must have been instantiated with a call to
3152    /// |CreateFilledRect|. Once released, the ID immediately goes out of scope and is free
3153    /// to be used again.
3154    pub fn r#release_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3155        FlatlandProxyInterface::r#release_filled_rect(self, rect_id)
3156    }
3157
3158    /// Setting a piece of Content on a Transform makes that Content visible in the render tree as
3159    /// long as the Transform is visible from the root Transform. The Content will be rendered
3160    /// before, and therefore "behind", any Content attached to the descendants of the Transform.
3161    ///
3162    /// Because each Transform can have, at most, a single piece of Content on it, calling this
3163    /// function on a Transform that already has Content will replace that Content.
3164    ///
3165    /// A Content may be set on more than one Transform.
3166    ///
3167    /// Calling this function with a Content id of 0 will remove any Content currently on the
3168    /// Transform.
3169    pub fn r#set_content(
3170        &self,
3171        mut transform_id: &TransformId,
3172        mut content_id: &ContentId,
3173    ) -> Result<(), fidl::Error> {
3174        FlatlandProxyInterface::r#set_content(self, transform_id, content_id)
3175    }
3176
3177    /// Transforms are usually sufficient to change how Content is presented. Viewports, however,
3178    /// have special properties that are not part of the Transform hierarchy. Those properties can
3179    /// be set using this function.
3180    pub fn r#set_viewport_properties(
3181        &self,
3182        mut viewport_id: &ContentId,
3183        mut properties: &ViewportProperties,
3184    ) -> Result<(), fidl::Error> {
3185        FlatlandProxyInterface::r#set_viewport_properties(self, viewport_id, properties)
3186    }
3187
3188    /// Released Transforms will be garbage collected by the system once they are no longer
3189    /// necessary for rendering. For Transforms, this means there is no path from any unreleased
3190    /// Transform to the newly-released Transform.
3191    ///
3192    /// Once released, the id immediately goes out of scope for future function calls and can be
3193    /// reused when creating new Transforms.
3194    ///
3195    /// It is an error to call functions with a released id (unless that id has been reused to
3196    /// construct a new Transform).
3197    pub fn r#release_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3198        FlatlandProxyInterface::r#release_transform(self, transform_id)
3199    }
3200
3201    pub fn r#release_view(&self) -> Result<(), fidl::Error> {
3202        FlatlandProxyInterface::r#release_view(self)
3203    }
3204
3205    /// Releases a Viewport from the scene, even if the Viewport is still connected to a Transform.
3206    /// Unlike other resources, Viewports are garbage collected by the system during the next
3207    /// [`Present`] because a removed Viewport is guaranteed to provide no renderable content.
3208    ///
3209    /// Use SetContent(transform_id, 0) to clean up references to released Viewports.
3210    ///
3211    /// Despite having a return type, this function is still feed-forward like [`CreateView`] and
3212    /// requires a call to [`Present`] to be executed. The ViewportCreationToken will be returned
3213    /// after the presented operations have been executed.
3214    pub fn r#release_viewport(
3215        &self,
3216        mut viewport_id: &ContentId,
3217    ) -> fidl::client::QueryResponseFut<
3218        fidl_fuchsia_ui_views::ViewportCreationToken,
3219        fidl::encoding::DefaultFuchsiaResourceDialect,
3220    > {
3221        FlatlandProxyInterface::r#release_viewport(self, viewport_id)
3222    }
3223
3224    /// Released Images will be garbage collected by the system once they are no longer necessary
3225    /// for rendering. For Images, this means the Image is no longer attached to any Transform and
3226    /// any pending rendering that references the Image is complete.
3227    ///
3228    /// Use SetContent(transform_id, 0) to clean up references to released Images.
3229    ///
3230    /// Once released, the id immediately goes out of scope for future function calls and can be
3231    /// reused when creating new Images.
3232    ///
3233    /// It is an error to call functions with a released id (unless that id has been reused to
3234    /// construct a new Image).
3235    pub fn r#release_image(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
3236        FlatlandProxyInterface::r#release_image(self, image_id)
3237    }
3238
3239    /// This function will reset all state on this interface. This includes destroying all existing
3240    /// View and Viewports without returning the associated Token to the caller.
3241    pub fn r#clear(&self) -> Result<(), fidl::Error> {
3242        FlatlandProxyInterface::r#clear(self)
3243    }
3244
3245    /// Set debug name of the current client that can be used by Flatland to print as a prefix to
3246    /// logs to help client distinguish what is theirs. [`name`] can be an arbitrary string, but the
3247    /// current process name (see fsl::GetCurrentProcessName()) is a good default.
3248    pub fn r#set_debug_name(&self, mut name: &str) -> Result<(), fidl::Error> {
3249        FlatlandProxyInterface::r#set_debug_name(self, name)
3250    }
3251}
3252
3253impl FlatlandProxyInterface for FlatlandProxy {
3254    fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
3255        self.client.send::<TrustedFlatlandReleaseImageImmediatelyRequest>(
3256            (image_id,),
3257            0x245e1ac080772c8,
3258            fidl::encoding::DynamicFlags::empty(),
3259        )
3260    }
3261
3262    fn r#present(&self, mut args: PresentArgs) -> Result<(), fidl::Error> {
3263        self.client.send::<FlatlandPresentRequest>(
3264            (&mut args,),
3265            0x50acc2aa1f0acec7,
3266            fidl::encoding::DynamicFlags::empty(),
3267        )
3268    }
3269
3270    fn r#create_view(
3271        &self,
3272        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
3273        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
3274    ) -> Result<(), fidl::Error> {
3275        self.client.send::<FlatlandCreateViewRequest>(
3276            (&mut token, parent_viewport_watcher),
3277            0x504686eb25864780,
3278            fidl::encoding::DynamicFlags::empty(),
3279        )
3280    }
3281
3282    fn r#create_view2(
3283        &self,
3284        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
3285        mut view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
3286        mut protocols: ViewBoundProtocols,
3287        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
3288    ) -> Result<(), fidl::Error> {
3289        self.client.send::<FlatlandCreateView2Request>(
3290            (&mut token, &mut view_identity, &mut protocols, parent_viewport_watcher),
3291            0x340a3a40c2fdbd5e,
3292            fidl::encoding::DynamicFlags::empty(),
3293        )
3294    }
3295
3296    fn r#create_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3297        self.client.send::<FlatlandCreateTransformRequest>(
3298            (transform_id,),
3299            0x5e042a4d3de3efb0,
3300            fidl::encoding::DynamicFlags::empty(),
3301        )
3302    }
3303
3304    fn r#set_translation(
3305        &self,
3306        mut transform_id: &TransformId,
3307        mut translation: &fidl_fuchsia_math::Vec_,
3308    ) -> Result<(), fidl::Error> {
3309        self.client.send::<FlatlandSetTranslationRequest>(
3310            (transform_id, translation),
3311            0x7863398291fba346,
3312            fidl::encoding::DynamicFlags::empty(),
3313        )
3314    }
3315
3316    fn r#set_orientation(
3317        &self,
3318        mut transform_id: &TransformId,
3319        mut orientation: Orientation,
3320    ) -> Result<(), fidl::Error> {
3321        self.client.send::<FlatlandSetOrientationRequest>(
3322            (transform_id, orientation),
3323            0x4915310bc4928edc,
3324            fidl::encoding::DynamicFlags::empty(),
3325        )
3326    }
3327
3328    fn r#set_scale(
3329        &self,
3330        mut transform_id: &TransformId,
3331        mut scale: &fidl_fuchsia_math::VecF,
3332    ) -> Result<(), fidl::Error> {
3333        self.client.send::<FlatlandSetScaleRequest>(
3334            (transform_id, scale),
3335            0x1ea1766fd8996bb4,
3336            fidl::encoding::DynamicFlags::empty(),
3337        )
3338    }
3339
3340    fn r#set_opacity(
3341        &self,
3342        mut transform_id: &TransformId,
3343        mut value: f32,
3344    ) -> Result<(), fidl::Error> {
3345        self.client.send::<FlatlandSetOpacityRequest>(
3346            (transform_id, value),
3347            0x3775fc2c00b432fa,
3348            fidl::encoding::DynamicFlags::empty(),
3349        )
3350    }
3351
3352    fn r#set_clip_boundary(
3353        &self,
3354        mut transform_id: &TransformId,
3355        mut rect: Option<&fidl_fuchsia_math::Rect>,
3356    ) -> Result<(), fidl::Error> {
3357        self.client.send::<FlatlandSetClipBoundaryRequest>(
3358            (transform_id, rect),
3359            0x6507843df12222d2,
3360            fidl::encoding::DynamicFlags::empty(),
3361        )
3362    }
3363
3364    fn r#add_child(
3365        &self,
3366        mut parent_transform_id: &TransformId,
3367        mut child_transform_id: &TransformId,
3368    ) -> Result<(), fidl::Error> {
3369        self.client.send::<FlatlandAddChildRequest>(
3370            (parent_transform_id, child_transform_id),
3371            0x67a8abd2f19b1a74,
3372            fidl::encoding::DynamicFlags::empty(),
3373        )
3374    }
3375
3376    fn r#remove_child(
3377        &self,
3378        mut parent_transform_id: &TransformId,
3379        mut child_transform_id: &TransformId,
3380    ) -> Result<(), fidl::Error> {
3381        self.client.send::<FlatlandRemoveChildRequest>(
3382            (parent_transform_id, child_transform_id),
3383            0x41d6cd90b298b67a,
3384            fidl::encoding::DynamicFlags::empty(),
3385        )
3386    }
3387
3388    fn r#replace_children(
3389        &self,
3390        mut parent_transform_id: &TransformId,
3391        mut new_child_transform_ids: &[TransformId],
3392    ) -> Result<(), fidl::Error> {
3393        self.client.send::<FlatlandReplaceChildrenRequest>(
3394            (parent_transform_id, new_child_transform_ids),
3395            0x5b6d86cbbff81316,
3396            fidl::encoding::DynamicFlags::empty(),
3397        )
3398    }
3399
3400    fn r#set_root_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3401        self.client.send::<FlatlandSetRootTransformRequest>(
3402            (transform_id,),
3403            0x6e80ca5bcc566cd8,
3404            fidl::encoding::DynamicFlags::empty(),
3405        )
3406    }
3407
3408    fn r#set_hit_regions(
3409        &self,
3410        mut transform_id: &TransformId,
3411        mut regions: &[HitRegion],
3412    ) -> Result<(), fidl::Error> {
3413        self.client.send::<FlatlandSetHitRegionsRequest>(
3414            (transform_id, regions),
3415            0x31c9d17b07c37ce4,
3416            fidl::encoding::DynamicFlags::empty(),
3417        )
3418    }
3419
3420    fn r#set_infinite_hit_region(
3421        &self,
3422        mut transform_id: &TransformId,
3423        mut hit_test: HitTestInteraction,
3424    ) -> Result<(), fidl::Error> {
3425        self.client.send::<FlatlandSetInfiniteHitRegionRequest>(
3426            (transform_id, hit_test),
3427            0x26d81af852d29562,
3428            fidl::encoding::DynamicFlags::empty(),
3429        )
3430    }
3431
3432    fn r#create_viewport(
3433        &self,
3434        mut viewport_id: &ContentId,
3435        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
3436        mut properties: &ViewportProperties,
3437        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
3438    ) -> Result<(), fidl::Error> {
3439        self.client.send::<FlatlandCreateViewportRequest>(
3440            (viewport_id, &mut token, properties, child_view_watcher),
3441            0x2485fbcab7f943c,
3442            fidl::encoding::DynamicFlags::empty(),
3443        )
3444    }
3445
3446    fn r#create_image(
3447        &self,
3448        mut image_id: &ContentId,
3449        mut import_token: BufferCollectionImportToken,
3450        mut vmo_index: u32,
3451        mut properties: &ImageProperties,
3452    ) -> Result<(), fidl::Error> {
3453        self.client.send::<FlatlandCreateImageRequest>(
3454            (image_id, &mut import_token, vmo_index, properties),
3455            0x26fae823c4ebedad,
3456            fidl::encoding::DynamicFlags::empty(),
3457        )
3458    }
3459
3460    fn r#set_image_sample_region(
3461        &self,
3462        mut image_id: &ContentId,
3463        mut rect: &fidl_fuchsia_math::RectF,
3464    ) -> Result<(), fidl::Error> {
3465        self.client.send::<FlatlandSetImageSampleRegionRequest>(
3466            (image_id, rect),
3467            0x8039391d715eb28,
3468            fidl::encoding::DynamicFlags::empty(),
3469        )
3470    }
3471
3472    fn r#set_image_destination_size(
3473        &self,
3474        mut image_id: &ContentId,
3475        mut size: &fidl_fuchsia_math::SizeU,
3476    ) -> Result<(), fidl::Error> {
3477        self.client.send::<FlatlandSetImageDestinationSizeRequest>(
3478            (image_id, size),
3479            0x766cf99a2ec58446,
3480            fidl::encoding::DynamicFlags::empty(),
3481        )
3482    }
3483
3484    fn r#set_image_blending_function(
3485        &self,
3486        mut image_id: &ContentId,
3487        mut blend_mode: BlendMode,
3488    ) -> Result<(), fidl::Error> {
3489        self.client.send::<FlatlandSetImageBlendingFunctionRequest>(
3490            (image_id, blend_mode),
3491            0x10f5da1356275b7b,
3492            fidl::encoding::DynamicFlags::empty(),
3493        )
3494    }
3495
3496    fn r#set_image_blend_mode(
3497        &self,
3498        mut image_id: &ContentId,
3499        mut blend_mode: BlendMode2,
3500    ) -> Result<(), fidl::Error> {
3501        self.client.send::<FlatlandSetImageBlendModeRequest>(
3502            (image_id, blend_mode),
3503            0x5b1667f130c3de67,
3504            fidl::encoding::DynamicFlags::empty(),
3505        )
3506    }
3507
3508    fn r#set_image_opacity(
3509        &self,
3510        mut image_id: &ContentId,
3511        mut val: f32,
3512    ) -> Result<(), fidl::Error> {
3513        self.client.send::<FlatlandSetImageOpacityRequest>(
3514            (image_id, val),
3515            0x2da9e4ef4c2cff6f,
3516            fidl::encoding::DynamicFlags::empty(),
3517        )
3518    }
3519
3520    fn r#set_image_flip(
3521        &self,
3522        mut image_id: &ContentId,
3523        mut flip: ImageFlip,
3524    ) -> Result<(), fidl::Error> {
3525        self.client.send::<FlatlandSetImageFlipRequest>(
3526            (image_id, flip),
3527            0x21b20f2c14aae6bc,
3528            fidl::encoding::DynamicFlags::empty(),
3529        )
3530    }
3531
3532    fn r#create_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3533        self.client.send::<FlatlandCreateFilledRectRequest>(
3534            (rect_id,),
3535            0x5e62355abc1c4c5d,
3536            fidl::encoding::DynamicFlags::empty(),
3537        )
3538    }
3539
3540    fn r#set_solid_fill(
3541        &self,
3542        mut rect_id: &ContentId,
3543        mut color: &ColorRgba,
3544        mut size: &fidl_fuchsia_math::SizeU,
3545    ) -> Result<(), fidl::Error> {
3546        self.client.send::<FlatlandSetSolidFillRequest>(
3547            (rect_id, color, size),
3548            0x32d6ef41e182dfa5,
3549            fidl::encoding::DynamicFlags::empty(),
3550        )
3551    }
3552
3553    fn r#release_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3554        self.client.send::<FlatlandReleaseFilledRectRequest>(
3555            (rect_id,),
3556            0x7392cabe45618f9b,
3557            fidl::encoding::DynamicFlags::empty(),
3558        )
3559    }
3560
3561    fn r#set_content(
3562        &self,
3563        mut transform_id: &TransformId,
3564        mut content_id: &ContentId,
3565    ) -> Result<(), fidl::Error> {
3566        self.client.send::<FlatlandSetContentRequest>(
3567            (transform_id, content_id),
3568            0x4ed2cfc0ce130862,
3569            fidl::encoding::DynamicFlags::empty(),
3570        )
3571    }
3572
3573    fn r#set_viewport_properties(
3574        &self,
3575        mut viewport_id: &ContentId,
3576        mut properties: &ViewportProperties,
3577    ) -> Result<(), fidl::Error> {
3578        self.client.send::<FlatlandSetViewportPropertiesRequest>(
3579            (viewport_id, properties),
3580            0x66ab67e9608ddb9f,
3581            fidl::encoding::DynamicFlags::empty(),
3582        )
3583    }
3584
3585    fn r#release_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3586        self.client.send::<FlatlandReleaseTransformRequest>(
3587            (transform_id,),
3588            0xab9328419451c22,
3589            fidl::encoding::DynamicFlags::empty(),
3590        )
3591    }
3592
3593    fn r#release_view(&self) -> Result<(), fidl::Error> {
3594        self.client.send::<fidl::encoding::EmptyPayload>(
3595            (),
3596            0x5b35aab9baffecae,
3597            fidl::encoding::DynamicFlags::empty(),
3598        )
3599    }
3600
3601    type ReleaseViewportResponseFut = fidl::client::QueryResponseFut<
3602        fidl_fuchsia_ui_views::ViewportCreationToken,
3603        fidl::encoding::DefaultFuchsiaResourceDialect,
3604    >;
3605    fn r#release_viewport(&self, mut viewport_id: &ContentId) -> Self::ReleaseViewportResponseFut {
3606        fn _decode(
3607            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3608        ) -> Result<fidl_fuchsia_ui_views::ViewportCreationToken, fidl::Error> {
3609            let _response = fidl::client::decode_transaction_body::<
3610                FlatlandReleaseViewportResponse,
3611                fidl::encoding::DefaultFuchsiaResourceDialect,
3612                0xbad474aeb5293f9,
3613            >(_buf?)?;
3614            Ok(_response.token)
3615        }
3616        self.client.send_query_and_decode::<
3617            FlatlandReleaseViewportRequest,
3618            fidl_fuchsia_ui_views::ViewportCreationToken,
3619        >(
3620            (viewport_id,),
3621            0xbad474aeb5293f9,
3622            fidl::encoding::DynamicFlags::empty(),
3623            _decode,
3624        )
3625    }
3626
3627    fn r#release_image(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
3628        self.client.send::<FlatlandReleaseImageRequest>(
3629            (image_id,),
3630            0xb884ffdbc72c111,
3631            fidl::encoding::DynamicFlags::empty(),
3632        )
3633    }
3634
3635    fn r#clear(&self) -> Result<(), fidl::Error> {
3636        self.client.send::<fidl::encoding::EmptyPayload>(
3637            (),
3638            0x4ec8817c02828c3e,
3639            fidl::encoding::DynamicFlags::empty(),
3640        )
3641    }
3642
3643    fn r#set_debug_name(&self, mut name: &str) -> Result<(), fidl::Error> {
3644        self.client.send::<FlatlandSetDebugNameRequest>(
3645            (name,),
3646            0x46a8b397e68a8888,
3647            fidl::encoding::DynamicFlags::empty(),
3648        )
3649    }
3650}
3651
3652pub struct FlatlandEventStream {
3653    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3654}
3655
3656impl std::marker::Unpin for FlatlandEventStream {}
3657
3658impl futures::stream::FusedStream for FlatlandEventStream {
3659    fn is_terminated(&self) -> bool {
3660        self.event_receiver.is_terminated()
3661    }
3662}
3663
3664impl futures::Stream for FlatlandEventStream {
3665    type Item = Result<FlatlandEvent, fidl::Error>;
3666
3667    fn poll_next(
3668        mut self: std::pin::Pin<&mut Self>,
3669        cx: &mut std::task::Context<'_>,
3670    ) -> std::task::Poll<Option<Self::Item>> {
3671        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3672            &mut self.event_receiver,
3673            cx
3674        )?) {
3675            Some(buf) => std::task::Poll::Ready(Some(FlatlandEvent::decode(buf))),
3676            None => std::task::Poll::Ready(None),
3677        }
3678    }
3679}
3680
3681#[derive(Debug)]
3682pub enum FlatlandEvent {
3683    OnNextFrameBegin { values: OnNextFrameBeginValues },
3684    OnFramePresented { frame_presented_info: fidl_fuchsia_scenic_scheduling::FramePresentedInfo },
3685    OnError { error: FlatlandError },
3686}
3687
3688impl FlatlandEvent {
3689    #[allow(irrefutable_let_patterns)]
3690    pub fn into_on_next_frame_begin(self) -> Option<OnNextFrameBeginValues> {
3691        if let FlatlandEvent::OnNextFrameBegin { values } = self { Some((values)) } else { None }
3692    }
3693    #[allow(irrefutable_let_patterns)]
3694    pub fn into_on_frame_presented(
3695        self,
3696    ) -> Option<fidl_fuchsia_scenic_scheduling::FramePresentedInfo> {
3697        if let FlatlandEvent::OnFramePresented { frame_presented_info } = self {
3698            Some((frame_presented_info))
3699        } else {
3700            None
3701        }
3702    }
3703    #[allow(irrefutable_let_patterns)]
3704    pub fn into_on_error(self) -> Option<FlatlandError> {
3705        if let FlatlandEvent::OnError { error } = self { Some((error)) } else { None }
3706    }
3707
3708    /// Decodes a message buffer as a [`FlatlandEvent`].
3709    fn decode(
3710        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3711    ) -> Result<FlatlandEvent, fidl::Error> {
3712        let (bytes, _handles) = buf.split_mut();
3713        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3714        debug_assert_eq!(tx_header.tx_id, 0);
3715        match tx_header.ordinal {
3716            0x10f69a5cdeece84a => {
3717                let mut out = fidl::new_empty!(
3718                    FlatlandOnNextFrameBeginRequest,
3719                    fidl::encoding::DefaultFuchsiaResourceDialect
3720                );
3721                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandOnNextFrameBeginRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3722                Ok((FlatlandEvent::OnNextFrameBegin { values: out.values }))
3723            }
3724            0x56e43e1a5f30216d => {
3725                let mut out = fidl::new_empty!(
3726                    FlatlandOnFramePresentedRequest,
3727                    fidl::encoding::DefaultFuchsiaResourceDialect
3728                );
3729                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandOnFramePresentedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3730                Ok((FlatlandEvent::OnFramePresented {
3731                    frame_presented_info: out.frame_presented_info,
3732                }))
3733            }
3734            0x1ebf39e90cd8b8d => {
3735                let mut out = fidl::new_empty!(
3736                    FlatlandOnErrorRequest,
3737                    fidl::encoding::DefaultFuchsiaResourceDialect
3738                );
3739                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandOnErrorRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3740                Ok((FlatlandEvent::OnError { error: out.error }))
3741            }
3742            _ => Err(fidl::Error::UnknownOrdinal {
3743                ordinal: tx_header.ordinal,
3744                protocol_name: <FlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3745            }),
3746        }
3747    }
3748}
3749
3750/// A Stream of incoming requests for fuchsia.ui.composition/Flatland.
3751pub struct FlatlandRequestStream {
3752    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3753    is_terminated: bool,
3754}
3755
3756impl std::marker::Unpin for FlatlandRequestStream {}
3757
3758impl futures::stream::FusedStream for FlatlandRequestStream {
3759    fn is_terminated(&self) -> bool {
3760        self.is_terminated
3761    }
3762}
3763
3764impl fidl::endpoints::RequestStream for FlatlandRequestStream {
3765    type Protocol = FlatlandMarker;
3766    type ControlHandle = FlatlandControlHandle;
3767
3768    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3769        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3770    }
3771
3772    fn control_handle(&self) -> Self::ControlHandle {
3773        FlatlandControlHandle { inner: self.inner.clone() }
3774    }
3775
3776    fn into_inner(
3777        self,
3778    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3779    {
3780        (self.inner, self.is_terminated)
3781    }
3782
3783    fn from_inner(
3784        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3785        is_terminated: bool,
3786    ) -> Self {
3787        Self { inner, is_terminated }
3788    }
3789}
3790
3791impl futures::Stream for FlatlandRequestStream {
3792    type Item = Result<FlatlandRequest, fidl::Error>;
3793
3794    fn poll_next(
3795        mut self: std::pin::Pin<&mut Self>,
3796        cx: &mut std::task::Context<'_>,
3797    ) -> std::task::Poll<Option<Self::Item>> {
3798        let this = &mut *self;
3799        if this.inner.check_shutdown(cx) {
3800            this.is_terminated = true;
3801            return std::task::Poll::Ready(None);
3802        }
3803        if this.is_terminated {
3804            panic!("polled FlatlandRequestStream after completion");
3805        }
3806        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3807            |bytes, handles| {
3808                match this.inner.channel().read_etc(cx, bytes, handles) {
3809                    std::task::Poll::Ready(Ok(())) => {}
3810                    std::task::Poll::Pending => return std::task::Poll::Pending,
3811                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3812                        this.is_terminated = true;
3813                        return std::task::Poll::Ready(None);
3814                    }
3815                    std::task::Poll::Ready(Err(e)) => {
3816                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3817                            e.into(),
3818                        ))));
3819                    }
3820                }
3821
3822                // A message has been received from the channel
3823                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3824
3825                std::task::Poll::Ready(Some(match header.ordinal {
3826                    0x245e1ac080772c8 => {
3827                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3828                        let mut req = fidl::new_empty!(
3829                            TrustedFlatlandReleaseImageImmediatelyRequest,
3830                            fidl::encoding::DefaultFuchsiaResourceDialect
3831                        );
3832                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TrustedFlatlandReleaseImageImmediatelyRequest>(&header, _body_bytes, handles, &mut req)?;
3833                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3834                        Ok(FlatlandRequest::ReleaseImageImmediately {
3835                            image_id: req.image_id,
3836
3837                            control_handle,
3838                        })
3839                    }
3840                    0x50acc2aa1f0acec7 => {
3841                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3842                        let mut req = fidl::new_empty!(
3843                            FlatlandPresentRequest,
3844                            fidl::encoding::DefaultFuchsiaResourceDialect
3845                        );
3846                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandPresentRequest>(&header, _body_bytes, handles, &mut req)?;
3847                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3848                        Ok(FlatlandRequest::Present { args: req.args, control_handle })
3849                    }
3850                    0x504686eb25864780 => {
3851                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3852                        let mut req = fidl::new_empty!(
3853                            FlatlandCreateViewRequest,
3854                            fidl::encoding::DefaultFuchsiaResourceDialect
3855                        );
3856                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateViewRequest>(&header, _body_bytes, handles, &mut req)?;
3857                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3858                        Ok(FlatlandRequest::CreateView {
3859                            token: req.token,
3860                            parent_viewport_watcher: req.parent_viewport_watcher,
3861
3862                            control_handle,
3863                        })
3864                    }
3865                    0x340a3a40c2fdbd5e => {
3866                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3867                        let mut req = fidl::new_empty!(
3868                            FlatlandCreateView2Request,
3869                            fidl::encoding::DefaultFuchsiaResourceDialect
3870                        );
3871                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateView2Request>(&header, _body_bytes, handles, &mut req)?;
3872                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3873                        Ok(FlatlandRequest::CreateView2 {
3874                            token: req.token,
3875                            view_identity: req.view_identity,
3876                            protocols: req.protocols,
3877                            parent_viewport_watcher: req.parent_viewport_watcher,
3878
3879                            control_handle,
3880                        })
3881                    }
3882                    0x5e042a4d3de3efb0 => {
3883                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3884                        let mut req = fidl::new_empty!(
3885                            FlatlandCreateTransformRequest,
3886                            fidl::encoding::DefaultFuchsiaResourceDialect
3887                        );
3888                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateTransformRequest>(&header, _body_bytes, handles, &mut req)?;
3889                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3890                        Ok(FlatlandRequest::CreateTransform {
3891                            transform_id: req.transform_id,
3892
3893                            control_handle,
3894                        })
3895                    }
3896                    0x7863398291fba346 => {
3897                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3898                        let mut req = fidl::new_empty!(
3899                            FlatlandSetTranslationRequest,
3900                            fidl::encoding::DefaultFuchsiaResourceDialect
3901                        );
3902                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetTranslationRequest>(&header, _body_bytes, handles, &mut req)?;
3903                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3904                        Ok(FlatlandRequest::SetTranslation {
3905                            transform_id: req.transform_id,
3906                            translation: req.translation,
3907
3908                            control_handle,
3909                        })
3910                    }
3911                    0x4915310bc4928edc => {
3912                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3913                        let mut req = fidl::new_empty!(
3914                            FlatlandSetOrientationRequest,
3915                            fidl::encoding::DefaultFuchsiaResourceDialect
3916                        );
3917                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetOrientationRequest>(&header, _body_bytes, handles, &mut req)?;
3918                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3919                        Ok(FlatlandRequest::SetOrientation {
3920                            transform_id: req.transform_id,
3921                            orientation: req.orientation,
3922
3923                            control_handle,
3924                        })
3925                    }
3926                    0x1ea1766fd8996bb4 => {
3927                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3928                        let mut req = fidl::new_empty!(
3929                            FlatlandSetScaleRequest,
3930                            fidl::encoding::DefaultFuchsiaResourceDialect
3931                        );
3932                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetScaleRequest>(&header, _body_bytes, handles, &mut req)?;
3933                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3934                        Ok(FlatlandRequest::SetScale {
3935                            transform_id: req.transform_id,
3936                            scale: req.scale,
3937
3938                            control_handle,
3939                        })
3940                    }
3941                    0x3775fc2c00b432fa => {
3942                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3943                        let mut req = fidl::new_empty!(
3944                            FlatlandSetOpacityRequest,
3945                            fidl::encoding::DefaultFuchsiaResourceDialect
3946                        );
3947                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetOpacityRequest>(&header, _body_bytes, handles, &mut req)?;
3948                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3949                        Ok(FlatlandRequest::SetOpacity {
3950                            transform_id: req.transform_id,
3951                            value: req.value,
3952
3953                            control_handle,
3954                        })
3955                    }
3956                    0x6507843df12222d2 => {
3957                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3958                        let mut req = fidl::new_empty!(
3959                            FlatlandSetClipBoundaryRequest,
3960                            fidl::encoding::DefaultFuchsiaResourceDialect
3961                        );
3962                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetClipBoundaryRequest>(&header, _body_bytes, handles, &mut req)?;
3963                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3964                        Ok(FlatlandRequest::SetClipBoundary {
3965                            transform_id: req.transform_id,
3966                            rect: req.rect,
3967
3968                            control_handle,
3969                        })
3970                    }
3971                    0x67a8abd2f19b1a74 => {
3972                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3973                        let mut req = fidl::new_empty!(
3974                            FlatlandAddChildRequest,
3975                            fidl::encoding::DefaultFuchsiaResourceDialect
3976                        );
3977                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandAddChildRequest>(&header, _body_bytes, handles, &mut req)?;
3978                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3979                        Ok(FlatlandRequest::AddChild {
3980                            parent_transform_id: req.parent_transform_id,
3981                            child_transform_id: req.child_transform_id,
3982
3983                            control_handle,
3984                        })
3985                    }
3986                    0x41d6cd90b298b67a => {
3987                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3988                        let mut req = fidl::new_empty!(
3989                            FlatlandRemoveChildRequest,
3990                            fidl::encoding::DefaultFuchsiaResourceDialect
3991                        );
3992                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandRemoveChildRequest>(&header, _body_bytes, handles, &mut req)?;
3993                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3994                        Ok(FlatlandRequest::RemoveChild {
3995                            parent_transform_id: req.parent_transform_id,
3996                            child_transform_id: req.child_transform_id,
3997
3998                            control_handle,
3999                        })
4000                    }
4001                    0x5b6d86cbbff81316 => {
4002                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4003                        let mut req = fidl::new_empty!(
4004                            FlatlandReplaceChildrenRequest,
4005                            fidl::encoding::DefaultFuchsiaResourceDialect
4006                        );
4007                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReplaceChildrenRequest>(&header, _body_bytes, handles, &mut req)?;
4008                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4009                        Ok(FlatlandRequest::ReplaceChildren {
4010                            parent_transform_id: req.parent_transform_id,
4011                            new_child_transform_ids: req.new_child_transform_ids,
4012
4013                            control_handle,
4014                        })
4015                    }
4016                    0x6e80ca5bcc566cd8 => {
4017                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4018                        let mut req = fidl::new_empty!(
4019                            FlatlandSetRootTransformRequest,
4020                            fidl::encoding::DefaultFuchsiaResourceDialect
4021                        );
4022                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetRootTransformRequest>(&header, _body_bytes, handles, &mut req)?;
4023                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4024                        Ok(FlatlandRequest::SetRootTransform {
4025                            transform_id: req.transform_id,
4026
4027                            control_handle,
4028                        })
4029                    }
4030                    0x31c9d17b07c37ce4 => {
4031                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4032                        let mut req = fidl::new_empty!(
4033                            FlatlandSetHitRegionsRequest,
4034                            fidl::encoding::DefaultFuchsiaResourceDialect
4035                        );
4036                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetHitRegionsRequest>(&header, _body_bytes, handles, &mut req)?;
4037                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4038                        Ok(FlatlandRequest::SetHitRegions {
4039                            transform_id: req.transform_id,
4040                            regions: req.regions,
4041
4042                            control_handle,
4043                        })
4044                    }
4045                    0x26d81af852d29562 => {
4046                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4047                        let mut req = fidl::new_empty!(
4048                            FlatlandSetInfiniteHitRegionRequest,
4049                            fidl::encoding::DefaultFuchsiaResourceDialect
4050                        );
4051                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetInfiniteHitRegionRequest>(&header, _body_bytes, handles, &mut req)?;
4052                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4053                        Ok(FlatlandRequest::SetInfiniteHitRegion {
4054                            transform_id: req.transform_id,
4055                            hit_test: req.hit_test,
4056
4057                            control_handle,
4058                        })
4059                    }
4060                    0x2485fbcab7f943c => {
4061                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4062                        let mut req = fidl::new_empty!(
4063                            FlatlandCreateViewportRequest,
4064                            fidl::encoding::DefaultFuchsiaResourceDialect
4065                        );
4066                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateViewportRequest>(&header, _body_bytes, handles, &mut req)?;
4067                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4068                        Ok(FlatlandRequest::CreateViewport {
4069                            viewport_id: req.viewport_id,
4070                            token: req.token,
4071                            properties: req.properties,
4072                            child_view_watcher: req.child_view_watcher,
4073
4074                            control_handle,
4075                        })
4076                    }
4077                    0x26fae823c4ebedad => {
4078                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4079                        let mut req = fidl::new_empty!(
4080                            FlatlandCreateImageRequest,
4081                            fidl::encoding::DefaultFuchsiaResourceDialect
4082                        );
4083                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateImageRequest>(&header, _body_bytes, handles, &mut req)?;
4084                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4085                        Ok(FlatlandRequest::CreateImage {
4086                            image_id: req.image_id,
4087                            import_token: req.import_token,
4088                            vmo_index: req.vmo_index,
4089                            properties: req.properties,
4090
4091                            control_handle,
4092                        })
4093                    }
4094                    0x8039391d715eb28 => {
4095                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4096                        let mut req = fidl::new_empty!(
4097                            FlatlandSetImageSampleRegionRequest,
4098                            fidl::encoding::DefaultFuchsiaResourceDialect
4099                        );
4100                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageSampleRegionRequest>(&header, _body_bytes, handles, &mut req)?;
4101                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4102                        Ok(FlatlandRequest::SetImageSampleRegion {
4103                            image_id: req.image_id,
4104                            rect: req.rect,
4105
4106                            control_handle,
4107                        })
4108                    }
4109                    0x766cf99a2ec58446 => {
4110                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4111                        let mut req = fidl::new_empty!(
4112                            FlatlandSetImageDestinationSizeRequest,
4113                            fidl::encoding::DefaultFuchsiaResourceDialect
4114                        );
4115                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageDestinationSizeRequest>(&header, _body_bytes, handles, &mut req)?;
4116                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4117                        Ok(FlatlandRequest::SetImageDestinationSize {
4118                            image_id: req.image_id,
4119                            size: req.size,
4120
4121                            control_handle,
4122                        })
4123                    }
4124                    0x10f5da1356275b7b => {
4125                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4126                        let mut req = fidl::new_empty!(
4127                            FlatlandSetImageBlendingFunctionRequest,
4128                            fidl::encoding::DefaultFuchsiaResourceDialect
4129                        );
4130                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageBlendingFunctionRequest>(&header, _body_bytes, handles, &mut req)?;
4131                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4132                        Ok(FlatlandRequest::SetImageBlendingFunction {
4133                            image_id: req.image_id,
4134                            blend_mode: req.blend_mode,
4135
4136                            control_handle,
4137                        })
4138                    }
4139                    0x5b1667f130c3de67 => {
4140                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4141                        let mut req = fidl::new_empty!(
4142                            FlatlandSetImageBlendModeRequest,
4143                            fidl::encoding::DefaultFuchsiaResourceDialect
4144                        );
4145                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageBlendModeRequest>(&header, _body_bytes, handles, &mut req)?;
4146                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4147                        Ok(FlatlandRequest::SetImageBlendMode {
4148                            image_id: req.image_id,
4149                            blend_mode: req.blend_mode,
4150
4151                            control_handle,
4152                        })
4153                    }
4154                    0x2da9e4ef4c2cff6f => {
4155                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4156                        let mut req = fidl::new_empty!(
4157                            FlatlandSetImageOpacityRequest,
4158                            fidl::encoding::DefaultFuchsiaResourceDialect
4159                        );
4160                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageOpacityRequest>(&header, _body_bytes, handles, &mut req)?;
4161                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4162                        Ok(FlatlandRequest::SetImageOpacity {
4163                            image_id: req.image_id,
4164                            val: req.val,
4165
4166                            control_handle,
4167                        })
4168                    }
4169                    0x21b20f2c14aae6bc => {
4170                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4171                        let mut req = fidl::new_empty!(
4172                            FlatlandSetImageFlipRequest,
4173                            fidl::encoding::DefaultFuchsiaResourceDialect
4174                        );
4175                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageFlipRequest>(&header, _body_bytes, handles, &mut req)?;
4176                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4177                        Ok(FlatlandRequest::SetImageFlip {
4178                            image_id: req.image_id,
4179                            flip: req.flip,
4180
4181                            control_handle,
4182                        })
4183                    }
4184                    0x5e62355abc1c4c5d => {
4185                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4186                        let mut req = fidl::new_empty!(
4187                            FlatlandCreateFilledRectRequest,
4188                            fidl::encoding::DefaultFuchsiaResourceDialect
4189                        );
4190                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateFilledRectRequest>(&header, _body_bytes, handles, &mut req)?;
4191                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4192                        Ok(FlatlandRequest::CreateFilledRect {
4193                            rect_id: req.rect_id,
4194
4195                            control_handle,
4196                        })
4197                    }
4198                    0x32d6ef41e182dfa5 => {
4199                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4200                        let mut req = fidl::new_empty!(
4201                            FlatlandSetSolidFillRequest,
4202                            fidl::encoding::DefaultFuchsiaResourceDialect
4203                        );
4204                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetSolidFillRequest>(&header, _body_bytes, handles, &mut req)?;
4205                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4206                        Ok(FlatlandRequest::SetSolidFill {
4207                            rect_id: req.rect_id,
4208                            color: req.color,
4209                            size: req.size,
4210
4211                            control_handle,
4212                        })
4213                    }
4214                    0x7392cabe45618f9b => {
4215                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4216                        let mut req = fidl::new_empty!(
4217                            FlatlandReleaseFilledRectRequest,
4218                            fidl::encoding::DefaultFuchsiaResourceDialect
4219                        );
4220                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseFilledRectRequest>(&header, _body_bytes, handles, &mut req)?;
4221                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4222                        Ok(FlatlandRequest::ReleaseFilledRect {
4223                            rect_id: req.rect_id,
4224
4225                            control_handle,
4226                        })
4227                    }
4228                    0x4ed2cfc0ce130862 => {
4229                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4230                        let mut req = fidl::new_empty!(
4231                            FlatlandSetContentRequest,
4232                            fidl::encoding::DefaultFuchsiaResourceDialect
4233                        );
4234                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetContentRequest>(&header, _body_bytes, handles, &mut req)?;
4235                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4236                        Ok(FlatlandRequest::SetContent {
4237                            transform_id: req.transform_id,
4238                            content_id: req.content_id,
4239
4240                            control_handle,
4241                        })
4242                    }
4243                    0x66ab67e9608ddb9f => {
4244                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4245                        let mut req = fidl::new_empty!(
4246                            FlatlandSetViewportPropertiesRequest,
4247                            fidl::encoding::DefaultFuchsiaResourceDialect
4248                        );
4249                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetViewportPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
4250                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4251                        Ok(FlatlandRequest::SetViewportProperties {
4252                            viewport_id: req.viewport_id,
4253                            properties: req.properties,
4254
4255                            control_handle,
4256                        })
4257                    }
4258                    0xab9328419451c22 => {
4259                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4260                        let mut req = fidl::new_empty!(
4261                            FlatlandReleaseTransformRequest,
4262                            fidl::encoding::DefaultFuchsiaResourceDialect
4263                        );
4264                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseTransformRequest>(&header, _body_bytes, handles, &mut req)?;
4265                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4266                        Ok(FlatlandRequest::ReleaseTransform {
4267                            transform_id: req.transform_id,
4268
4269                            control_handle,
4270                        })
4271                    }
4272                    0x5b35aab9baffecae => {
4273                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4274                        let mut req = fidl::new_empty!(
4275                            fidl::encoding::EmptyPayload,
4276                            fidl::encoding::DefaultFuchsiaResourceDialect
4277                        );
4278                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4279                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4280                        Ok(FlatlandRequest::ReleaseView { control_handle })
4281                    }
4282                    0xbad474aeb5293f9 => {
4283                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4284                        let mut req = fidl::new_empty!(
4285                            FlatlandReleaseViewportRequest,
4286                            fidl::encoding::DefaultFuchsiaResourceDialect
4287                        );
4288                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseViewportRequest>(&header, _body_bytes, handles, &mut req)?;
4289                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4290                        Ok(FlatlandRequest::ReleaseViewport {
4291                            viewport_id: req.viewport_id,
4292
4293                            responder: FlatlandReleaseViewportResponder {
4294                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4295                                tx_id: header.tx_id,
4296                            },
4297                        })
4298                    }
4299                    0xb884ffdbc72c111 => {
4300                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4301                        let mut req = fidl::new_empty!(
4302                            FlatlandReleaseImageRequest,
4303                            fidl::encoding::DefaultFuchsiaResourceDialect
4304                        );
4305                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseImageRequest>(&header, _body_bytes, handles, &mut req)?;
4306                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4307                        Ok(FlatlandRequest::ReleaseImage { image_id: req.image_id, control_handle })
4308                    }
4309                    0x4ec8817c02828c3e => {
4310                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4311                        let mut req = fidl::new_empty!(
4312                            fidl::encoding::EmptyPayload,
4313                            fidl::encoding::DefaultFuchsiaResourceDialect
4314                        );
4315                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4316                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4317                        Ok(FlatlandRequest::Clear { control_handle })
4318                    }
4319                    0x46a8b397e68a8888 => {
4320                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4321                        let mut req = fidl::new_empty!(
4322                            FlatlandSetDebugNameRequest,
4323                            fidl::encoding::DefaultFuchsiaResourceDialect
4324                        );
4325                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetDebugNameRequest>(&header, _body_bytes, handles, &mut req)?;
4326                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4327                        Ok(FlatlandRequest::SetDebugName { name: req.name, control_handle })
4328                    }
4329                    _ => Err(fidl::Error::UnknownOrdinal {
4330                        ordinal: header.ordinal,
4331                        protocol_name:
4332                            <FlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4333                    }),
4334                }))
4335            },
4336        )
4337    }
4338}
4339
4340/// Each Flatland instance contains a Graph, which consists of a set of objects, and the
4341/// relationships between those objects. The client can specify a subset of those objects
4342/// (specifically, the directed acyclic graph starting at the root transform) to be presented as
4343/// content to some kind of output -- usually, a display.
4344///
4345/// Flatland Graphs are both hierarchical, and distributed. Graphs from different Flatland instances
4346/// may be connected together, allowing multiple processes to be involved in authoring content for a
4347/// particular output.
4348///
4349/// All functions in this protocol are feed-forward. The operations they represent are not fully
4350/// executed until [`Present`] is called.
4351#[derive(Debug)]
4352pub enum FlatlandRequest {
4353    /// Releases an image immediately, without waiting for the next present.
4354    ReleaseImageImmediately {
4355        image_id: ContentId,
4356        control_handle: FlatlandControlHandle,
4357    },
4358    /// Complete execution of all feed-forward operations.
4359    ///
4360    /// If executing an operation produces an error (e.g., CreateTransform(0)), an [`OnError`] event
4361    /// is emitted. Operations that produce errors are ignored and the channel is closed.
4362    ///
4363    /// If the execution is completed successfully, [`OnNextFrameBegin`] emits NO_ERROR along
4364    /// with other valid fields.
4365    ///
4366    /// The client may only call [`Present`] when they have a non-zero number of present credits,
4367    /// which are tracked by the server. The server may increment the number of credits when it
4368    /// fires the [`OnNextFrameBegin`] event, which informs the client when it receives additional
4369    /// present credits. Each [`Present`] call uses one present credit and decrements the server
4370    /// count by one. If the client calls [`Present`] with no present credits, the server will
4371    /// return a `NO_PRESENTS_REMAINING` error.
4372    ///
4373    /// The client should assume that prior to receiving any [`OnNextFrameBegin`] events, they have
4374    /// one present credit.
4375    ///
4376    /// Every [`Present`] call results in one [`OnNextFrameBegin`] event, and one
4377    /// [`OnFramePresented`] event, typically in that order.
4378    ///
4379    /// When the commands flushed by [`Present`] make it to display, an [`OnFramePresented`] event
4380    /// is fired. This event includes information pertaining to all [`Present`]s that had content
4381    /// that were part of that frame.
4382    ///
4383    /// See [`fuchsia.ui.composition/PresentArgs`] documentation above for more detailed information
4384    /// on what arguments are passed in and their role.
4385    Present {
4386        args: PresentArgs,
4387        control_handle: FlatlandControlHandle,
4388    },
4389    /// Two Flatland instances may be connected in a parent-child relationship. The parent endpoint
4390    /// is held in a Viewport, and the child endpoint is held in a View. The parent Flatland
4391    /// instance that creates a Viewport has control over how the child's View is integrated into
4392    /// its own View.
4393    ///
4394    /// The lifecycle of a parent-child connection starts with two endpoints of a channel object:
4395    /// a ViewportCreationToken and a ViewCreationToken. Out-of-band protocols pass the
4396    /// ViewportCreationToken to the parent, which calls [`CreateViewport`], and the
4397    /// ViewCreationToken to the child, which calls [`CreateView`].
4398    ///
4399    /// Only nodes connected to the Root Transform in this Flatland instance will be rendered into
4400    /// the parent's Viewport.
4401    ///
4402    /// Calling [`CreateView`] a second time will disconnect the Root Transform from the existing
4403    /// parent's Viewport, and attach it to a new parent's Viewport. In other words, each View can
4404    /// only have one parent.
4405    ///
4406    /// This function is queued, meaning that the Root Transform will not be attached to the
4407    /// parent Viewport until [`Present`] is called. However, clients will receive information
4408    /// through their ParentViewportWatcher (e.g., LayoutInfo) immediately after calling this
4409    /// function, even if they have not called [`Present`] or [`SetRootTransform`]. This allows
4410    /// clients to wait for layout information from their parent before calling [`Present`].
4411    ///
4412    /// Any illegal operations on ParentViewportWatcher will cause both ParentViewportWatcher
4413    /// channel and this Flatland channel to be torn down.
4414    ///
4415    /// Lifecycle note. The lifetime of the ParentViewportWatcher channel is bound by the peer
4416    /// ViewportCreationToken. When the ViewportCreationToken dies, this ParentViewportWatcher
4417    /// channel is destroyed.
4418    ///
4419    /// Views and subgraphs of Views created using `CreateView` will not be represented in the
4420    /// ViewTree, and hence will not be able to participate in any ViewTree-dependent interactions
4421    /// such as touch, mouse or focus.
4422    /// The Flatland protocol provides no way for Views in the subgraph of a View created with
4423    /// `CreateView` to know that they are excluded from the ViewTree.
4424    CreateView {
4425        token: fidl_fuchsia_ui_views::ViewCreationToken,
4426        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4427        control_handle: FlatlandControlHandle,
4428    },
4429    /// Identical to [`CreateView`], except it allows association of View identity (ViewRef) and
4430    /// view-bound protocols.
4431    CreateView2 {
4432        token: fidl_fuchsia_ui_views::ViewCreationToken,
4433        view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
4434        protocols: ViewBoundProtocols,
4435        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4436        control_handle: FlatlandControlHandle,
4437    },
4438    /// Creates a new Transform node. Transforms are a hierarchical piece of a Flatland graph. They
4439    /// can have children, and can reference Content. A sub-graph represented by a Transform and its
4440    /// descendants can be rendered to a display.
4441    ///
4442    /// Transforms are kept alive, even when released, as long as they are children of either an
4443    /// unreleased Transform, or the Root Transform.
4444    ///
4445    /// Each Transform can have a single piece of attached Content. Common types of Content include
4446    /// bitmaps, asynchronous streams of images, and Viewports to Views hosted in other Flatland
4447    /// instances.
4448    ///
4449    /// Transforms have attributes. Child Transforms inherit the combined attributes of their
4450    /// parents. Content attached to a Transform is also affected by that Transform's attributes.
4451    ///
4452    /// When a sub-graph of Transforms is rendered, Content will be rendered back-to-front, starting
4453    /// with the Content on the root transform, and continuing recursively through all of its child
4454    /// Transforms in the order the children were added. See [`AddChild`] for more information.
4455    ///
4456    /// Zero is not a valid transform id. All other values are valid, assuming they are not already
4457    /// in use (see [`ReleaseTransform`] for more details).
4458    CreateTransform {
4459        transform_id: TransformId,
4460        control_handle: FlatlandControlHandle,
4461    },
4462    /// All Transform objects support all attributes.
4463    ///
4464    /// Geometric attributes are applied in the following order:
4465    /// 1. Scale (relative to the parent transform's coordinate space)
4466    /// 2. Orientation (relative to the parent transform's coordinate space)
4467    /// 3. Translation (relative to the parent transforms's coordinate space,
4468    ///    unaffected by scale applied to the current transform).
4469    /// 4. Clipping (relative to the current transform's coordinate space)
4470    ///
4471    /// The effects of each of these attributes are cumulative. This means the transform's position
4472    /// in the view space, and its clip boundary, will be calculated based on that chain of
4473    /// geometric attributes going up to the root transform.
4474    ///
4475    /// For instance, in a nested hierarchy such as the following:
4476    ///     [Root-Transform -> Transform1 -> Transform2 -> CurrentTransform]
4477    /// If Transform1 is translated by [2,0] and Transform2 is translated by [0,1] then the
4478    /// view-space position of CurrentTransform will be [2,1].
4479    ///
4480    /// Sets the translation on a Transform. The order of geometric attribute application is
4481    /// addressed above.
4482    SetTranslation {
4483        transform_id: TransformId,
4484        translation: fidl_fuchsia_math::Vec_,
4485        control_handle: FlatlandControlHandle,
4486    },
4487    /// Sets the orientation on a Transform. The order of geometric attribute application is
4488    /// addressed in the documentation for [`SetTranslation`]. In Flatland, the +X axis is
4489    /// to the right and the +Y axis is down. There is no notion of a Z axis. CCW is defined
4490    /// from the POV of the user, as if a skeuomorphoic clock is displayed on the screen.
4491    SetOrientation {
4492        transform_id: TransformId,
4493        orientation: Orientation,
4494        control_handle: FlatlandControlHandle,
4495    },
4496    /// Sets the scale on a transform. The order of geometric attribute application is
4497    /// addressed above. The (x,y) values in the VecF |scale| refer to the scale factor in the
4498    /// x-axis (width) and y-axis (height) respectively. Scale values must be normal 32-bit
4499    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29
4500    SetScale {
4501        transform_id: TransformId,
4502        scale: fidl_fuchsia_math::VecF,
4503        control_handle: FlatlandControlHandle,
4504    },
4505    /// Sets an opacity in linear space to be applied to a transform and its descendents,
4506    /// which include other transforms and content. Opacity values must be in the range
4507    /// of [0.0, 1.0], where 0.0 is completely transparent and 1.0 is completely opaque.
4508    /// Attempting to call this function with values outside that range will result in
4509    /// an error. A transform's opacity value is multiplied with that of its parent. This
4510    /// effect works differently from group opacity. Using group opacity, child nodes are
4511    /// rendered together first, and then have the parent's opacity applied as a post-effect.
4512    /// Here, opacity is applied to each child individually. This may result in a very
4513    /// different effect.
4514    SetOpacity {
4515        transform_id: TransformId,
4516        value: f32,
4517        control_handle: FlatlandControlHandle,
4518    },
4519    /// Sets the bounds, expressed in the local coordinate space of the transform, that
4520    /// constrains the region that content attached to this transform can be rendered to.
4521    /// If the content's area exceeds the clip bounds, the area outside the bounds will
4522    /// not be rendered. These bounds are valid for all children of this transform node as
4523    /// well, which includes nested Flatland instances and their node hierarchies.
4524    /// If a child transform attempts to set clip bounds larger than that of its parent,
4525    /// it will be clipped to the parent's clip bounds. The default state is for a transform
4526    /// to be unclipped, meaning it will not have any bounds placed on its render region.
4527    /// The clip width/height must be positive. Negative values will result in an error.
4528    /// Passing in an empty box to the |rect| parameter will remove the clip bounds.
4529    SetClipBoundary {
4530        transform_id: TransformId,
4531        rect: Option<Box<fidl_fuchsia_math::Rect>>,
4532        control_handle: FlatlandControlHandle,
4533    },
4534    /// Adds a child Transform to a parent Transform. The new child Transform,
4535    /// and any Content attached to it or its children, will be rendered on top
4536    /// of the parent's Content, as well as any previously added children.
4537    ///
4538    /// The caller must ensure that `child_transform_id` is valid and that there
4539    /// are no repetitions.  Sending a repeated `child_transform_id` over
4540    /// multiple calls will result in session closure.
4541    AddChild {
4542        parent_transform_id: TransformId,
4543        child_transform_id: TransformId,
4544        control_handle: FlatlandControlHandle,
4545    },
4546    /// Removes a child Transform from a parent Transform.
4547    RemoveChild {
4548        parent_transform_id: TransformId,
4549        child_transform_id: TransformId,
4550        control_handle: FlatlandControlHandle,
4551    },
4552    /// Removes all child Transforms from a parent Transform and replaces them
4553    /// with the new child transforms in `new_child_transform_ids`.  The caller
4554    /// must ensure that all `TransformId` values in `new_child_transform_ids`
4555    /// are valid and that there are no repetitions.  Sending a repeated
4556    /// `TransformId` in `new_child_transform_ids` will result in session
4557    /// closure.
4558    ReplaceChildren {
4559        parent_transform_id: TransformId,
4560        new_child_transform_ids: Vec<TransformId>,
4561        control_handle: FlatlandControlHandle,
4562    },
4563    /// Sets the Root Transform for the graph.
4564    ///
4565    /// The sub-graph defined by the Root Transform and its children will be rendered as View
4566    /// in the connected parent's Viewport (see [`CreateView`]). Any parents of the Root Transform
4567    /// in this Graph will be ignored.
4568    ///
4569    /// The Root Transform, and all children of the Root Transform, are kept alive if they are
4570    /// released (see [`ReleaseTransform`] for more details).
4571    ///
4572    /// There is only ever one Root. Since 0 is not a valid transform id (see [`CreateTransform`]),
4573    /// calling SetRootTransform(0) clears the current Root, destroying any previously released
4574    /// objects that are not referenced by the new root.
4575    ///
4576    /// Note that every View has a clip boundary equivalent to its logical size. Anything outside
4577    /// that clip boundary will not be rendered. Hence, the Root Transform has a useful coordinate
4578    /// space of (0, 0) to (logical_size.width, logical_size.height), where (0, 0) is the upper left
4579    /// corner.
4580    ///
4581    /// Setting the root transform installs a full screen hit region on the root transform. Clients
4582    /// may remove this hit region if they don't want users to be able to interact with the root
4583    /// transform's content. For additional details on hit regions, see the [`SetHitRegions`]
4584    /// documentation.
4585    ///
4586    /// Default hit region rules
4587    ///
4588    ///   A default hit region follows these rules:
4589    ///   - When [`SetRootTransform`](T) is called, T receives a maximal hit region, covering the
4590    ///   entire view.
4591    ///   - If [`SetHitRegions`] is called on T, either before or after [`SetRootTransform`](T),
4592    ///   then no default hit region is active and the client specified hit regions are used.
4593    ///   - If a transform is no longer the root transform, i.e., [`SetRootTransform`](U) is
4594    ///   called, then the original transform no longer has its default hit region.
4595    ///   - Clients can remove or modify the root transform's hit regions the same way they would
4596    ///   reset any other transform's hit regions, by calling [`SetHitRegions`] with the appropriate
4597    ///   vector.
4598    SetRootTransform {
4599        transform_id: TransformId,
4600        control_handle: FlatlandControlHandle,
4601    },
4602    /// Sets the interactive areas for a Transform. By default, Content is not interactive; hit
4603    /// regions must be placed for a user to interact with the Content in a View. Because hit
4604    /// regions are described in the Flatland protocol, a Flatland instance can synchronize Content
4605    /// and hit regions.
4606    ///
4607    /// Each hit region is placed in the coordinate space of the owning Transform, and may or may
4608    /// not interact with different types of hit testing, depending on its [`HitTestInteraction`]
4609    /// type. When there are multiple hit regions that intersect with a hit test, the precedence
4610    /// rules given below dictate which hit region has interacted with the hit test. Only Transforms
4611    /// that transitively connect to the root Transform have their hit regions interact with a hit
4612    /// test.
4613    ///
4614    /// Calling this function replaces any previous values set on this Transform. To reset a
4615    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
4616    ///
4617    /// Note that root transforms get a default hit region installed by Flatland. For more details,
4618    /// see the [`SetRootTransform`] documentation.
4619    ///
4620    /// Precedence rules
4621    ///   Within a Transform, if multiple hit regions overlap, the hit test examines each
4622    ///   intersecting hit region for a possible interaction. Thus, for a regular hit test R and an
4623    ///   accessibility hit test A, where R and A both intersect two hit regions D ([`DEFAULT`]) and
4624    ///   S ([`SEMANTICALLY_INVISIBLE`]) on the same Transform, (1) R interacts with both D and S,
4625    ///   and (2) A only interacts with D. Generally, hit regions that overlap in a single Transform
4626    ///   can cause confusing behavior.
4627    ///
4628    ///   Within a View, for a given hit test, the front-most Transform's hit regions take
4629    ///   precedence over those behind. This follows the expected reverse "render order" of
4630    ///   Transforms (described in [`CreateTransform`]), where a user expects to interact with
4631    ///   Content that is visible, or front-most.
4632    ///
4633    ///   Across Flatland instances, for a given hit test, the front-most instance's front-most
4634    ///   Transform's hit regions take precedence over those behind. This follows the expected
4635    ///   reverse "render order" of views, where a user expects to interact with the View that is
4636    ///   visible, or front-most. For example, if a child View owns Content that is rendered over
4637    ///   the parent View, the user expects to interact with the child's Content.
4638    SetHitRegions {
4639        transform_id: TransformId,
4640        regions: Vec<HitRegion>,
4641        control_handle: FlatlandControlHandle,
4642    },
4643    /// Identical to [`SetHitRegions`], except the hit region associated with [`transform_id`]
4644    /// covers an infinite region. The hit region is invariant against translation, scaling, and
4645    /// orientation of the Transform.
4646    ///
4647    /// An infinite hit region is still limited in extent by the View's clip boundary, just like a
4648    /// finite hit region.
4649    ///
4650    /// Calling this function replaces any previous values set on this Transform. To reset a
4651    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
4652    SetInfiniteHitRegion {
4653        transform_id: TransformId,
4654        hit_test: HitTestInteraction,
4655        control_handle: FlatlandControlHandle,
4656    },
4657    /// The Viewport and View pair, together, represent the connection between two Flatland
4658    /// instances. The Viewport is created in the parent, and the View is created in the child. The
4659    /// parent has control over how the child's View is integrated into its own View.
4660    ///
4661    /// Any illegal operations on ChildViewWatcher will cause both ChildViewWatcher channel and this
4662    /// Flatland channel to be torn down.
4663    ///
4664    /// `ViewportProperties` must have logical_size set. This is the initial size that will drive
4665    /// the layout of the child. The logical_size is also used as the default Content size, but
4666    /// subsequent changes to the logical_size will have no effect on the Content size.
4667    ///
4668    /// `ViewportProperties` may have inset field not set. In that case, the default value of
4669    /// (0, 0, 0, 0) is used.
4670    ///
4671    /// The logical_size must have positive X and Y components.
4672    ///
4673    /// Zero is not a valid ContentId. All other values are valid, assuming they are not already
4674    /// in use for another piece of Content (see [`ReleaseViewport`] for more details).
4675    ///
4676    /// Lifecycle note. The lifetime of the ChildViewWatcher channel is bound by the peer
4677    /// ViewCreationToken. When the ViewCreationToken dies, this ChildViewWatcher channel is
4678    /// destroyed.
4679    CreateViewport {
4680        viewport_id: ContentId,
4681        token: fidl_fuchsia_ui_views::ViewportCreationToken,
4682        properties: ViewportProperties,
4683        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
4684        control_handle: FlatlandControlHandle,
4685    },
4686    /// An Image is a bitmap backed by a specific VMO in a BufferCollection.
4687    ///
4688    /// Image creation requires an allocated BufferCollection registered with Allocator. This
4689    /// function will fail unless all clients of the specified BufferCollection have set their
4690    /// constraints.
4691    ///
4692    /// The Image must reference a valid VMO index and must have ImageProperties that fall within
4693    /// the constraints specified by the backing BufferCollection (i.e. width and height within a
4694    /// valid range, etc.)
4695    ///
4696    /// Zero is not a valid Image id. All other values are valid, assuming they are not already in
4697    /// use for another piece of Content (see [`ReleaseImage`] for more details).
4698    CreateImage {
4699        image_id: ContentId,
4700        import_token: BufferCollectionImportToken,
4701        vmo_index: u32,
4702        properties: ImageProperties,
4703        control_handle: FlatlandControlHandle,
4704    },
4705    /// This function is used to determine the region (in texel space) of an image that will be used
4706    /// by Flatland when rendering. The image to be sampled is referenced by [`image_id`] and the
4707    /// sample region is specified by [`rect`] which itself is comprised of an origin point (x,y) as
4708    /// well as a width and height, in unnormalized coordinates. It is illegal to call this function
4709    /// on non-image content, or to sample a region outside of the texel space of the image. In
4710    /// other words, the region specifed by [`rect`] must not exceed the ranges (0, image_width) and
4711    /// (0, image_height). If (rect.x + rect.width > image_width) or (rect.y + rect.height >
4712    /// image_height) or if any of the values are negative, this will result in an error.
4713    ///
4714    /// If this method is not called, the default sample region is the rectangle with origin at
4715    /// (0, 0) and width and height set at ImageProperties from [`CreateImage`].
4716    SetImageSampleRegion {
4717        image_id: ContentId,
4718        rect: fidl_fuchsia_math::RectF,
4719        control_handle: FlatlandControlHandle,
4720    },
4721    /// The content size for an Image is the size of the rectangle in the parent's logical
4722    /// coordinate space that the image occupies. This combined with the global translation of the
4723    /// transform it is attached to determines the size and location of where the content is
4724    /// rendered on the display.
4725    ///
4726    /// If this method is not called, the default image destination size is the width and height set
4727    /// at ImageProperties from [`CreateImage`]. The destination size will be affected by scaling if
4728    /// [`SetScale`] is used on the attached Transform or its parents.
4729    SetImageDestinationSize {
4730        image_id: ContentId,
4731        size: fidl_fuchsia_math::SizeU,
4732        control_handle: FlatlandControlHandle,
4733    },
4734    /// Determines the blend function to use when rendering the content specified by
4735    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
4736    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
4737    /// that are available, please refer to the BlendMode enum. If this function is not called, then
4738    /// the default blendmode is BlendMode::SRC.
4739    SetImageBlendingFunction {
4740        image_id: ContentId,
4741        blend_mode: BlendMode,
4742        control_handle: FlatlandControlHandle,
4743    },
4744    /// Determines the blend function to use when rendering the content specified by
4745    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
4746    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
4747    /// that are available, please refer to the BlendMode2 enum. If this function is not called,
4748    /// the default blendmode is BlendMode2::REPLACE.
4749    SetImageBlendMode {
4750        image_id: ContentId,
4751        blend_mode: BlendMode2,
4752        control_handle: FlatlandControlHandle,
4753    },
4754    /// Sets an opacity in linear space to be applied to a flatland image. Opacity values must
4755    /// be in the range [0.0, 1.0].
4756    SetImageOpacity {
4757        image_id: ContentId,
4758        val: f32,
4759        control_handle: FlatlandControlHandle,
4760    },
4761    /// Sets the image flip to be applied to a flatland image. This call must be performed after a
4762    /// successful |CreateImage| call. If an invalid |image_id| is supplied, the channel will be
4763    /// closed due to FlatlandError::BAD_OPERATION. This flip will be applied to the Image before
4764    /// parent Transform Orientations. If this function is not called, then the default flip value
4765    /// is ImageFlip::NONE.
4766    SetImageFlip {
4767        image_id: ContentId,
4768        flip: ImageFlip,
4769        control_handle: FlatlandControlHandle,
4770    },
4771    /// Creates a solid-color rectangle. By default a filled-rect does not have a defined
4772    /// color or size. It is necessary to call |SetSolidFill| to specify a color and size
4773    /// before a filled rect can be used for rendering. Not doing so will result the
4774    CreateFilledRect {
4775        rect_id: ContentId,
4776        control_handle: FlatlandControlHandle,
4777    },
4778    /// Defines the color and size of a filled rect. |rect_id| must refer to content that
4779    /// was created via a call to CreateFilledRect. The color is not premultiplied. Color values
4780    /// must be within the range [0,1] inclusive, and normal 32-bit
4781    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29. Values
4782    /// that do not conform to these specifications will cause the channel to close.
4783    /// The rectangle's top left corner will be at (0, 0) in its transform's coordinate space.
4784    /// Hence, its bottom right corner will be at (size.width, size.height).
4785    SetSolidFill {
4786        rect_id: ContentId,
4787        color: ColorRgba,
4788        size: fidl_fuchsia_math::SizeU,
4789        control_handle: FlatlandControlHandle,
4790    },
4791    /// Automatically garbage collects the rectangle when it is no longer needed for
4792    /// rendering. |rect_id| must have been instantiated with a call to
4793    /// |CreateFilledRect|. Once released, the ID immediately goes out of scope and is free
4794    /// to be used again.
4795    ReleaseFilledRect {
4796        rect_id: ContentId,
4797        control_handle: FlatlandControlHandle,
4798    },
4799    /// Setting a piece of Content on a Transform makes that Content visible in the render tree as
4800    /// long as the Transform is visible from the root Transform. The Content will be rendered
4801    /// before, and therefore "behind", any Content attached to the descendants of the Transform.
4802    ///
4803    /// Because each Transform can have, at most, a single piece of Content on it, calling this
4804    /// function on a Transform that already has Content will replace that Content.
4805    ///
4806    /// A Content may be set on more than one Transform.
4807    ///
4808    /// Calling this function with a Content id of 0 will remove any Content currently on the
4809    /// Transform.
4810    SetContent {
4811        transform_id: TransformId,
4812        content_id: ContentId,
4813        control_handle: FlatlandControlHandle,
4814    },
4815    /// Transforms are usually sufficient to change how Content is presented. Viewports, however,
4816    /// have special properties that are not part of the Transform hierarchy. Those properties can
4817    /// be set using this function.
4818    SetViewportProperties {
4819        viewport_id: ContentId,
4820        properties: ViewportProperties,
4821        control_handle: FlatlandControlHandle,
4822    },
4823    /// Released Transforms will be garbage collected by the system once they are no longer
4824    /// necessary for rendering. For Transforms, this means there is no path from any unreleased
4825    /// Transform to the newly-released Transform.
4826    ///
4827    /// Once released, the id immediately goes out of scope for future function calls and can be
4828    /// reused when creating new Transforms.
4829    ///
4830    /// It is an error to call functions with a released id (unless that id has been reused to
4831    /// construct a new Transform).
4832    ReleaseTransform {
4833        transform_id: TransformId,
4834        control_handle: FlatlandControlHandle,
4835    },
4836    ReleaseView {
4837        control_handle: FlatlandControlHandle,
4838    },
4839    /// Releases a Viewport from the scene, even if the Viewport is still connected to a Transform.
4840    /// Unlike other resources, Viewports are garbage collected by the system during the next
4841    /// [`Present`] because a removed Viewport is guaranteed to provide no renderable content.
4842    ///
4843    /// Use SetContent(transform_id, 0) to clean up references to released Viewports.
4844    ///
4845    /// Despite having a return type, this function is still feed-forward like [`CreateView`] and
4846    /// requires a call to [`Present`] to be executed. The ViewportCreationToken will be returned
4847    /// after the presented operations have been executed.
4848    ReleaseViewport {
4849        viewport_id: ContentId,
4850        responder: FlatlandReleaseViewportResponder,
4851    },
4852    /// Released Images will be garbage collected by the system once they are no longer necessary
4853    /// for rendering. For Images, this means the Image is no longer attached to any Transform and
4854    /// any pending rendering that references the Image is complete.
4855    ///
4856    /// Use SetContent(transform_id, 0) to clean up references to released Images.
4857    ///
4858    /// Once released, the id immediately goes out of scope for future function calls and can be
4859    /// reused when creating new Images.
4860    ///
4861    /// It is an error to call functions with a released id (unless that id has been reused to
4862    /// construct a new Image).
4863    ReleaseImage {
4864        image_id: ContentId,
4865        control_handle: FlatlandControlHandle,
4866    },
4867    /// This function will reset all state on this interface. This includes destroying all existing
4868    /// View and Viewports without returning the associated Token to the caller.
4869    Clear {
4870        control_handle: FlatlandControlHandle,
4871    },
4872    /// Set debug name of the current client that can be used by Flatland to print as a prefix to
4873    /// logs to help client distinguish what is theirs. [`name`] can be an arbitrary string, but the
4874    /// current process name (see fsl::GetCurrentProcessName()) is a good default.
4875    SetDebugName {
4876        name: String,
4877        control_handle: FlatlandControlHandle,
4878    },
4879}
4880
4881impl FlatlandRequest {
4882    #[allow(irrefutable_let_patterns)]
4883    pub fn into_release_image_immediately(self) -> Option<(ContentId, FlatlandControlHandle)> {
4884        if let FlatlandRequest::ReleaseImageImmediately { image_id, control_handle } = self {
4885            Some((image_id, control_handle))
4886        } else {
4887            None
4888        }
4889    }
4890
4891    #[allow(irrefutable_let_patterns)]
4892    pub fn into_present(self) -> Option<(PresentArgs, FlatlandControlHandle)> {
4893        if let FlatlandRequest::Present { args, control_handle } = self {
4894            Some((args, control_handle))
4895        } else {
4896            None
4897        }
4898    }
4899
4900    #[allow(irrefutable_let_patterns)]
4901    pub fn into_create_view(
4902        self,
4903    ) -> Option<(
4904        fidl_fuchsia_ui_views::ViewCreationToken,
4905        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4906        FlatlandControlHandle,
4907    )> {
4908        if let FlatlandRequest::CreateView { token, parent_viewport_watcher, control_handle } = self
4909        {
4910            Some((token, parent_viewport_watcher, control_handle))
4911        } else {
4912            None
4913        }
4914    }
4915
4916    #[allow(irrefutable_let_patterns)]
4917    pub fn into_create_view2(
4918        self,
4919    ) -> Option<(
4920        fidl_fuchsia_ui_views::ViewCreationToken,
4921        fidl_fuchsia_ui_views::ViewIdentityOnCreation,
4922        ViewBoundProtocols,
4923        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4924        FlatlandControlHandle,
4925    )> {
4926        if let FlatlandRequest::CreateView2 {
4927            token,
4928            view_identity,
4929            protocols,
4930            parent_viewport_watcher,
4931            control_handle,
4932        } = self
4933        {
4934            Some((token, view_identity, protocols, parent_viewport_watcher, control_handle))
4935        } else {
4936            None
4937        }
4938    }
4939
4940    #[allow(irrefutable_let_patterns)]
4941    pub fn into_create_transform(self) -> Option<(TransformId, FlatlandControlHandle)> {
4942        if let FlatlandRequest::CreateTransform { transform_id, control_handle } = self {
4943            Some((transform_id, control_handle))
4944        } else {
4945            None
4946        }
4947    }
4948
4949    #[allow(irrefutable_let_patterns)]
4950    pub fn into_set_translation(
4951        self,
4952    ) -> Option<(TransformId, fidl_fuchsia_math::Vec_, FlatlandControlHandle)> {
4953        if let FlatlandRequest::SetTranslation { transform_id, translation, control_handle } = self
4954        {
4955            Some((transform_id, translation, control_handle))
4956        } else {
4957            None
4958        }
4959    }
4960
4961    #[allow(irrefutable_let_patterns)]
4962    pub fn into_set_orientation(self) -> Option<(TransformId, Orientation, FlatlandControlHandle)> {
4963        if let FlatlandRequest::SetOrientation { transform_id, orientation, control_handle } = self
4964        {
4965            Some((transform_id, orientation, control_handle))
4966        } else {
4967            None
4968        }
4969    }
4970
4971    #[allow(irrefutable_let_patterns)]
4972    pub fn into_set_scale(
4973        self,
4974    ) -> Option<(TransformId, fidl_fuchsia_math::VecF, FlatlandControlHandle)> {
4975        if let FlatlandRequest::SetScale { transform_id, scale, control_handle } = self {
4976            Some((transform_id, scale, control_handle))
4977        } else {
4978            None
4979        }
4980    }
4981
4982    #[allow(irrefutable_let_patterns)]
4983    pub fn into_set_opacity(self) -> Option<(TransformId, f32, FlatlandControlHandle)> {
4984        if let FlatlandRequest::SetOpacity { transform_id, value, control_handle } = self {
4985            Some((transform_id, value, control_handle))
4986        } else {
4987            None
4988        }
4989    }
4990
4991    #[allow(irrefutable_let_patterns)]
4992    pub fn into_set_clip_boundary(
4993        self,
4994    ) -> Option<(TransformId, Option<Box<fidl_fuchsia_math::Rect>>, FlatlandControlHandle)> {
4995        if let FlatlandRequest::SetClipBoundary { transform_id, rect, control_handle } = self {
4996            Some((transform_id, rect, control_handle))
4997        } else {
4998            None
4999        }
5000    }
5001
5002    #[allow(irrefutable_let_patterns)]
5003    pub fn into_add_child(self) -> Option<(TransformId, TransformId, FlatlandControlHandle)> {
5004        if let FlatlandRequest::AddChild {
5005            parent_transform_id,
5006            child_transform_id,
5007            control_handle,
5008        } = self
5009        {
5010            Some((parent_transform_id, child_transform_id, control_handle))
5011        } else {
5012            None
5013        }
5014    }
5015
5016    #[allow(irrefutable_let_patterns)]
5017    pub fn into_remove_child(self) -> Option<(TransformId, TransformId, FlatlandControlHandle)> {
5018        if let FlatlandRequest::RemoveChild {
5019            parent_transform_id,
5020            child_transform_id,
5021            control_handle,
5022        } = self
5023        {
5024            Some((parent_transform_id, child_transform_id, control_handle))
5025        } else {
5026            None
5027        }
5028    }
5029
5030    #[allow(irrefutable_let_patterns)]
5031    pub fn into_replace_children(
5032        self,
5033    ) -> Option<(TransformId, Vec<TransformId>, FlatlandControlHandle)> {
5034        if let FlatlandRequest::ReplaceChildren {
5035            parent_transform_id,
5036            new_child_transform_ids,
5037            control_handle,
5038        } = self
5039        {
5040            Some((parent_transform_id, new_child_transform_ids, control_handle))
5041        } else {
5042            None
5043        }
5044    }
5045
5046    #[allow(irrefutable_let_patterns)]
5047    pub fn into_set_root_transform(self) -> Option<(TransformId, FlatlandControlHandle)> {
5048        if let FlatlandRequest::SetRootTransform { transform_id, control_handle } = self {
5049            Some((transform_id, control_handle))
5050        } else {
5051            None
5052        }
5053    }
5054
5055    #[allow(irrefutable_let_patterns)]
5056    pub fn into_set_hit_regions(
5057        self,
5058    ) -> Option<(TransformId, Vec<HitRegion>, FlatlandControlHandle)> {
5059        if let FlatlandRequest::SetHitRegions { transform_id, regions, control_handle } = self {
5060            Some((transform_id, regions, control_handle))
5061        } else {
5062            None
5063        }
5064    }
5065
5066    #[allow(irrefutable_let_patterns)]
5067    pub fn into_set_infinite_hit_region(
5068        self,
5069    ) -> Option<(TransformId, HitTestInteraction, FlatlandControlHandle)> {
5070        if let FlatlandRequest::SetInfiniteHitRegion { transform_id, hit_test, control_handle } =
5071            self
5072        {
5073            Some((transform_id, hit_test, control_handle))
5074        } else {
5075            None
5076        }
5077    }
5078
5079    #[allow(irrefutable_let_patterns)]
5080    pub fn into_create_viewport(
5081        self,
5082    ) -> Option<(
5083        ContentId,
5084        fidl_fuchsia_ui_views::ViewportCreationToken,
5085        ViewportProperties,
5086        fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5087        FlatlandControlHandle,
5088    )> {
5089        if let FlatlandRequest::CreateViewport {
5090            viewport_id,
5091            token,
5092            properties,
5093            child_view_watcher,
5094            control_handle,
5095        } = self
5096        {
5097            Some((viewport_id, token, properties, child_view_watcher, control_handle))
5098        } else {
5099            None
5100        }
5101    }
5102
5103    #[allow(irrefutable_let_patterns)]
5104    pub fn into_create_image(
5105        self,
5106    ) -> Option<(ContentId, BufferCollectionImportToken, u32, ImageProperties, FlatlandControlHandle)>
5107    {
5108        if let FlatlandRequest::CreateImage {
5109            image_id,
5110            import_token,
5111            vmo_index,
5112            properties,
5113            control_handle,
5114        } = self
5115        {
5116            Some((image_id, import_token, vmo_index, properties, control_handle))
5117        } else {
5118            None
5119        }
5120    }
5121
5122    #[allow(irrefutable_let_patterns)]
5123    pub fn into_set_image_sample_region(
5124        self,
5125    ) -> Option<(ContentId, fidl_fuchsia_math::RectF, FlatlandControlHandle)> {
5126        if let FlatlandRequest::SetImageSampleRegion { image_id, rect, control_handle } = self {
5127            Some((image_id, rect, control_handle))
5128        } else {
5129            None
5130        }
5131    }
5132
5133    #[allow(irrefutable_let_patterns)]
5134    pub fn into_set_image_destination_size(
5135        self,
5136    ) -> Option<(ContentId, fidl_fuchsia_math::SizeU, FlatlandControlHandle)> {
5137        if let FlatlandRequest::SetImageDestinationSize { image_id, size, control_handle } = self {
5138            Some((image_id, size, control_handle))
5139        } else {
5140            None
5141        }
5142    }
5143
5144    #[allow(irrefutable_let_patterns)]
5145    pub fn into_set_image_blending_function(
5146        self,
5147    ) -> Option<(ContentId, BlendMode, FlatlandControlHandle)> {
5148        if let FlatlandRequest::SetImageBlendingFunction { image_id, blend_mode, control_handle } =
5149            self
5150        {
5151            Some((image_id, blend_mode, control_handle))
5152        } else {
5153            None
5154        }
5155    }
5156
5157    #[allow(irrefutable_let_patterns)]
5158    pub fn into_set_image_blend_mode(
5159        self,
5160    ) -> Option<(ContentId, BlendMode2, FlatlandControlHandle)> {
5161        if let FlatlandRequest::SetImageBlendMode { image_id, blend_mode, control_handle } = self {
5162            Some((image_id, blend_mode, control_handle))
5163        } else {
5164            None
5165        }
5166    }
5167
5168    #[allow(irrefutable_let_patterns)]
5169    pub fn into_set_image_opacity(self) -> Option<(ContentId, f32, FlatlandControlHandle)> {
5170        if let FlatlandRequest::SetImageOpacity { image_id, val, control_handle } = self {
5171            Some((image_id, val, control_handle))
5172        } else {
5173            None
5174        }
5175    }
5176
5177    #[allow(irrefutable_let_patterns)]
5178    pub fn into_set_image_flip(self) -> Option<(ContentId, ImageFlip, FlatlandControlHandle)> {
5179        if let FlatlandRequest::SetImageFlip { image_id, flip, control_handle } = self {
5180            Some((image_id, flip, control_handle))
5181        } else {
5182            None
5183        }
5184    }
5185
5186    #[allow(irrefutable_let_patterns)]
5187    pub fn into_create_filled_rect(self) -> Option<(ContentId, FlatlandControlHandle)> {
5188        if let FlatlandRequest::CreateFilledRect { rect_id, control_handle } = self {
5189            Some((rect_id, control_handle))
5190        } else {
5191            None
5192        }
5193    }
5194
5195    #[allow(irrefutable_let_patterns)]
5196    pub fn into_set_solid_fill(
5197        self,
5198    ) -> Option<(ContentId, ColorRgba, fidl_fuchsia_math::SizeU, FlatlandControlHandle)> {
5199        if let FlatlandRequest::SetSolidFill { rect_id, color, size, control_handle } = self {
5200            Some((rect_id, color, size, control_handle))
5201        } else {
5202            None
5203        }
5204    }
5205
5206    #[allow(irrefutable_let_patterns)]
5207    pub fn into_release_filled_rect(self) -> Option<(ContentId, FlatlandControlHandle)> {
5208        if let FlatlandRequest::ReleaseFilledRect { rect_id, control_handle } = self {
5209            Some((rect_id, control_handle))
5210        } else {
5211            None
5212        }
5213    }
5214
5215    #[allow(irrefutable_let_patterns)]
5216    pub fn into_set_content(self) -> Option<(TransformId, ContentId, FlatlandControlHandle)> {
5217        if let FlatlandRequest::SetContent { transform_id, content_id, control_handle } = self {
5218            Some((transform_id, content_id, control_handle))
5219        } else {
5220            None
5221        }
5222    }
5223
5224    #[allow(irrefutable_let_patterns)]
5225    pub fn into_set_viewport_properties(
5226        self,
5227    ) -> Option<(ContentId, ViewportProperties, FlatlandControlHandle)> {
5228        if let FlatlandRequest::SetViewportProperties { viewport_id, properties, control_handle } =
5229            self
5230        {
5231            Some((viewport_id, properties, control_handle))
5232        } else {
5233            None
5234        }
5235    }
5236
5237    #[allow(irrefutable_let_patterns)]
5238    pub fn into_release_transform(self) -> Option<(TransformId, FlatlandControlHandle)> {
5239        if let FlatlandRequest::ReleaseTransform { transform_id, control_handle } = self {
5240            Some((transform_id, control_handle))
5241        } else {
5242            None
5243        }
5244    }
5245
5246    #[allow(irrefutable_let_patterns)]
5247    pub fn into_release_view(self) -> Option<(FlatlandControlHandle)> {
5248        if let FlatlandRequest::ReleaseView { control_handle } = self {
5249            Some((control_handle))
5250        } else {
5251            None
5252        }
5253    }
5254
5255    #[allow(irrefutable_let_patterns)]
5256    pub fn into_release_viewport(self) -> Option<(ContentId, FlatlandReleaseViewportResponder)> {
5257        if let FlatlandRequest::ReleaseViewport { viewport_id, responder } = self {
5258            Some((viewport_id, responder))
5259        } else {
5260            None
5261        }
5262    }
5263
5264    #[allow(irrefutable_let_patterns)]
5265    pub fn into_release_image(self) -> Option<(ContentId, FlatlandControlHandle)> {
5266        if let FlatlandRequest::ReleaseImage { image_id, control_handle } = self {
5267            Some((image_id, control_handle))
5268        } else {
5269            None
5270        }
5271    }
5272
5273    #[allow(irrefutable_let_patterns)]
5274    pub fn into_clear(self) -> Option<(FlatlandControlHandle)> {
5275        if let FlatlandRequest::Clear { control_handle } = self {
5276            Some((control_handle))
5277        } else {
5278            None
5279        }
5280    }
5281
5282    #[allow(irrefutable_let_patterns)]
5283    pub fn into_set_debug_name(self) -> Option<(String, FlatlandControlHandle)> {
5284        if let FlatlandRequest::SetDebugName { name, control_handle } = self {
5285            Some((name, control_handle))
5286        } else {
5287            None
5288        }
5289    }
5290
5291    /// Name of the method defined in FIDL
5292    pub fn method_name(&self) -> &'static str {
5293        match *self {
5294            FlatlandRequest::ReleaseImageImmediately { .. } => "release_image_immediately",
5295            FlatlandRequest::Present { .. } => "present",
5296            FlatlandRequest::CreateView { .. } => "create_view",
5297            FlatlandRequest::CreateView2 { .. } => "create_view2",
5298            FlatlandRequest::CreateTransform { .. } => "create_transform",
5299            FlatlandRequest::SetTranslation { .. } => "set_translation",
5300            FlatlandRequest::SetOrientation { .. } => "set_orientation",
5301            FlatlandRequest::SetScale { .. } => "set_scale",
5302            FlatlandRequest::SetOpacity { .. } => "set_opacity",
5303            FlatlandRequest::SetClipBoundary { .. } => "set_clip_boundary",
5304            FlatlandRequest::AddChild { .. } => "add_child",
5305            FlatlandRequest::RemoveChild { .. } => "remove_child",
5306            FlatlandRequest::ReplaceChildren { .. } => "replace_children",
5307            FlatlandRequest::SetRootTransform { .. } => "set_root_transform",
5308            FlatlandRequest::SetHitRegions { .. } => "set_hit_regions",
5309            FlatlandRequest::SetInfiniteHitRegion { .. } => "set_infinite_hit_region",
5310            FlatlandRequest::CreateViewport { .. } => "create_viewport",
5311            FlatlandRequest::CreateImage { .. } => "create_image",
5312            FlatlandRequest::SetImageSampleRegion { .. } => "set_image_sample_region",
5313            FlatlandRequest::SetImageDestinationSize { .. } => "set_image_destination_size",
5314            FlatlandRequest::SetImageBlendingFunction { .. } => "set_image_blending_function",
5315            FlatlandRequest::SetImageBlendMode { .. } => "set_image_blend_mode",
5316            FlatlandRequest::SetImageOpacity { .. } => "set_image_opacity",
5317            FlatlandRequest::SetImageFlip { .. } => "set_image_flip",
5318            FlatlandRequest::CreateFilledRect { .. } => "create_filled_rect",
5319            FlatlandRequest::SetSolidFill { .. } => "set_solid_fill",
5320            FlatlandRequest::ReleaseFilledRect { .. } => "release_filled_rect",
5321            FlatlandRequest::SetContent { .. } => "set_content",
5322            FlatlandRequest::SetViewportProperties { .. } => "set_viewport_properties",
5323            FlatlandRequest::ReleaseTransform { .. } => "release_transform",
5324            FlatlandRequest::ReleaseView { .. } => "release_view",
5325            FlatlandRequest::ReleaseViewport { .. } => "release_viewport",
5326            FlatlandRequest::ReleaseImage { .. } => "release_image",
5327            FlatlandRequest::Clear { .. } => "clear",
5328            FlatlandRequest::SetDebugName { .. } => "set_debug_name",
5329        }
5330    }
5331}
5332
5333#[derive(Debug, Clone)]
5334pub struct FlatlandControlHandle {
5335    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5336}
5337
5338impl fidl::endpoints::ControlHandle for FlatlandControlHandle {
5339    fn shutdown(&self) {
5340        self.inner.shutdown()
5341    }
5342
5343    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5344        self.inner.shutdown_with_epitaph(status)
5345    }
5346
5347    fn is_closed(&self) -> bool {
5348        self.inner.channel().is_closed()
5349    }
5350    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5351        self.inner.channel().on_closed()
5352    }
5353
5354    #[cfg(target_os = "fuchsia")]
5355    fn signal_peer(
5356        &self,
5357        clear_mask: zx::Signals,
5358        set_mask: zx::Signals,
5359    ) -> Result<(), zx_status::Status> {
5360        use fidl::Peered;
5361        self.inner.channel().signal_peer(clear_mask, set_mask)
5362    }
5363}
5364
5365impl FlatlandControlHandle {
5366    pub fn send_on_next_frame_begin(
5367        &self,
5368        mut values: &OnNextFrameBeginValues,
5369    ) -> Result<(), fidl::Error> {
5370        self.inner.send::<FlatlandOnNextFrameBeginRequest>(
5371            (values,),
5372            0,
5373            0x10f69a5cdeece84a,
5374            fidl::encoding::DynamicFlags::empty(),
5375        )
5376    }
5377
5378    pub fn send_on_frame_presented(
5379        &self,
5380        mut frame_presented_info: &fidl_fuchsia_scenic_scheduling::FramePresentedInfo,
5381    ) -> Result<(), fidl::Error> {
5382        self.inner.send::<FlatlandOnFramePresentedRequest>(
5383            (frame_presented_info,),
5384            0,
5385            0x56e43e1a5f30216d,
5386            fidl::encoding::DynamicFlags::empty(),
5387        )
5388    }
5389
5390    pub fn send_on_error(&self, mut error: FlatlandError) -> Result<(), fidl::Error> {
5391        self.inner.send::<FlatlandOnErrorRequest>(
5392            (error,),
5393            0,
5394            0x1ebf39e90cd8b8d,
5395            fidl::encoding::DynamicFlags::empty(),
5396        )
5397    }
5398}
5399
5400#[must_use = "FIDL methods require a response to be sent"]
5401#[derive(Debug)]
5402pub struct FlatlandReleaseViewportResponder {
5403    control_handle: std::mem::ManuallyDrop<FlatlandControlHandle>,
5404    tx_id: u32,
5405}
5406
5407/// Set the the channel to be shutdown (see [`FlatlandControlHandle::shutdown`])
5408/// if the responder is dropped without sending a response, so that the client
5409/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5410impl std::ops::Drop for FlatlandReleaseViewportResponder {
5411    fn drop(&mut self) {
5412        self.control_handle.shutdown();
5413        // Safety: drops once, never accessed again
5414        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5415    }
5416}
5417
5418impl fidl::endpoints::Responder for FlatlandReleaseViewportResponder {
5419    type ControlHandle = FlatlandControlHandle;
5420
5421    fn control_handle(&self) -> &FlatlandControlHandle {
5422        &self.control_handle
5423    }
5424
5425    fn drop_without_shutdown(mut self) {
5426        // Safety: drops once, never accessed again due to mem::forget
5427        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5428        // Prevent Drop from running (which would shut down the channel)
5429        std::mem::forget(self);
5430    }
5431}
5432
5433impl FlatlandReleaseViewportResponder {
5434    /// Sends a response to the FIDL transaction.
5435    ///
5436    /// Sets the channel to shutdown if an error occurs.
5437    pub fn send(
5438        self,
5439        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5440    ) -> Result<(), fidl::Error> {
5441        let _result = self.send_raw(token);
5442        if _result.is_err() {
5443            self.control_handle.shutdown();
5444        }
5445        self.drop_without_shutdown();
5446        _result
5447    }
5448
5449    /// Similar to "send" but does not shutdown the channel if an error occurs.
5450    pub fn send_no_shutdown_on_err(
5451        self,
5452        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5453    ) -> Result<(), fidl::Error> {
5454        let _result = self.send_raw(token);
5455        self.drop_without_shutdown();
5456        _result
5457    }
5458
5459    fn send_raw(
5460        &self,
5461        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5462    ) -> Result<(), fidl::Error> {
5463        self.control_handle.inner.send::<FlatlandReleaseViewportResponse>(
5464            (&mut token,),
5465            self.tx_id,
5466            0xbad474aeb5293f9,
5467            fidl::encoding::DynamicFlags::empty(),
5468        )
5469    }
5470}
5471
5472#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5473pub struct FlatlandDisplayMarker;
5474
5475impl fidl::endpoints::ProtocolMarker for FlatlandDisplayMarker {
5476    type Proxy = FlatlandDisplayProxy;
5477    type RequestStream = FlatlandDisplayRequestStream;
5478    #[cfg(target_os = "fuchsia")]
5479    type SynchronousProxy = FlatlandDisplaySynchronousProxy;
5480
5481    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.FlatlandDisplay";
5482}
5483impl fidl::endpoints::DiscoverableProtocolMarker for FlatlandDisplayMarker {}
5484
5485pub trait FlatlandDisplayProxyInterface: Send + Sync {
5486    fn r#set_content(
5487        &self,
5488        token: fidl_fuchsia_ui_views::ViewportCreationToken,
5489        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5490    ) -> Result<(), fidl::Error>;
5491    fn r#set_device_pixel_ratio(
5492        &self,
5493        device_pixel_ratio: &fidl_fuchsia_math::VecF,
5494    ) -> Result<(), fidl::Error>;
5495}
5496#[derive(Debug)]
5497#[cfg(target_os = "fuchsia")]
5498pub struct FlatlandDisplaySynchronousProxy {
5499    client: fidl::client::sync::Client,
5500}
5501
5502#[cfg(target_os = "fuchsia")]
5503impl fidl::endpoints::SynchronousProxy for FlatlandDisplaySynchronousProxy {
5504    type Proxy = FlatlandDisplayProxy;
5505    type Protocol = FlatlandDisplayMarker;
5506
5507    fn from_channel(inner: fidl::Channel) -> Self {
5508        Self::new(inner)
5509    }
5510
5511    fn into_channel(self) -> fidl::Channel {
5512        self.client.into_channel()
5513    }
5514
5515    fn as_channel(&self) -> &fidl::Channel {
5516        self.client.as_channel()
5517    }
5518}
5519
5520#[cfg(target_os = "fuchsia")]
5521impl FlatlandDisplaySynchronousProxy {
5522    pub fn new(channel: fidl::Channel) -> Self {
5523        let protocol_name = <FlatlandDisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5524        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5525    }
5526
5527    pub fn into_channel(self) -> fidl::Channel {
5528        self.client.into_channel()
5529    }
5530
5531    /// Waits until an event arrives and returns it. It is safe for other
5532    /// threads to make concurrent requests while waiting for an event.
5533    pub fn wait_for_event(
5534        &self,
5535        deadline: zx::MonotonicInstant,
5536    ) -> Result<FlatlandDisplayEvent, fidl::Error> {
5537        FlatlandDisplayEvent::decode(self.client.wait_for_event(deadline)?)
5538    }
5539
5540    pub fn r#set_content(
5541        &self,
5542        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5543        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5544    ) -> Result<(), fidl::Error> {
5545        self.client.send::<FlatlandDisplaySetContentRequest>(
5546            (&mut token, child_view_watcher),
5547            0x6748193a39918298,
5548            fidl::encoding::DynamicFlags::empty(),
5549        )
5550    }
5551
5552    /// Sets the ratio of display's physical pixels to device independent pixels that should be used
5553    /// for the tree of Flatland content that are attached to this display. See
5554    /// [`LayoutInfo.device_pixel_ratio`] for details.
5555    ///
5556    /// The default value is (1.0, 1.0). The valid values are 1.0 and above.
5557    pub fn r#set_device_pixel_ratio(
5558        &self,
5559        mut device_pixel_ratio: &fidl_fuchsia_math::VecF,
5560    ) -> Result<(), fidl::Error> {
5561        self.client.send::<FlatlandDisplaySetDevicePixelRatioRequest>(
5562            (device_pixel_ratio,),
5563            0x392c3e70cc0a81a4,
5564            fidl::encoding::DynamicFlags::empty(),
5565        )
5566    }
5567}
5568
5569#[cfg(target_os = "fuchsia")]
5570impl From<FlatlandDisplaySynchronousProxy> for zx::NullableHandle {
5571    fn from(value: FlatlandDisplaySynchronousProxy) -> Self {
5572        value.into_channel().into()
5573    }
5574}
5575
5576#[cfg(target_os = "fuchsia")]
5577impl From<fidl::Channel> for FlatlandDisplaySynchronousProxy {
5578    fn from(value: fidl::Channel) -> Self {
5579        Self::new(value)
5580    }
5581}
5582
5583#[cfg(target_os = "fuchsia")]
5584impl fidl::endpoints::FromClient for FlatlandDisplaySynchronousProxy {
5585    type Protocol = FlatlandDisplayMarker;
5586
5587    fn from_client(value: fidl::endpoints::ClientEnd<FlatlandDisplayMarker>) -> Self {
5588        Self::new(value.into_channel())
5589    }
5590}
5591
5592#[derive(Debug, Clone)]
5593pub struct FlatlandDisplayProxy {
5594    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5595}
5596
5597impl fidl::endpoints::Proxy for FlatlandDisplayProxy {
5598    type Protocol = FlatlandDisplayMarker;
5599
5600    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5601        Self::new(inner)
5602    }
5603
5604    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5605        self.client.into_channel().map_err(|client| Self { client })
5606    }
5607
5608    fn as_channel(&self) -> &::fidl::AsyncChannel {
5609        self.client.as_channel()
5610    }
5611}
5612
5613impl FlatlandDisplayProxy {
5614    /// Create a new Proxy for fuchsia.ui.composition/FlatlandDisplay.
5615    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5616        let protocol_name = <FlatlandDisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5617        Self { client: fidl::client::Client::new(channel, protocol_name) }
5618    }
5619
5620    /// Get a Stream of events from the remote end of the protocol.
5621    ///
5622    /// # Panics
5623    ///
5624    /// Panics if the event stream was already taken.
5625    pub fn take_event_stream(&self) -> FlatlandDisplayEventStream {
5626        FlatlandDisplayEventStream { event_receiver: self.client.take_event_receiver() }
5627    }
5628
5629    pub fn r#set_content(
5630        &self,
5631        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5632        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5633    ) -> Result<(), fidl::Error> {
5634        FlatlandDisplayProxyInterface::r#set_content(self, token, child_view_watcher)
5635    }
5636
5637    /// Sets the ratio of display's physical pixels to device independent pixels that should be used
5638    /// for the tree of Flatland content that are attached to this display. See
5639    /// [`LayoutInfo.device_pixel_ratio`] for details.
5640    ///
5641    /// The default value is (1.0, 1.0). The valid values are 1.0 and above.
5642    pub fn r#set_device_pixel_ratio(
5643        &self,
5644        mut device_pixel_ratio: &fidl_fuchsia_math::VecF,
5645    ) -> Result<(), fidl::Error> {
5646        FlatlandDisplayProxyInterface::r#set_device_pixel_ratio(self, device_pixel_ratio)
5647    }
5648}
5649
5650impl FlatlandDisplayProxyInterface for FlatlandDisplayProxy {
5651    fn r#set_content(
5652        &self,
5653        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5654        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5655    ) -> Result<(), fidl::Error> {
5656        self.client.send::<FlatlandDisplaySetContentRequest>(
5657            (&mut token, child_view_watcher),
5658            0x6748193a39918298,
5659            fidl::encoding::DynamicFlags::empty(),
5660        )
5661    }
5662
5663    fn r#set_device_pixel_ratio(
5664        &self,
5665        mut device_pixel_ratio: &fidl_fuchsia_math::VecF,
5666    ) -> Result<(), fidl::Error> {
5667        self.client.send::<FlatlandDisplaySetDevicePixelRatioRequest>(
5668            (device_pixel_ratio,),
5669            0x392c3e70cc0a81a4,
5670            fidl::encoding::DynamicFlags::empty(),
5671        )
5672    }
5673}
5674
5675pub struct FlatlandDisplayEventStream {
5676    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5677}
5678
5679impl std::marker::Unpin for FlatlandDisplayEventStream {}
5680
5681impl futures::stream::FusedStream for FlatlandDisplayEventStream {
5682    fn is_terminated(&self) -> bool {
5683        self.event_receiver.is_terminated()
5684    }
5685}
5686
5687impl futures::Stream for FlatlandDisplayEventStream {
5688    type Item = Result<FlatlandDisplayEvent, fidl::Error>;
5689
5690    fn poll_next(
5691        mut self: std::pin::Pin<&mut Self>,
5692        cx: &mut std::task::Context<'_>,
5693    ) -> std::task::Poll<Option<Self::Item>> {
5694        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5695            &mut self.event_receiver,
5696            cx
5697        )?) {
5698            Some(buf) => std::task::Poll::Ready(Some(FlatlandDisplayEvent::decode(buf))),
5699            None => std::task::Poll::Ready(None),
5700        }
5701    }
5702}
5703
5704#[derive(Debug)]
5705pub enum FlatlandDisplayEvent {}
5706
5707impl FlatlandDisplayEvent {
5708    /// Decodes a message buffer as a [`FlatlandDisplayEvent`].
5709    fn decode(
5710        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5711    ) -> Result<FlatlandDisplayEvent, fidl::Error> {
5712        let (bytes, _handles) = buf.split_mut();
5713        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5714        debug_assert_eq!(tx_header.tx_id, 0);
5715        match tx_header.ordinal {
5716            _ => Err(fidl::Error::UnknownOrdinal {
5717                ordinal: tx_header.ordinal,
5718                protocol_name:
5719                    <FlatlandDisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5720            }),
5721        }
5722    }
5723}
5724
5725/// A Stream of incoming requests for fuchsia.ui.composition/FlatlandDisplay.
5726pub struct FlatlandDisplayRequestStream {
5727    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5728    is_terminated: bool,
5729}
5730
5731impl std::marker::Unpin for FlatlandDisplayRequestStream {}
5732
5733impl futures::stream::FusedStream for FlatlandDisplayRequestStream {
5734    fn is_terminated(&self) -> bool {
5735        self.is_terminated
5736    }
5737}
5738
5739impl fidl::endpoints::RequestStream for FlatlandDisplayRequestStream {
5740    type Protocol = FlatlandDisplayMarker;
5741    type ControlHandle = FlatlandDisplayControlHandle;
5742
5743    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5744        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5745    }
5746
5747    fn control_handle(&self) -> Self::ControlHandle {
5748        FlatlandDisplayControlHandle { inner: self.inner.clone() }
5749    }
5750
5751    fn into_inner(
5752        self,
5753    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5754    {
5755        (self.inner, self.is_terminated)
5756    }
5757
5758    fn from_inner(
5759        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5760        is_terminated: bool,
5761    ) -> Self {
5762        Self { inner, is_terminated }
5763    }
5764}
5765
5766impl futures::Stream for FlatlandDisplayRequestStream {
5767    type Item = Result<FlatlandDisplayRequest, fidl::Error>;
5768
5769    fn poll_next(
5770        mut self: std::pin::Pin<&mut Self>,
5771        cx: &mut std::task::Context<'_>,
5772    ) -> std::task::Poll<Option<Self::Item>> {
5773        let this = &mut *self;
5774        if this.inner.check_shutdown(cx) {
5775            this.is_terminated = true;
5776            return std::task::Poll::Ready(None);
5777        }
5778        if this.is_terminated {
5779            panic!("polled FlatlandDisplayRequestStream after completion");
5780        }
5781        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5782            |bytes, handles| {
5783                match this.inner.channel().read_etc(cx, bytes, handles) {
5784                    std::task::Poll::Ready(Ok(())) => {}
5785                    std::task::Poll::Pending => return std::task::Poll::Pending,
5786                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5787                        this.is_terminated = true;
5788                        return std::task::Poll::Ready(None);
5789                    }
5790                    std::task::Poll::Ready(Err(e)) => {
5791                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5792                            e.into(),
5793                        ))));
5794                    }
5795                }
5796
5797                // A message has been received from the channel
5798                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5799
5800                std::task::Poll::Ready(Some(match header.ordinal {
5801                    0x6748193a39918298 => {
5802                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5803                        let mut req = fidl::new_empty!(
5804                            FlatlandDisplaySetContentRequest,
5805                            fidl::encoding::DefaultFuchsiaResourceDialect
5806                        );
5807                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandDisplaySetContentRequest>(&header, _body_bytes, handles, &mut req)?;
5808                        let control_handle =
5809                            FlatlandDisplayControlHandle { inner: this.inner.clone() };
5810                        Ok(FlatlandDisplayRequest::SetContent {
5811                            token: req.token,
5812                            child_view_watcher: req.child_view_watcher,
5813
5814                            control_handle,
5815                        })
5816                    }
5817                    0x392c3e70cc0a81a4 => {
5818                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5819                        let mut req = fidl::new_empty!(
5820                            FlatlandDisplaySetDevicePixelRatioRequest,
5821                            fidl::encoding::DefaultFuchsiaResourceDialect
5822                        );
5823                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandDisplaySetDevicePixelRatioRequest>(&header, _body_bytes, handles, &mut req)?;
5824                        let control_handle =
5825                            FlatlandDisplayControlHandle { inner: this.inner.clone() };
5826                        Ok(FlatlandDisplayRequest::SetDevicePixelRatio {
5827                            device_pixel_ratio: req.device_pixel_ratio,
5828
5829                            control_handle,
5830                        })
5831                    }
5832                    _ => Err(fidl::Error::UnknownOrdinal {
5833                        ordinal: header.ordinal,
5834                        protocol_name:
5835                            <FlatlandDisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5836                    }),
5837                }))
5838            },
5839        )
5840    }
5841}
5842
5843/// This API connects to the singleton "primary display", and allows a tree of Flatland content to
5844/// be attached underneath.  Only one FlatlandDisplay client connection is allowed at one time.
5845#[derive(Debug)]
5846pub enum FlatlandDisplayRequest {
5847    SetContent {
5848        token: fidl_fuchsia_ui_views::ViewportCreationToken,
5849        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5850        control_handle: FlatlandDisplayControlHandle,
5851    },
5852    /// Sets the ratio of display's physical pixels to device independent pixels that should be used
5853    /// for the tree of Flatland content that are attached to this display. See
5854    /// [`LayoutInfo.device_pixel_ratio`] for details.
5855    ///
5856    /// The default value is (1.0, 1.0). The valid values are 1.0 and above.
5857    SetDevicePixelRatio {
5858        device_pixel_ratio: fidl_fuchsia_math::VecF,
5859        control_handle: FlatlandDisplayControlHandle,
5860    },
5861}
5862
5863impl FlatlandDisplayRequest {
5864    #[allow(irrefutable_let_patterns)]
5865    pub fn into_set_content(
5866        self,
5867    ) -> Option<(
5868        fidl_fuchsia_ui_views::ViewportCreationToken,
5869        fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5870        FlatlandDisplayControlHandle,
5871    )> {
5872        if let FlatlandDisplayRequest::SetContent { token, child_view_watcher, control_handle } =
5873            self
5874        {
5875            Some((token, child_view_watcher, control_handle))
5876        } else {
5877            None
5878        }
5879    }
5880
5881    #[allow(irrefutable_let_patterns)]
5882    pub fn into_set_device_pixel_ratio(
5883        self,
5884    ) -> Option<(fidl_fuchsia_math::VecF, FlatlandDisplayControlHandle)> {
5885        if let FlatlandDisplayRequest::SetDevicePixelRatio { device_pixel_ratio, control_handle } =
5886            self
5887        {
5888            Some((device_pixel_ratio, control_handle))
5889        } else {
5890            None
5891        }
5892    }
5893
5894    /// Name of the method defined in FIDL
5895    pub fn method_name(&self) -> &'static str {
5896        match *self {
5897            FlatlandDisplayRequest::SetContent { .. } => "set_content",
5898            FlatlandDisplayRequest::SetDevicePixelRatio { .. } => "set_device_pixel_ratio",
5899        }
5900    }
5901}
5902
5903#[derive(Debug, Clone)]
5904pub struct FlatlandDisplayControlHandle {
5905    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5906}
5907
5908impl fidl::endpoints::ControlHandle for FlatlandDisplayControlHandle {
5909    fn shutdown(&self) {
5910        self.inner.shutdown()
5911    }
5912
5913    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5914        self.inner.shutdown_with_epitaph(status)
5915    }
5916
5917    fn is_closed(&self) -> bool {
5918        self.inner.channel().is_closed()
5919    }
5920    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5921        self.inner.channel().on_closed()
5922    }
5923
5924    #[cfg(target_os = "fuchsia")]
5925    fn signal_peer(
5926        &self,
5927        clear_mask: zx::Signals,
5928        set_mask: zx::Signals,
5929    ) -> Result<(), zx_status::Status> {
5930        use fidl::Peered;
5931        self.inner.channel().signal_peer(clear_mask, set_mask)
5932    }
5933}
5934
5935impl FlatlandDisplayControlHandle {}
5936
5937#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5938pub struct ParentViewportWatcherMarker;
5939
5940impl fidl::endpoints::ProtocolMarker for ParentViewportWatcherMarker {
5941    type Proxy = ParentViewportWatcherProxy;
5942    type RequestStream = ParentViewportWatcherRequestStream;
5943    #[cfg(target_os = "fuchsia")]
5944    type SynchronousProxy = ParentViewportWatcherSynchronousProxy;
5945
5946    const DEBUG_NAME: &'static str = "(anonymous) ParentViewportWatcher";
5947}
5948
5949pub trait ParentViewportWatcherProxyInterface: Send + Sync {
5950    type GetLayoutResponseFut: std::future::Future<Output = Result<LayoutInfo, fidl::Error>> + Send;
5951    fn r#get_layout(&self) -> Self::GetLayoutResponseFut;
5952    type GetStatusResponseFut: std::future::Future<Output = Result<ParentViewportStatus, fidl::Error>>
5953        + Send;
5954    fn r#get_status(&self) -> Self::GetStatusResponseFut;
5955}
5956#[derive(Debug)]
5957#[cfg(target_os = "fuchsia")]
5958pub struct ParentViewportWatcherSynchronousProxy {
5959    client: fidl::client::sync::Client,
5960}
5961
5962#[cfg(target_os = "fuchsia")]
5963impl fidl::endpoints::SynchronousProxy for ParentViewportWatcherSynchronousProxy {
5964    type Proxy = ParentViewportWatcherProxy;
5965    type Protocol = ParentViewportWatcherMarker;
5966
5967    fn from_channel(inner: fidl::Channel) -> Self {
5968        Self::new(inner)
5969    }
5970
5971    fn into_channel(self) -> fidl::Channel {
5972        self.client.into_channel()
5973    }
5974
5975    fn as_channel(&self) -> &fidl::Channel {
5976        self.client.as_channel()
5977    }
5978}
5979
5980#[cfg(target_os = "fuchsia")]
5981impl ParentViewportWatcherSynchronousProxy {
5982    pub fn new(channel: fidl::Channel) -> Self {
5983        let protocol_name =
5984            <ParentViewportWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5985        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5986    }
5987
5988    pub fn into_channel(self) -> fidl::Channel {
5989        self.client.into_channel()
5990    }
5991
5992    /// Waits until an event arrives and returns it. It is safe for other
5993    /// threads to make concurrent requests while waiting for an event.
5994    pub fn wait_for_event(
5995        &self,
5996        deadline: zx::MonotonicInstant,
5997    ) -> Result<ParentViewportWatcherEvent, fidl::Error> {
5998        ParentViewportWatcherEvent::decode(self.client.wait_for_event(deadline)?)
5999    }
6000
6001    /// A hanging get for receiving layout information. Clients may receive layout information
6002    /// before the ParentViewportWatcher operation has been presented. This allows children to
6003    /// layout their content before their first call to [`Present`]. In transition cases where two
6004    /// ParentViewportWatcher channels exist at the same time, both protocol instances will be
6005    /// receiving different layout information.
6006    ///
6007    /// This hanging get will only fire when the LayoutInfo is different than the previously
6008    /// returned LayoutInfo. Note that, since LayoutInfo is a table, only some fields may have
6009    /// changed.
6010    ///
6011    /// It is invalid to call `GetLayout` while a previous call is still pending. Doing so will
6012    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6013    /// closed.
6014    pub fn r#get_layout(
6015        &self,
6016        ___deadline: zx::MonotonicInstant,
6017    ) -> Result<LayoutInfo, fidl::Error> {
6018        let _response = self
6019            .client
6020            .send_query::<fidl::encoding::EmptyPayload, ParentViewportWatcherGetLayoutResponse>(
6021                (),
6022                0x3cbe5d9638e032,
6023                fidl::encoding::DynamicFlags::empty(),
6024                ___deadline,
6025            )?;
6026        Ok(_response.info)
6027    }
6028
6029    /// A hanging get for receiving the status of the parent Viewport. This provides global
6030    /// connectivity information to the child.
6031    ///
6032    /// This hanging get will only fire when the ParentViewportStatus is different than the
6033    /// previously returned ParentViewportStatus.
6034    ///
6035    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
6036    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6037    /// closed.
6038    pub fn r#get_status(
6039        &self,
6040        ___deadline: zx::MonotonicInstant,
6041    ) -> Result<ParentViewportStatus, fidl::Error> {
6042        let _response = self
6043            .client
6044            .send_query::<fidl::encoding::EmptyPayload, ParentViewportWatcherGetStatusResponse>(
6045                (),
6046                0x7caa022f050d9ea6,
6047                fidl::encoding::DynamicFlags::empty(),
6048                ___deadline,
6049            )?;
6050        Ok(_response.status)
6051    }
6052}
6053
6054#[cfg(target_os = "fuchsia")]
6055impl From<ParentViewportWatcherSynchronousProxy> for zx::NullableHandle {
6056    fn from(value: ParentViewportWatcherSynchronousProxy) -> Self {
6057        value.into_channel().into()
6058    }
6059}
6060
6061#[cfg(target_os = "fuchsia")]
6062impl From<fidl::Channel> for ParentViewportWatcherSynchronousProxy {
6063    fn from(value: fidl::Channel) -> Self {
6064        Self::new(value)
6065    }
6066}
6067
6068#[cfg(target_os = "fuchsia")]
6069impl fidl::endpoints::FromClient for ParentViewportWatcherSynchronousProxy {
6070    type Protocol = ParentViewportWatcherMarker;
6071
6072    fn from_client(value: fidl::endpoints::ClientEnd<ParentViewportWatcherMarker>) -> Self {
6073        Self::new(value.into_channel())
6074    }
6075}
6076
6077#[derive(Debug, Clone)]
6078pub struct ParentViewportWatcherProxy {
6079    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6080}
6081
6082impl fidl::endpoints::Proxy for ParentViewportWatcherProxy {
6083    type Protocol = ParentViewportWatcherMarker;
6084
6085    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6086        Self::new(inner)
6087    }
6088
6089    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6090        self.client.into_channel().map_err(|client| Self { client })
6091    }
6092
6093    fn as_channel(&self) -> &::fidl::AsyncChannel {
6094        self.client.as_channel()
6095    }
6096}
6097
6098impl ParentViewportWatcherProxy {
6099    /// Create a new Proxy for fuchsia.ui.composition/ParentViewportWatcher.
6100    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6101        let protocol_name =
6102            <ParentViewportWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6103        Self { client: fidl::client::Client::new(channel, protocol_name) }
6104    }
6105
6106    /// Get a Stream of events from the remote end of the protocol.
6107    ///
6108    /// # Panics
6109    ///
6110    /// Panics if the event stream was already taken.
6111    pub fn take_event_stream(&self) -> ParentViewportWatcherEventStream {
6112        ParentViewportWatcherEventStream { event_receiver: self.client.take_event_receiver() }
6113    }
6114
6115    /// A hanging get for receiving layout information. Clients may receive layout information
6116    /// before the ParentViewportWatcher operation has been presented. This allows children to
6117    /// layout their content before their first call to [`Present`]. In transition cases where two
6118    /// ParentViewportWatcher channels exist at the same time, both protocol instances will be
6119    /// receiving different layout information.
6120    ///
6121    /// This hanging get will only fire when the LayoutInfo is different than the previously
6122    /// returned LayoutInfo. Note that, since LayoutInfo is a table, only some fields may have
6123    /// changed.
6124    ///
6125    /// It is invalid to call `GetLayout` while a previous call is still pending. Doing so will
6126    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6127    /// closed.
6128    pub fn r#get_layout(
6129        &self,
6130    ) -> fidl::client::QueryResponseFut<LayoutInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
6131    {
6132        ParentViewportWatcherProxyInterface::r#get_layout(self)
6133    }
6134
6135    /// A hanging get for receiving the status of the parent Viewport. This provides global
6136    /// connectivity information to the child.
6137    ///
6138    /// This hanging get will only fire when the ParentViewportStatus is different than the
6139    /// previously returned ParentViewportStatus.
6140    ///
6141    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
6142    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6143    /// closed.
6144    pub fn r#get_status(
6145        &self,
6146    ) -> fidl::client::QueryResponseFut<
6147        ParentViewportStatus,
6148        fidl::encoding::DefaultFuchsiaResourceDialect,
6149    > {
6150        ParentViewportWatcherProxyInterface::r#get_status(self)
6151    }
6152}
6153
6154impl ParentViewportWatcherProxyInterface for ParentViewportWatcherProxy {
6155    type GetLayoutResponseFut =
6156        fidl::client::QueryResponseFut<LayoutInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
6157    fn r#get_layout(&self) -> Self::GetLayoutResponseFut {
6158        fn _decode(
6159            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6160        ) -> Result<LayoutInfo, fidl::Error> {
6161            let _response = fidl::client::decode_transaction_body::<
6162                ParentViewportWatcherGetLayoutResponse,
6163                fidl::encoding::DefaultFuchsiaResourceDialect,
6164                0x3cbe5d9638e032,
6165            >(_buf?)?;
6166            Ok(_response.info)
6167        }
6168        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, LayoutInfo>(
6169            (),
6170            0x3cbe5d9638e032,
6171            fidl::encoding::DynamicFlags::empty(),
6172            _decode,
6173        )
6174    }
6175
6176    type GetStatusResponseFut = fidl::client::QueryResponseFut<
6177        ParentViewportStatus,
6178        fidl::encoding::DefaultFuchsiaResourceDialect,
6179    >;
6180    fn r#get_status(&self) -> Self::GetStatusResponseFut {
6181        fn _decode(
6182            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6183        ) -> Result<ParentViewportStatus, fidl::Error> {
6184            let _response = fidl::client::decode_transaction_body::<
6185                ParentViewportWatcherGetStatusResponse,
6186                fidl::encoding::DefaultFuchsiaResourceDialect,
6187                0x7caa022f050d9ea6,
6188            >(_buf?)?;
6189            Ok(_response.status)
6190        }
6191        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ParentViewportStatus>(
6192            (),
6193            0x7caa022f050d9ea6,
6194            fidl::encoding::DynamicFlags::empty(),
6195            _decode,
6196        )
6197    }
6198}
6199
6200pub struct ParentViewportWatcherEventStream {
6201    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6202}
6203
6204impl std::marker::Unpin for ParentViewportWatcherEventStream {}
6205
6206impl futures::stream::FusedStream for ParentViewportWatcherEventStream {
6207    fn is_terminated(&self) -> bool {
6208        self.event_receiver.is_terminated()
6209    }
6210}
6211
6212impl futures::Stream for ParentViewportWatcherEventStream {
6213    type Item = Result<ParentViewportWatcherEvent, fidl::Error>;
6214
6215    fn poll_next(
6216        mut self: std::pin::Pin<&mut Self>,
6217        cx: &mut std::task::Context<'_>,
6218    ) -> std::task::Poll<Option<Self::Item>> {
6219        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6220            &mut self.event_receiver,
6221            cx
6222        )?) {
6223            Some(buf) => std::task::Poll::Ready(Some(ParentViewportWatcherEvent::decode(buf))),
6224            None => std::task::Poll::Ready(None),
6225        }
6226    }
6227}
6228
6229#[derive(Debug)]
6230pub enum ParentViewportWatcherEvent {}
6231
6232impl ParentViewportWatcherEvent {
6233    /// Decodes a message buffer as a [`ParentViewportWatcherEvent`].
6234    fn decode(
6235        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6236    ) -> Result<ParentViewportWatcherEvent, fidl::Error> {
6237        let (bytes, _handles) = buf.split_mut();
6238        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6239        debug_assert_eq!(tx_header.tx_id, 0);
6240        match tx_header.ordinal {
6241            _ => Err(fidl::Error::UnknownOrdinal {
6242                ordinal: tx_header.ordinal,
6243                protocol_name:
6244                    <ParentViewportWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6245            }),
6246        }
6247    }
6248}
6249
6250/// A Stream of incoming requests for fuchsia.ui.composition/ParentViewportWatcher.
6251pub struct ParentViewportWatcherRequestStream {
6252    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6253    is_terminated: bool,
6254}
6255
6256impl std::marker::Unpin for ParentViewportWatcherRequestStream {}
6257
6258impl futures::stream::FusedStream for ParentViewportWatcherRequestStream {
6259    fn is_terminated(&self) -> bool {
6260        self.is_terminated
6261    }
6262}
6263
6264impl fidl::endpoints::RequestStream for ParentViewportWatcherRequestStream {
6265    type Protocol = ParentViewportWatcherMarker;
6266    type ControlHandle = ParentViewportWatcherControlHandle;
6267
6268    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6269        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6270    }
6271
6272    fn control_handle(&self) -> Self::ControlHandle {
6273        ParentViewportWatcherControlHandle { inner: self.inner.clone() }
6274    }
6275
6276    fn into_inner(
6277        self,
6278    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6279    {
6280        (self.inner, self.is_terminated)
6281    }
6282
6283    fn from_inner(
6284        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6285        is_terminated: bool,
6286    ) -> Self {
6287        Self { inner, is_terminated }
6288    }
6289}
6290
6291impl futures::Stream for ParentViewportWatcherRequestStream {
6292    type Item = Result<ParentViewportWatcherRequest, fidl::Error>;
6293
6294    fn poll_next(
6295        mut self: std::pin::Pin<&mut Self>,
6296        cx: &mut std::task::Context<'_>,
6297    ) -> std::task::Poll<Option<Self::Item>> {
6298        let this = &mut *self;
6299        if this.inner.check_shutdown(cx) {
6300            this.is_terminated = true;
6301            return std::task::Poll::Ready(None);
6302        }
6303        if this.is_terminated {
6304            panic!("polled ParentViewportWatcherRequestStream after completion");
6305        }
6306        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6307            |bytes, handles| {
6308                match this.inner.channel().read_etc(cx, bytes, handles) {
6309                    std::task::Poll::Ready(Ok(())) => {}
6310                    std::task::Poll::Pending => return std::task::Poll::Pending,
6311                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6312                        this.is_terminated = true;
6313                        return std::task::Poll::Ready(None);
6314                    }
6315                    std::task::Poll::Ready(Err(e)) => {
6316                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6317                            e.into(),
6318                        ))));
6319                    }
6320                }
6321
6322                // A message has been received from the channel
6323                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6324
6325                std::task::Poll::Ready(Some(match header.ordinal {
6326                0x3cbe5d9638e032 => {
6327                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6328                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
6329                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6330                    let control_handle = ParentViewportWatcherControlHandle {
6331                        inner: this.inner.clone(),
6332                    };
6333                    Ok(ParentViewportWatcherRequest::GetLayout {
6334                        responder: ParentViewportWatcherGetLayoutResponder {
6335                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6336                            tx_id: header.tx_id,
6337                        },
6338                    })
6339                }
6340                0x7caa022f050d9ea6 => {
6341                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6342                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
6343                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6344                    let control_handle = ParentViewportWatcherControlHandle {
6345                        inner: this.inner.clone(),
6346                    };
6347                    Ok(ParentViewportWatcherRequest::GetStatus {
6348                        responder: ParentViewportWatcherGetStatusResponder {
6349                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6350                            tx_id: header.tx_id,
6351                        },
6352                    })
6353                }
6354                _ => Err(fidl::Error::UnknownOrdinal {
6355                    ordinal: header.ordinal,
6356                    protocol_name: <ParentViewportWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6357                }),
6358            }))
6359            },
6360        )
6361    }
6362}
6363
6364/// A protocol that provides information about the parent Viewport attached to a Flatland instance's
6365/// sole View.  Although Flatland instances can have at most one view, it is possible to have
6366/// multiple ParentViewportWatchers during the brief transition period when replacing the instance's
6367/// View with another, e.g. via [`CreateView`].  During this period, certain updates may be
6368/// duplicated and sent to each ParentViewportWatcher connection.
6369///
6370/// A ParentViewportWatcher will remain connected as long as the corresponding parent Viewport
6371/// exists; the connection will also be closed if the parents's ViewportCreationToken is dropped
6372/// without using it to create a Viewport.
6373#[derive(Debug)]
6374pub enum ParentViewportWatcherRequest {
6375    /// A hanging get for receiving layout information. Clients may receive layout information
6376    /// before the ParentViewportWatcher operation has been presented. This allows children to
6377    /// layout their content before their first call to [`Present`]. In transition cases where two
6378    /// ParentViewportWatcher channels exist at the same time, both protocol instances will be
6379    /// receiving different layout information.
6380    ///
6381    /// This hanging get will only fire when the LayoutInfo is different than the previously
6382    /// returned LayoutInfo. Note that, since LayoutInfo is a table, only some fields may have
6383    /// changed.
6384    ///
6385    /// It is invalid to call `GetLayout` while a previous call is still pending. Doing so will
6386    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6387    /// closed.
6388    GetLayout { responder: ParentViewportWatcherGetLayoutResponder },
6389    /// A hanging get for receiving the status of the parent Viewport. This provides global
6390    /// connectivity information to the child.
6391    ///
6392    /// This hanging get will only fire when the ParentViewportStatus is different than the
6393    /// previously returned ParentViewportStatus.
6394    ///
6395    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
6396    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6397    /// closed.
6398    GetStatus { responder: ParentViewportWatcherGetStatusResponder },
6399}
6400
6401impl ParentViewportWatcherRequest {
6402    #[allow(irrefutable_let_patterns)]
6403    pub fn into_get_layout(self) -> Option<(ParentViewportWatcherGetLayoutResponder)> {
6404        if let ParentViewportWatcherRequest::GetLayout { responder } = self {
6405            Some((responder))
6406        } else {
6407            None
6408        }
6409    }
6410
6411    #[allow(irrefutable_let_patterns)]
6412    pub fn into_get_status(self) -> Option<(ParentViewportWatcherGetStatusResponder)> {
6413        if let ParentViewportWatcherRequest::GetStatus { responder } = self {
6414            Some((responder))
6415        } else {
6416            None
6417        }
6418    }
6419
6420    /// Name of the method defined in FIDL
6421    pub fn method_name(&self) -> &'static str {
6422        match *self {
6423            ParentViewportWatcherRequest::GetLayout { .. } => "get_layout",
6424            ParentViewportWatcherRequest::GetStatus { .. } => "get_status",
6425        }
6426    }
6427}
6428
6429#[derive(Debug, Clone)]
6430pub struct ParentViewportWatcherControlHandle {
6431    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6432}
6433
6434impl fidl::endpoints::ControlHandle for ParentViewportWatcherControlHandle {
6435    fn shutdown(&self) {
6436        self.inner.shutdown()
6437    }
6438
6439    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6440        self.inner.shutdown_with_epitaph(status)
6441    }
6442
6443    fn is_closed(&self) -> bool {
6444        self.inner.channel().is_closed()
6445    }
6446    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6447        self.inner.channel().on_closed()
6448    }
6449
6450    #[cfg(target_os = "fuchsia")]
6451    fn signal_peer(
6452        &self,
6453        clear_mask: zx::Signals,
6454        set_mask: zx::Signals,
6455    ) -> Result<(), zx_status::Status> {
6456        use fidl::Peered;
6457        self.inner.channel().signal_peer(clear_mask, set_mask)
6458    }
6459}
6460
6461impl ParentViewportWatcherControlHandle {}
6462
6463#[must_use = "FIDL methods require a response to be sent"]
6464#[derive(Debug)]
6465pub struct ParentViewportWatcherGetLayoutResponder {
6466    control_handle: std::mem::ManuallyDrop<ParentViewportWatcherControlHandle>,
6467    tx_id: u32,
6468}
6469
6470/// Set the the channel to be shutdown (see [`ParentViewportWatcherControlHandle::shutdown`])
6471/// if the responder is dropped without sending a response, so that the client
6472/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6473impl std::ops::Drop for ParentViewportWatcherGetLayoutResponder {
6474    fn drop(&mut self) {
6475        self.control_handle.shutdown();
6476        // Safety: drops once, never accessed again
6477        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6478    }
6479}
6480
6481impl fidl::endpoints::Responder for ParentViewportWatcherGetLayoutResponder {
6482    type ControlHandle = ParentViewportWatcherControlHandle;
6483
6484    fn control_handle(&self) -> &ParentViewportWatcherControlHandle {
6485        &self.control_handle
6486    }
6487
6488    fn drop_without_shutdown(mut self) {
6489        // Safety: drops once, never accessed again due to mem::forget
6490        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6491        // Prevent Drop from running (which would shut down the channel)
6492        std::mem::forget(self);
6493    }
6494}
6495
6496impl ParentViewportWatcherGetLayoutResponder {
6497    /// Sends a response to the FIDL transaction.
6498    ///
6499    /// Sets the channel to shutdown if an error occurs.
6500    pub fn send(self, mut info: &LayoutInfo) -> Result<(), fidl::Error> {
6501        let _result = self.send_raw(info);
6502        if _result.is_err() {
6503            self.control_handle.shutdown();
6504        }
6505        self.drop_without_shutdown();
6506        _result
6507    }
6508
6509    /// Similar to "send" but does not shutdown the channel if an error occurs.
6510    pub fn send_no_shutdown_on_err(self, mut info: &LayoutInfo) -> Result<(), fidl::Error> {
6511        let _result = self.send_raw(info);
6512        self.drop_without_shutdown();
6513        _result
6514    }
6515
6516    fn send_raw(&self, mut info: &LayoutInfo) -> Result<(), fidl::Error> {
6517        self.control_handle.inner.send::<ParentViewportWatcherGetLayoutResponse>(
6518            (info,),
6519            self.tx_id,
6520            0x3cbe5d9638e032,
6521            fidl::encoding::DynamicFlags::empty(),
6522        )
6523    }
6524}
6525
6526#[must_use = "FIDL methods require a response to be sent"]
6527#[derive(Debug)]
6528pub struct ParentViewportWatcherGetStatusResponder {
6529    control_handle: std::mem::ManuallyDrop<ParentViewportWatcherControlHandle>,
6530    tx_id: u32,
6531}
6532
6533/// Set the the channel to be shutdown (see [`ParentViewportWatcherControlHandle::shutdown`])
6534/// if the responder is dropped without sending a response, so that the client
6535/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6536impl std::ops::Drop for ParentViewportWatcherGetStatusResponder {
6537    fn drop(&mut self) {
6538        self.control_handle.shutdown();
6539        // Safety: drops once, never accessed again
6540        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6541    }
6542}
6543
6544impl fidl::endpoints::Responder for ParentViewportWatcherGetStatusResponder {
6545    type ControlHandle = ParentViewportWatcherControlHandle;
6546
6547    fn control_handle(&self) -> &ParentViewportWatcherControlHandle {
6548        &self.control_handle
6549    }
6550
6551    fn drop_without_shutdown(mut self) {
6552        // Safety: drops once, never accessed again due to mem::forget
6553        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6554        // Prevent Drop from running (which would shut down the channel)
6555        std::mem::forget(self);
6556    }
6557}
6558
6559impl ParentViewportWatcherGetStatusResponder {
6560    /// Sends a response to the FIDL transaction.
6561    ///
6562    /// Sets the channel to shutdown if an error occurs.
6563    pub fn send(self, mut status: ParentViewportStatus) -> Result<(), fidl::Error> {
6564        let _result = self.send_raw(status);
6565        if _result.is_err() {
6566            self.control_handle.shutdown();
6567        }
6568        self.drop_without_shutdown();
6569        _result
6570    }
6571
6572    /// Similar to "send" but does not shutdown the channel if an error occurs.
6573    pub fn send_no_shutdown_on_err(
6574        self,
6575        mut status: ParentViewportStatus,
6576    ) -> Result<(), fidl::Error> {
6577        let _result = self.send_raw(status);
6578        self.drop_without_shutdown();
6579        _result
6580    }
6581
6582    fn send_raw(&self, mut status: ParentViewportStatus) -> Result<(), fidl::Error> {
6583        self.control_handle.inner.send::<ParentViewportWatcherGetStatusResponse>(
6584            (status,),
6585            self.tx_id,
6586            0x7caa022f050d9ea6,
6587            fidl::encoding::DynamicFlags::empty(),
6588        )
6589    }
6590}
6591
6592#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6593pub struct ScreenCaptureMarker;
6594
6595impl fidl::endpoints::ProtocolMarker for ScreenCaptureMarker {
6596    type Proxy = ScreenCaptureProxy;
6597    type RequestStream = ScreenCaptureRequestStream;
6598    #[cfg(target_os = "fuchsia")]
6599    type SynchronousProxy = ScreenCaptureSynchronousProxy;
6600
6601    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.ScreenCapture";
6602}
6603impl fidl::endpoints::DiscoverableProtocolMarker for ScreenCaptureMarker {}
6604pub type ScreenCaptureConfigureResult = Result<(), ScreenCaptureError>;
6605pub type ScreenCaptureGetNextFrameResult = Result<FrameInfo, ScreenCaptureError>;
6606pub type ScreenCaptureReleaseFrameResult = Result<(), ScreenCaptureError>;
6607
6608pub trait ScreenCaptureProxyInterface: Send + Sync {
6609    type ConfigureResponseFut: std::future::Future<Output = Result<ScreenCaptureConfigureResult, fidl::Error>>
6610        + Send;
6611    fn r#configure(&self, payload: ScreenCaptureConfig) -> Self::ConfigureResponseFut;
6612    type GetNextFrameResponseFut: std::future::Future<Output = Result<ScreenCaptureGetNextFrameResult, fidl::Error>>
6613        + Send;
6614    fn r#get_next_frame(&self, payload: GetNextFrameArgs) -> Self::GetNextFrameResponseFut;
6615    type ReleaseFrameResponseFut: std::future::Future<Output = Result<ScreenCaptureReleaseFrameResult, fidl::Error>>
6616        + Send;
6617    fn r#release_frame(&self, buffer_id: u32) -> Self::ReleaseFrameResponseFut;
6618}
6619#[derive(Debug)]
6620#[cfg(target_os = "fuchsia")]
6621pub struct ScreenCaptureSynchronousProxy {
6622    client: fidl::client::sync::Client,
6623}
6624
6625#[cfg(target_os = "fuchsia")]
6626impl fidl::endpoints::SynchronousProxy for ScreenCaptureSynchronousProxy {
6627    type Proxy = ScreenCaptureProxy;
6628    type Protocol = ScreenCaptureMarker;
6629
6630    fn from_channel(inner: fidl::Channel) -> Self {
6631        Self::new(inner)
6632    }
6633
6634    fn into_channel(self) -> fidl::Channel {
6635        self.client.into_channel()
6636    }
6637
6638    fn as_channel(&self) -> &fidl::Channel {
6639        self.client.as_channel()
6640    }
6641}
6642
6643#[cfg(target_os = "fuchsia")]
6644impl ScreenCaptureSynchronousProxy {
6645    pub fn new(channel: fidl::Channel) -> Self {
6646        let protocol_name = <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6647        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6648    }
6649
6650    pub fn into_channel(self) -> fidl::Channel {
6651        self.client.into_channel()
6652    }
6653
6654    /// Waits until an event arrives and returns it. It is safe for other
6655    /// threads to make concurrent requests while waiting for an event.
6656    pub fn wait_for_event(
6657        &self,
6658        deadline: zx::MonotonicInstant,
6659    ) -> Result<ScreenCaptureEvent, fidl::Error> {
6660        ScreenCaptureEvent::decode(self.client.wait_for_event(deadline)?)
6661    }
6662
6663    /// Clients should first use the Allocator protocol to register a
6664    /// BufferCollection. This function will fail with BAD_OPERATION unless all clients of the
6665    /// BufferCollection have set their constraints.
6666    ///
6667    /// Afterwards, clients should create and configure the images that will
6668    /// eventually be rendered to using this method. All the buffers in the
6669    /// collection from 0 to (buffer_count-1) may be used for screen capture.
6670    ///
6671    /// Clients are responsible for determining the rotation of the display,
6672    /// and applying the corrective rotation. For instance, if the display is
6673    /// mounted 90 degrees clockwise (the "top" is on the right, when looking
6674    /// at the display), then the client should specify a 270 degree rotation
6675    /// to account for it.
6676    ///
6677    /// Similarly, the clients are responsible for specifying a buffer big
6678    /// enough for the rotated image. If the buffer is too small, a best effort
6679    /// attempt will be made to render the image.
6680    ///
6681    /// Finally, clients request the server to render the current screen to the
6682    /// shared buffers using [`GetNextFrame`].
6683    ///
6684    /// [`Configure`] can be called again with a new BufferCollectionImportToken
6685    /// if the client wishes to change any of the configuration settings. In
6686    /// this case all the buffers from the previous call to [`Configure`] will
6687    /// be released.
6688    pub fn r#configure(
6689        &self,
6690        mut payload: ScreenCaptureConfig,
6691        ___deadline: zx::MonotonicInstant,
6692    ) -> Result<ScreenCaptureConfigureResult, fidl::Error> {
6693        let _response = self.client.send_query::<ScreenCaptureConfig, fidl::encoding::ResultType<
6694            fidl::encoding::EmptyStruct,
6695            ScreenCaptureError,
6696        >>(
6697            &mut payload,
6698            0x3b6e5af1d294afd9,
6699            fidl::encoding::DynamicFlags::empty(),
6700            ___deadline,
6701        )?;
6702        Ok(_response.map(|x| x))
6703    }
6704
6705    /// Following a successful call to [`Configure`], clients can call
6706    /// GetNextFrame. This will populate a buffer with the most recent frame.
6707    ///
6708    /// Clients should wait on the zx::event they pass for successful
6709    /// completion of the screenshot. It is not guaranteed that the screenshot
6710    /// will be completed by the time this function returns.
6711    ///
6712    /// The requested image will be in the BufferCollection that the client set
6713    /// up in the VMO at the index specified by buffer_id.
6714    ///
6715    /// When ScreenCapture is used to provide a stream, the rate that the
6716    /// client calls GetNextFrame will drive the frame rate.
6717    ///
6718    /// Errors:
6719    /// BAD_OPERATION if Configure was not called, or not called successfully
6720    /// MISSING_ARGS if a required argument is not present
6721    /// BUFFER_FULL if all buffers in the BufferCollection are in use. In this case, ReleaseFrame
6722    /// must be called to make a buffer available before this function can be called successfully.
6723    pub fn r#get_next_frame(
6724        &self,
6725        mut payload: GetNextFrameArgs,
6726        ___deadline: zx::MonotonicInstant,
6727    ) -> Result<ScreenCaptureGetNextFrameResult, fidl::Error> {
6728        let _response = self.client.send_query::<
6729            GetNextFrameArgs,
6730            fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>,
6731        >(
6732            &mut payload,
6733            0x552c1580aab8c4a7,
6734            fidl::encoding::DynamicFlags::empty(),
6735            ___deadline,
6736        )?;
6737        Ok(_response.map(|x| x))
6738    }
6739
6740    /// Once the client no longer needs an image, they can call ReleaseFrame on
6741    /// the VMO index of the buffer so that the server can reuse it in the future.
6742    pub fn r#release_frame(
6743        &self,
6744        mut buffer_id: u32,
6745        ___deadline: zx::MonotonicInstant,
6746    ) -> Result<ScreenCaptureReleaseFrameResult, fidl::Error> {
6747        let _response =
6748            self.client.send_query::<ScreenCaptureReleaseFrameRequest, fidl::encoding::ResultType<
6749                fidl::encoding::EmptyStruct,
6750                ScreenCaptureError,
6751            >>(
6752                (buffer_id,),
6753                0x46704dce24e35950,
6754                fidl::encoding::DynamicFlags::empty(),
6755                ___deadline,
6756            )?;
6757        Ok(_response.map(|x| x))
6758    }
6759}
6760
6761#[cfg(target_os = "fuchsia")]
6762impl From<ScreenCaptureSynchronousProxy> for zx::NullableHandle {
6763    fn from(value: ScreenCaptureSynchronousProxy) -> Self {
6764        value.into_channel().into()
6765    }
6766}
6767
6768#[cfg(target_os = "fuchsia")]
6769impl From<fidl::Channel> for ScreenCaptureSynchronousProxy {
6770    fn from(value: fidl::Channel) -> Self {
6771        Self::new(value)
6772    }
6773}
6774
6775#[cfg(target_os = "fuchsia")]
6776impl fidl::endpoints::FromClient for ScreenCaptureSynchronousProxy {
6777    type Protocol = ScreenCaptureMarker;
6778
6779    fn from_client(value: fidl::endpoints::ClientEnd<ScreenCaptureMarker>) -> Self {
6780        Self::new(value.into_channel())
6781    }
6782}
6783
6784#[derive(Debug, Clone)]
6785pub struct ScreenCaptureProxy {
6786    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6787}
6788
6789impl fidl::endpoints::Proxy for ScreenCaptureProxy {
6790    type Protocol = ScreenCaptureMarker;
6791
6792    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6793        Self::new(inner)
6794    }
6795
6796    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6797        self.client.into_channel().map_err(|client| Self { client })
6798    }
6799
6800    fn as_channel(&self) -> &::fidl::AsyncChannel {
6801        self.client.as_channel()
6802    }
6803}
6804
6805impl ScreenCaptureProxy {
6806    /// Create a new Proxy for fuchsia.ui.composition/ScreenCapture.
6807    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6808        let protocol_name = <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6809        Self { client: fidl::client::Client::new(channel, protocol_name) }
6810    }
6811
6812    /// Get a Stream of events from the remote end of the protocol.
6813    ///
6814    /// # Panics
6815    ///
6816    /// Panics if the event stream was already taken.
6817    pub fn take_event_stream(&self) -> ScreenCaptureEventStream {
6818        ScreenCaptureEventStream { event_receiver: self.client.take_event_receiver() }
6819    }
6820
6821    /// Clients should first use the Allocator protocol to register a
6822    /// BufferCollection. This function will fail with BAD_OPERATION unless all clients of the
6823    /// BufferCollection have set their constraints.
6824    ///
6825    /// Afterwards, clients should create and configure the images that will
6826    /// eventually be rendered to using this method. All the buffers in the
6827    /// collection from 0 to (buffer_count-1) may be used for screen capture.
6828    ///
6829    /// Clients are responsible for determining the rotation of the display,
6830    /// and applying the corrective rotation. For instance, if the display is
6831    /// mounted 90 degrees clockwise (the "top" is on the right, when looking
6832    /// at the display), then the client should specify a 270 degree rotation
6833    /// to account for it.
6834    ///
6835    /// Similarly, the clients are responsible for specifying a buffer big
6836    /// enough for the rotated image. If the buffer is too small, a best effort
6837    /// attempt will be made to render the image.
6838    ///
6839    /// Finally, clients request the server to render the current screen to the
6840    /// shared buffers using [`GetNextFrame`].
6841    ///
6842    /// [`Configure`] can be called again with a new BufferCollectionImportToken
6843    /// if the client wishes to change any of the configuration settings. In
6844    /// this case all the buffers from the previous call to [`Configure`] will
6845    /// be released.
6846    pub fn r#configure(
6847        &self,
6848        mut payload: ScreenCaptureConfig,
6849    ) -> fidl::client::QueryResponseFut<
6850        ScreenCaptureConfigureResult,
6851        fidl::encoding::DefaultFuchsiaResourceDialect,
6852    > {
6853        ScreenCaptureProxyInterface::r#configure(self, payload)
6854    }
6855
6856    /// Following a successful call to [`Configure`], clients can call
6857    /// GetNextFrame. This will populate a buffer with the most recent frame.
6858    ///
6859    /// Clients should wait on the zx::event they pass for successful
6860    /// completion of the screenshot. It is not guaranteed that the screenshot
6861    /// will be completed by the time this function returns.
6862    ///
6863    /// The requested image will be in the BufferCollection that the client set
6864    /// up in the VMO at the index specified by buffer_id.
6865    ///
6866    /// When ScreenCapture is used to provide a stream, the rate that the
6867    /// client calls GetNextFrame will drive the frame rate.
6868    ///
6869    /// Errors:
6870    /// BAD_OPERATION if Configure was not called, or not called successfully
6871    /// MISSING_ARGS if a required argument is not present
6872    /// BUFFER_FULL if all buffers in the BufferCollection are in use. In this case, ReleaseFrame
6873    /// must be called to make a buffer available before this function can be called successfully.
6874    pub fn r#get_next_frame(
6875        &self,
6876        mut payload: GetNextFrameArgs,
6877    ) -> fidl::client::QueryResponseFut<
6878        ScreenCaptureGetNextFrameResult,
6879        fidl::encoding::DefaultFuchsiaResourceDialect,
6880    > {
6881        ScreenCaptureProxyInterface::r#get_next_frame(self, payload)
6882    }
6883
6884    /// Once the client no longer needs an image, they can call ReleaseFrame on
6885    /// the VMO index of the buffer so that the server can reuse it in the future.
6886    pub fn r#release_frame(
6887        &self,
6888        mut buffer_id: u32,
6889    ) -> fidl::client::QueryResponseFut<
6890        ScreenCaptureReleaseFrameResult,
6891        fidl::encoding::DefaultFuchsiaResourceDialect,
6892    > {
6893        ScreenCaptureProxyInterface::r#release_frame(self, buffer_id)
6894    }
6895}
6896
6897impl ScreenCaptureProxyInterface for ScreenCaptureProxy {
6898    type ConfigureResponseFut = fidl::client::QueryResponseFut<
6899        ScreenCaptureConfigureResult,
6900        fidl::encoding::DefaultFuchsiaResourceDialect,
6901    >;
6902    fn r#configure(&self, mut payload: ScreenCaptureConfig) -> Self::ConfigureResponseFut {
6903        fn _decode(
6904            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6905        ) -> Result<ScreenCaptureConfigureResult, fidl::Error> {
6906            let _response = fidl::client::decode_transaction_body::<
6907                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ScreenCaptureError>,
6908                fidl::encoding::DefaultFuchsiaResourceDialect,
6909                0x3b6e5af1d294afd9,
6910            >(_buf?)?;
6911            Ok(_response.map(|x| x))
6912        }
6913        self.client.send_query_and_decode::<ScreenCaptureConfig, ScreenCaptureConfigureResult>(
6914            &mut payload,
6915            0x3b6e5af1d294afd9,
6916            fidl::encoding::DynamicFlags::empty(),
6917            _decode,
6918        )
6919    }
6920
6921    type GetNextFrameResponseFut = fidl::client::QueryResponseFut<
6922        ScreenCaptureGetNextFrameResult,
6923        fidl::encoding::DefaultFuchsiaResourceDialect,
6924    >;
6925    fn r#get_next_frame(&self, mut payload: GetNextFrameArgs) -> Self::GetNextFrameResponseFut {
6926        fn _decode(
6927            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6928        ) -> Result<ScreenCaptureGetNextFrameResult, fidl::Error> {
6929            let _response = fidl::client::decode_transaction_body::<
6930                fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>,
6931                fidl::encoding::DefaultFuchsiaResourceDialect,
6932                0x552c1580aab8c4a7,
6933            >(_buf?)?;
6934            Ok(_response.map(|x| x))
6935        }
6936        self.client.send_query_and_decode::<GetNextFrameArgs, ScreenCaptureGetNextFrameResult>(
6937            &mut payload,
6938            0x552c1580aab8c4a7,
6939            fidl::encoding::DynamicFlags::empty(),
6940            _decode,
6941        )
6942    }
6943
6944    type ReleaseFrameResponseFut = fidl::client::QueryResponseFut<
6945        ScreenCaptureReleaseFrameResult,
6946        fidl::encoding::DefaultFuchsiaResourceDialect,
6947    >;
6948    fn r#release_frame(&self, mut buffer_id: u32) -> Self::ReleaseFrameResponseFut {
6949        fn _decode(
6950            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6951        ) -> Result<ScreenCaptureReleaseFrameResult, fidl::Error> {
6952            let _response = fidl::client::decode_transaction_body::<
6953                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ScreenCaptureError>,
6954                fidl::encoding::DefaultFuchsiaResourceDialect,
6955                0x46704dce24e35950,
6956            >(_buf?)?;
6957            Ok(_response.map(|x| x))
6958        }
6959        self.client.send_query_and_decode::<
6960            ScreenCaptureReleaseFrameRequest,
6961            ScreenCaptureReleaseFrameResult,
6962        >(
6963            (buffer_id,),
6964            0x46704dce24e35950,
6965            fidl::encoding::DynamicFlags::empty(),
6966            _decode,
6967        )
6968    }
6969}
6970
6971pub struct ScreenCaptureEventStream {
6972    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6973}
6974
6975impl std::marker::Unpin for ScreenCaptureEventStream {}
6976
6977impl futures::stream::FusedStream for ScreenCaptureEventStream {
6978    fn is_terminated(&self) -> bool {
6979        self.event_receiver.is_terminated()
6980    }
6981}
6982
6983impl futures::Stream for ScreenCaptureEventStream {
6984    type Item = Result<ScreenCaptureEvent, fidl::Error>;
6985
6986    fn poll_next(
6987        mut self: std::pin::Pin<&mut Self>,
6988        cx: &mut std::task::Context<'_>,
6989    ) -> std::task::Poll<Option<Self::Item>> {
6990        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6991            &mut self.event_receiver,
6992            cx
6993        )?) {
6994            Some(buf) => std::task::Poll::Ready(Some(ScreenCaptureEvent::decode(buf))),
6995            None => std::task::Poll::Ready(None),
6996        }
6997    }
6998}
6999
7000#[derive(Debug)]
7001pub enum ScreenCaptureEvent {}
7002
7003impl ScreenCaptureEvent {
7004    /// Decodes a message buffer as a [`ScreenCaptureEvent`].
7005    fn decode(
7006        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7007    ) -> Result<ScreenCaptureEvent, fidl::Error> {
7008        let (bytes, _handles) = buf.split_mut();
7009        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7010        debug_assert_eq!(tx_header.tx_id, 0);
7011        match tx_header.ordinal {
7012            _ => Err(fidl::Error::UnknownOrdinal {
7013                ordinal: tx_header.ordinal,
7014                protocol_name: <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7015            }),
7016        }
7017    }
7018}
7019
7020/// A Stream of incoming requests for fuchsia.ui.composition/ScreenCapture.
7021pub struct ScreenCaptureRequestStream {
7022    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7023    is_terminated: bool,
7024}
7025
7026impl std::marker::Unpin for ScreenCaptureRequestStream {}
7027
7028impl futures::stream::FusedStream for ScreenCaptureRequestStream {
7029    fn is_terminated(&self) -> bool {
7030        self.is_terminated
7031    }
7032}
7033
7034impl fidl::endpoints::RequestStream for ScreenCaptureRequestStream {
7035    type Protocol = ScreenCaptureMarker;
7036    type ControlHandle = ScreenCaptureControlHandle;
7037
7038    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7039        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7040    }
7041
7042    fn control_handle(&self) -> Self::ControlHandle {
7043        ScreenCaptureControlHandle { inner: self.inner.clone() }
7044    }
7045
7046    fn into_inner(
7047        self,
7048    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7049    {
7050        (self.inner, self.is_terminated)
7051    }
7052
7053    fn from_inner(
7054        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7055        is_terminated: bool,
7056    ) -> Self {
7057        Self { inner, is_terminated }
7058    }
7059}
7060
7061impl futures::Stream for ScreenCaptureRequestStream {
7062    type Item = Result<ScreenCaptureRequest, fidl::Error>;
7063
7064    fn poll_next(
7065        mut self: std::pin::Pin<&mut Self>,
7066        cx: &mut std::task::Context<'_>,
7067    ) -> std::task::Poll<Option<Self::Item>> {
7068        let this = &mut *self;
7069        if this.inner.check_shutdown(cx) {
7070            this.is_terminated = true;
7071            return std::task::Poll::Ready(None);
7072        }
7073        if this.is_terminated {
7074            panic!("polled ScreenCaptureRequestStream after completion");
7075        }
7076        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7077            |bytes, handles| {
7078                match this.inner.channel().read_etc(cx, bytes, handles) {
7079                    std::task::Poll::Ready(Ok(())) => {}
7080                    std::task::Poll::Pending => return std::task::Poll::Pending,
7081                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7082                        this.is_terminated = true;
7083                        return std::task::Poll::Ready(None);
7084                    }
7085                    std::task::Poll::Ready(Err(e)) => {
7086                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7087                            e.into(),
7088                        ))));
7089                    }
7090                }
7091
7092                // A message has been received from the channel
7093                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7094
7095                std::task::Poll::Ready(Some(match header.ordinal {
7096                    0x3b6e5af1d294afd9 => {
7097                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7098                        let mut req = fidl::new_empty!(
7099                            ScreenCaptureConfig,
7100                            fidl::encoding::DefaultFuchsiaResourceDialect
7101                        );
7102                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenCaptureConfig>(&header, _body_bytes, handles, &mut req)?;
7103                        let control_handle =
7104                            ScreenCaptureControlHandle { inner: this.inner.clone() };
7105                        Ok(ScreenCaptureRequest::Configure {
7106                            payload: req,
7107                            responder: ScreenCaptureConfigureResponder {
7108                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7109                                tx_id: header.tx_id,
7110                            },
7111                        })
7112                    }
7113                    0x552c1580aab8c4a7 => {
7114                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7115                        let mut req = fidl::new_empty!(
7116                            GetNextFrameArgs,
7117                            fidl::encoding::DefaultFuchsiaResourceDialect
7118                        );
7119                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GetNextFrameArgs>(&header, _body_bytes, handles, &mut req)?;
7120                        let control_handle =
7121                            ScreenCaptureControlHandle { inner: this.inner.clone() };
7122                        Ok(ScreenCaptureRequest::GetNextFrame {
7123                            payload: req,
7124                            responder: ScreenCaptureGetNextFrameResponder {
7125                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7126                                tx_id: header.tx_id,
7127                            },
7128                        })
7129                    }
7130                    0x46704dce24e35950 => {
7131                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7132                        let mut req = fidl::new_empty!(
7133                            ScreenCaptureReleaseFrameRequest,
7134                            fidl::encoding::DefaultFuchsiaResourceDialect
7135                        );
7136                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenCaptureReleaseFrameRequest>(&header, _body_bytes, handles, &mut req)?;
7137                        let control_handle =
7138                            ScreenCaptureControlHandle { inner: this.inner.clone() };
7139                        Ok(ScreenCaptureRequest::ReleaseFrame {
7140                            buffer_id: req.buffer_id,
7141
7142                            responder: ScreenCaptureReleaseFrameResponder {
7143                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7144                                tx_id: header.tx_id,
7145                            },
7146                        })
7147                    }
7148                    _ => Err(fidl::Error::UnknownOrdinal {
7149                        ordinal: header.ordinal,
7150                        protocol_name:
7151                            <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7152                    }),
7153                }))
7154            },
7155        )
7156    }
7157}
7158
7159/// This protocol provides a low-level ScreenCapture API for clients to use.
7160/// ScreenCapture clients should familiarize themselves with the
7161/// [`fuchsia.sysmem/BufferCollection`] and [`fuchsia.ui.composition/Allocator`] protocols
7162/// as those are necessary to create the BufferCollections and images ScreenCapture uses.
7163#[derive(Debug)]
7164pub enum ScreenCaptureRequest {
7165    /// Clients should first use the Allocator protocol to register a
7166    /// BufferCollection. This function will fail with BAD_OPERATION unless all clients of the
7167    /// BufferCollection have set their constraints.
7168    ///
7169    /// Afterwards, clients should create and configure the images that will
7170    /// eventually be rendered to using this method. All the buffers in the
7171    /// collection from 0 to (buffer_count-1) may be used for screen capture.
7172    ///
7173    /// Clients are responsible for determining the rotation of the display,
7174    /// and applying the corrective rotation. For instance, if the display is
7175    /// mounted 90 degrees clockwise (the "top" is on the right, when looking
7176    /// at the display), then the client should specify a 270 degree rotation
7177    /// to account for it.
7178    ///
7179    /// Similarly, the clients are responsible for specifying a buffer big
7180    /// enough for the rotated image. If the buffer is too small, a best effort
7181    /// attempt will be made to render the image.
7182    ///
7183    /// Finally, clients request the server to render the current screen to the
7184    /// shared buffers using [`GetNextFrame`].
7185    ///
7186    /// [`Configure`] can be called again with a new BufferCollectionImportToken
7187    /// if the client wishes to change any of the configuration settings. In
7188    /// this case all the buffers from the previous call to [`Configure`] will
7189    /// be released.
7190    Configure { payload: ScreenCaptureConfig, responder: ScreenCaptureConfigureResponder },
7191    /// Following a successful call to [`Configure`], clients can call
7192    /// GetNextFrame. This will populate a buffer with the most recent frame.
7193    ///
7194    /// Clients should wait on the zx::event they pass for successful
7195    /// completion of the screenshot. It is not guaranteed that the screenshot
7196    /// will be completed by the time this function returns.
7197    ///
7198    /// The requested image will be in the BufferCollection that the client set
7199    /// up in the VMO at the index specified by buffer_id.
7200    ///
7201    /// When ScreenCapture is used to provide a stream, the rate that the
7202    /// client calls GetNextFrame will drive the frame rate.
7203    ///
7204    /// Errors:
7205    /// BAD_OPERATION if Configure was not called, or not called successfully
7206    /// MISSING_ARGS if a required argument is not present
7207    /// BUFFER_FULL if all buffers in the BufferCollection are in use. In this case, ReleaseFrame
7208    /// must be called to make a buffer available before this function can be called successfully.
7209    GetNextFrame { payload: GetNextFrameArgs, responder: ScreenCaptureGetNextFrameResponder },
7210    /// Once the client no longer needs an image, they can call ReleaseFrame on
7211    /// the VMO index of the buffer so that the server can reuse it in the future.
7212    ReleaseFrame { buffer_id: u32, responder: ScreenCaptureReleaseFrameResponder },
7213}
7214
7215impl ScreenCaptureRequest {
7216    #[allow(irrefutable_let_patterns)]
7217    pub fn into_configure(self) -> Option<(ScreenCaptureConfig, ScreenCaptureConfigureResponder)> {
7218        if let ScreenCaptureRequest::Configure { payload, responder } = self {
7219            Some((payload, responder))
7220        } else {
7221            None
7222        }
7223    }
7224
7225    #[allow(irrefutable_let_patterns)]
7226    pub fn into_get_next_frame(
7227        self,
7228    ) -> Option<(GetNextFrameArgs, ScreenCaptureGetNextFrameResponder)> {
7229        if let ScreenCaptureRequest::GetNextFrame { payload, responder } = self {
7230            Some((payload, responder))
7231        } else {
7232            None
7233        }
7234    }
7235
7236    #[allow(irrefutable_let_patterns)]
7237    pub fn into_release_frame(self) -> Option<(u32, ScreenCaptureReleaseFrameResponder)> {
7238        if let ScreenCaptureRequest::ReleaseFrame { buffer_id, responder } = self {
7239            Some((buffer_id, responder))
7240        } else {
7241            None
7242        }
7243    }
7244
7245    /// Name of the method defined in FIDL
7246    pub fn method_name(&self) -> &'static str {
7247        match *self {
7248            ScreenCaptureRequest::Configure { .. } => "configure",
7249            ScreenCaptureRequest::GetNextFrame { .. } => "get_next_frame",
7250            ScreenCaptureRequest::ReleaseFrame { .. } => "release_frame",
7251        }
7252    }
7253}
7254
7255#[derive(Debug, Clone)]
7256pub struct ScreenCaptureControlHandle {
7257    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7258}
7259
7260impl fidl::endpoints::ControlHandle for ScreenCaptureControlHandle {
7261    fn shutdown(&self) {
7262        self.inner.shutdown()
7263    }
7264
7265    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7266        self.inner.shutdown_with_epitaph(status)
7267    }
7268
7269    fn is_closed(&self) -> bool {
7270        self.inner.channel().is_closed()
7271    }
7272    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7273        self.inner.channel().on_closed()
7274    }
7275
7276    #[cfg(target_os = "fuchsia")]
7277    fn signal_peer(
7278        &self,
7279        clear_mask: zx::Signals,
7280        set_mask: zx::Signals,
7281    ) -> Result<(), zx_status::Status> {
7282        use fidl::Peered;
7283        self.inner.channel().signal_peer(clear_mask, set_mask)
7284    }
7285}
7286
7287impl ScreenCaptureControlHandle {}
7288
7289#[must_use = "FIDL methods require a response to be sent"]
7290#[derive(Debug)]
7291pub struct ScreenCaptureConfigureResponder {
7292    control_handle: std::mem::ManuallyDrop<ScreenCaptureControlHandle>,
7293    tx_id: u32,
7294}
7295
7296/// Set the the channel to be shutdown (see [`ScreenCaptureControlHandle::shutdown`])
7297/// if the responder is dropped without sending a response, so that the client
7298/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7299impl std::ops::Drop for ScreenCaptureConfigureResponder {
7300    fn drop(&mut self) {
7301        self.control_handle.shutdown();
7302        // Safety: drops once, never accessed again
7303        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7304    }
7305}
7306
7307impl fidl::endpoints::Responder for ScreenCaptureConfigureResponder {
7308    type ControlHandle = ScreenCaptureControlHandle;
7309
7310    fn control_handle(&self) -> &ScreenCaptureControlHandle {
7311        &self.control_handle
7312    }
7313
7314    fn drop_without_shutdown(mut self) {
7315        // Safety: drops once, never accessed again due to mem::forget
7316        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7317        // Prevent Drop from running (which would shut down the channel)
7318        std::mem::forget(self);
7319    }
7320}
7321
7322impl ScreenCaptureConfigureResponder {
7323    /// Sends a response to the FIDL transaction.
7324    ///
7325    /// Sets the channel to shutdown if an error occurs.
7326    pub fn send(self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7327        let _result = self.send_raw(result);
7328        if _result.is_err() {
7329            self.control_handle.shutdown();
7330        }
7331        self.drop_without_shutdown();
7332        _result
7333    }
7334
7335    /// Similar to "send" but does not shutdown the channel if an error occurs.
7336    pub fn send_no_shutdown_on_err(
7337        self,
7338        mut result: Result<(), ScreenCaptureError>,
7339    ) -> Result<(), fidl::Error> {
7340        let _result = self.send_raw(result);
7341        self.drop_without_shutdown();
7342        _result
7343    }
7344
7345    fn send_raw(&self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7346        self.control_handle.inner.send::<fidl::encoding::ResultType<
7347            fidl::encoding::EmptyStruct,
7348            ScreenCaptureError,
7349        >>(
7350            result,
7351            self.tx_id,
7352            0x3b6e5af1d294afd9,
7353            fidl::encoding::DynamicFlags::empty(),
7354        )
7355    }
7356}
7357
7358#[must_use = "FIDL methods require a response to be sent"]
7359#[derive(Debug)]
7360pub struct ScreenCaptureGetNextFrameResponder {
7361    control_handle: std::mem::ManuallyDrop<ScreenCaptureControlHandle>,
7362    tx_id: u32,
7363}
7364
7365/// Set the the channel to be shutdown (see [`ScreenCaptureControlHandle::shutdown`])
7366/// if the responder is dropped without sending a response, so that the client
7367/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7368impl std::ops::Drop for ScreenCaptureGetNextFrameResponder {
7369    fn drop(&mut self) {
7370        self.control_handle.shutdown();
7371        // Safety: drops once, never accessed again
7372        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7373    }
7374}
7375
7376impl fidl::endpoints::Responder for ScreenCaptureGetNextFrameResponder {
7377    type ControlHandle = ScreenCaptureControlHandle;
7378
7379    fn control_handle(&self) -> &ScreenCaptureControlHandle {
7380        &self.control_handle
7381    }
7382
7383    fn drop_without_shutdown(mut self) {
7384        // Safety: drops once, never accessed again due to mem::forget
7385        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7386        // Prevent Drop from running (which would shut down the channel)
7387        std::mem::forget(self);
7388    }
7389}
7390
7391impl ScreenCaptureGetNextFrameResponder {
7392    /// Sends a response to the FIDL transaction.
7393    ///
7394    /// Sets the channel to shutdown if an error occurs.
7395    pub fn send(
7396        self,
7397        mut result: Result<FrameInfo, ScreenCaptureError>,
7398    ) -> Result<(), fidl::Error> {
7399        let _result = self.send_raw(result);
7400        if _result.is_err() {
7401            self.control_handle.shutdown();
7402        }
7403        self.drop_without_shutdown();
7404        _result
7405    }
7406
7407    /// Similar to "send" but does not shutdown the channel if an error occurs.
7408    pub fn send_no_shutdown_on_err(
7409        self,
7410        mut result: Result<FrameInfo, ScreenCaptureError>,
7411    ) -> Result<(), fidl::Error> {
7412        let _result = self.send_raw(result);
7413        self.drop_without_shutdown();
7414        _result
7415    }
7416
7417    fn send_raw(
7418        &self,
7419        mut result: Result<FrameInfo, ScreenCaptureError>,
7420    ) -> Result<(), fidl::Error> {
7421        self.control_handle.inner.send::<fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>>(
7422            result.as_mut().map_err(|e| *e),
7423            self.tx_id,
7424            0x552c1580aab8c4a7,
7425            fidl::encoding::DynamicFlags::empty(),
7426        )
7427    }
7428}
7429
7430#[must_use = "FIDL methods require a response to be sent"]
7431#[derive(Debug)]
7432pub struct ScreenCaptureReleaseFrameResponder {
7433    control_handle: std::mem::ManuallyDrop<ScreenCaptureControlHandle>,
7434    tx_id: u32,
7435}
7436
7437/// Set the the channel to be shutdown (see [`ScreenCaptureControlHandle::shutdown`])
7438/// if the responder is dropped without sending a response, so that the client
7439/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7440impl std::ops::Drop for ScreenCaptureReleaseFrameResponder {
7441    fn drop(&mut self) {
7442        self.control_handle.shutdown();
7443        // Safety: drops once, never accessed again
7444        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7445    }
7446}
7447
7448impl fidl::endpoints::Responder for ScreenCaptureReleaseFrameResponder {
7449    type ControlHandle = ScreenCaptureControlHandle;
7450
7451    fn control_handle(&self) -> &ScreenCaptureControlHandle {
7452        &self.control_handle
7453    }
7454
7455    fn drop_without_shutdown(mut self) {
7456        // Safety: drops once, never accessed again due to mem::forget
7457        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7458        // Prevent Drop from running (which would shut down the channel)
7459        std::mem::forget(self);
7460    }
7461}
7462
7463impl ScreenCaptureReleaseFrameResponder {
7464    /// Sends a response to the FIDL transaction.
7465    ///
7466    /// Sets the channel to shutdown if an error occurs.
7467    pub fn send(self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7468        let _result = self.send_raw(result);
7469        if _result.is_err() {
7470            self.control_handle.shutdown();
7471        }
7472        self.drop_without_shutdown();
7473        _result
7474    }
7475
7476    /// Similar to "send" but does not shutdown the channel if an error occurs.
7477    pub fn send_no_shutdown_on_err(
7478        self,
7479        mut result: Result<(), ScreenCaptureError>,
7480    ) -> Result<(), fidl::Error> {
7481        let _result = self.send_raw(result);
7482        self.drop_without_shutdown();
7483        _result
7484    }
7485
7486    fn send_raw(&self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7487        self.control_handle.inner.send::<fidl::encoding::ResultType<
7488            fidl::encoding::EmptyStruct,
7489            ScreenCaptureError,
7490        >>(
7491            result,
7492            self.tx_id,
7493            0x46704dce24e35950,
7494            fidl::encoding::DynamicFlags::empty(),
7495        )
7496    }
7497}
7498
7499#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7500pub struct ScreenshotMarker;
7501
7502impl fidl::endpoints::ProtocolMarker for ScreenshotMarker {
7503    type Proxy = ScreenshotProxy;
7504    type RequestStream = ScreenshotRequestStream;
7505    #[cfg(target_os = "fuchsia")]
7506    type SynchronousProxy = ScreenshotSynchronousProxy;
7507
7508    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.Screenshot";
7509}
7510impl fidl::endpoints::DiscoverableProtocolMarker for ScreenshotMarker {}
7511
7512pub trait ScreenshotProxyInterface: Send + Sync {
7513    type TakeResponseFut: std::future::Future<Output = Result<ScreenshotTakeResponse, fidl::Error>>
7514        + Send;
7515    fn r#take(&self, payload: ScreenshotTakeRequest) -> Self::TakeResponseFut;
7516    type TakeFileResponseFut: std::future::Future<Output = Result<ScreenshotTakeFileResponse, fidl::Error>>
7517        + Send;
7518    fn r#take_file(&self, payload: ScreenshotTakeFileRequest) -> Self::TakeFileResponseFut;
7519}
7520#[derive(Debug)]
7521#[cfg(target_os = "fuchsia")]
7522pub struct ScreenshotSynchronousProxy {
7523    client: fidl::client::sync::Client,
7524}
7525
7526#[cfg(target_os = "fuchsia")]
7527impl fidl::endpoints::SynchronousProxy for ScreenshotSynchronousProxy {
7528    type Proxy = ScreenshotProxy;
7529    type Protocol = ScreenshotMarker;
7530
7531    fn from_channel(inner: fidl::Channel) -> Self {
7532        Self::new(inner)
7533    }
7534
7535    fn into_channel(self) -> fidl::Channel {
7536        self.client.into_channel()
7537    }
7538
7539    fn as_channel(&self) -> &fidl::Channel {
7540        self.client.as_channel()
7541    }
7542}
7543
7544#[cfg(target_os = "fuchsia")]
7545impl ScreenshotSynchronousProxy {
7546    pub fn new(channel: fidl::Channel) -> Self {
7547        let protocol_name = <ScreenshotMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7548        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7549    }
7550
7551    pub fn into_channel(self) -> fidl::Channel {
7552        self.client.into_channel()
7553    }
7554
7555    /// Waits until an event arrives and returns it. It is safe for other
7556    /// threads to make concurrent requests while waiting for an event.
7557    pub fn wait_for_event(
7558        &self,
7559        deadline: zx::MonotonicInstant,
7560    ) -> Result<ScreenshotEvent, fidl::Error> {
7561        ScreenshotEvent::decode(self.client.wait_for_event(deadline)?)
7562    }
7563
7564    /// Collects the current graphical content of a display in a specified buffer `format` in the
7565    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7566    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7567    /// linear color space.
7568    ///
7569    /// See https://fuchsia.dev/fuchsia-src/concepts/ui/scenic/color_spaces for more information.
7570    ///
7571    /// Screenshot is taken immediately, populated with the display's content from the most recent
7572    /// VSYNC.
7573    ///
7574    /// If the client calls [`Take`] a second time before a first [`Take`] call returns, the server
7575    /// will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7576    ///
7577    /// If capture fails due to an internal error, the server will close the Screenshot connection
7578    /// with a ZX_ERR_INTERNAL epitaph.
7579    pub fn r#take(
7580        &self,
7581        mut payload: ScreenshotTakeRequest,
7582        ___deadline: zx::MonotonicInstant,
7583    ) -> Result<ScreenshotTakeResponse, fidl::Error> {
7584        let _response = self.client.send_query::<ScreenshotTakeRequest, ScreenshotTakeResponse>(
7585            &mut payload,
7586            0x51341396e9fd2fd0,
7587            fidl::encoding::DynamicFlags::empty(),
7588            ___deadline,
7589        )?;
7590        Ok(_response)
7591    }
7592
7593    /// Collects the current graphical content of a display in a specified buffer `format` in the
7594    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7595    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7596    /// linear color space.
7597    ///
7598    /// TODO(https://fxbug.dev/42065844): Link to fuchsia.dev documentation when it's up.
7599    ///
7600    /// Screenshot is taken immediately, populated with the display's content from the most recent
7601    /// VSYNC.
7602    ///
7603    /// If the client calls [`TakeFile`] a second time before a first [`TakeFile`] call returns,
7604    /// the server will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7605    ///
7606    /// If capture fails due to an internal error, the server will close the Screenshot connection
7607    /// with a ZX_ERR_INTERNAL epitaph.
7608    ///
7609    /// This call should be used if the client is on the host and does not support VMOs,
7610    /// as is the case for ffx tools.
7611    pub fn r#take_file(
7612        &self,
7613        mut payload: ScreenshotTakeFileRequest,
7614        ___deadline: zx::MonotonicInstant,
7615    ) -> Result<ScreenshotTakeFileResponse, fidl::Error> {
7616        let _response =
7617            self.client.send_query::<ScreenshotTakeFileRequest, ScreenshotTakeFileResponse>(
7618                &mut payload,
7619                0x470aeea0a4d32903,
7620                fidl::encoding::DynamicFlags::empty(),
7621                ___deadline,
7622            )?;
7623        Ok(_response)
7624    }
7625}
7626
7627#[cfg(target_os = "fuchsia")]
7628impl From<ScreenshotSynchronousProxy> for zx::NullableHandle {
7629    fn from(value: ScreenshotSynchronousProxy) -> Self {
7630        value.into_channel().into()
7631    }
7632}
7633
7634#[cfg(target_os = "fuchsia")]
7635impl From<fidl::Channel> for ScreenshotSynchronousProxy {
7636    fn from(value: fidl::Channel) -> Self {
7637        Self::new(value)
7638    }
7639}
7640
7641#[cfg(target_os = "fuchsia")]
7642impl fidl::endpoints::FromClient for ScreenshotSynchronousProxy {
7643    type Protocol = ScreenshotMarker;
7644
7645    fn from_client(value: fidl::endpoints::ClientEnd<ScreenshotMarker>) -> Self {
7646        Self::new(value.into_channel())
7647    }
7648}
7649
7650#[derive(Debug, Clone)]
7651pub struct ScreenshotProxy {
7652    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7653}
7654
7655impl fidl::endpoints::Proxy for ScreenshotProxy {
7656    type Protocol = ScreenshotMarker;
7657
7658    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7659        Self::new(inner)
7660    }
7661
7662    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7663        self.client.into_channel().map_err(|client| Self { client })
7664    }
7665
7666    fn as_channel(&self) -> &::fidl::AsyncChannel {
7667        self.client.as_channel()
7668    }
7669}
7670
7671impl ScreenshotProxy {
7672    /// Create a new Proxy for fuchsia.ui.composition/Screenshot.
7673    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7674        let protocol_name = <ScreenshotMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7675        Self { client: fidl::client::Client::new(channel, protocol_name) }
7676    }
7677
7678    /// Get a Stream of events from the remote end of the protocol.
7679    ///
7680    /// # Panics
7681    ///
7682    /// Panics if the event stream was already taken.
7683    pub fn take_event_stream(&self) -> ScreenshotEventStream {
7684        ScreenshotEventStream { event_receiver: self.client.take_event_receiver() }
7685    }
7686
7687    /// Collects the current graphical content of a display in a specified buffer `format` in the
7688    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7689    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7690    /// linear color space.
7691    ///
7692    /// See https://fuchsia.dev/fuchsia-src/concepts/ui/scenic/color_spaces for more information.
7693    ///
7694    /// Screenshot is taken immediately, populated with the display's content from the most recent
7695    /// VSYNC.
7696    ///
7697    /// If the client calls [`Take`] a second time before a first [`Take`] call returns, the server
7698    /// will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7699    ///
7700    /// If capture fails due to an internal error, the server will close the Screenshot connection
7701    /// with a ZX_ERR_INTERNAL epitaph.
7702    pub fn r#take(
7703        &self,
7704        mut payload: ScreenshotTakeRequest,
7705    ) -> fidl::client::QueryResponseFut<
7706        ScreenshotTakeResponse,
7707        fidl::encoding::DefaultFuchsiaResourceDialect,
7708    > {
7709        ScreenshotProxyInterface::r#take(self, payload)
7710    }
7711
7712    /// Collects the current graphical content of a display in a specified buffer `format` in the
7713    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7714    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7715    /// linear color space.
7716    ///
7717    /// TODO(https://fxbug.dev/42065844): Link to fuchsia.dev documentation when it's up.
7718    ///
7719    /// Screenshot is taken immediately, populated with the display's content from the most recent
7720    /// VSYNC.
7721    ///
7722    /// If the client calls [`TakeFile`] a second time before a first [`TakeFile`] call returns,
7723    /// the server will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7724    ///
7725    /// If capture fails due to an internal error, the server will close the Screenshot connection
7726    /// with a ZX_ERR_INTERNAL epitaph.
7727    ///
7728    /// This call should be used if the client is on the host and does not support VMOs,
7729    /// as is the case for ffx tools.
7730    pub fn r#take_file(
7731        &self,
7732        mut payload: ScreenshotTakeFileRequest,
7733    ) -> fidl::client::QueryResponseFut<
7734        ScreenshotTakeFileResponse,
7735        fidl::encoding::DefaultFuchsiaResourceDialect,
7736    > {
7737        ScreenshotProxyInterface::r#take_file(self, payload)
7738    }
7739}
7740
7741impl ScreenshotProxyInterface for ScreenshotProxy {
7742    type TakeResponseFut = fidl::client::QueryResponseFut<
7743        ScreenshotTakeResponse,
7744        fidl::encoding::DefaultFuchsiaResourceDialect,
7745    >;
7746    fn r#take(&self, mut payload: ScreenshotTakeRequest) -> Self::TakeResponseFut {
7747        fn _decode(
7748            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7749        ) -> Result<ScreenshotTakeResponse, fidl::Error> {
7750            let _response = fidl::client::decode_transaction_body::<
7751                ScreenshotTakeResponse,
7752                fidl::encoding::DefaultFuchsiaResourceDialect,
7753                0x51341396e9fd2fd0,
7754            >(_buf?)?;
7755            Ok(_response)
7756        }
7757        self.client.send_query_and_decode::<ScreenshotTakeRequest, ScreenshotTakeResponse>(
7758            &mut payload,
7759            0x51341396e9fd2fd0,
7760            fidl::encoding::DynamicFlags::empty(),
7761            _decode,
7762        )
7763    }
7764
7765    type TakeFileResponseFut = fidl::client::QueryResponseFut<
7766        ScreenshotTakeFileResponse,
7767        fidl::encoding::DefaultFuchsiaResourceDialect,
7768    >;
7769    fn r#take_file(&self, mut payload: ScreenshotTakeFileRequest) -> Self::TakeFileResponseFut {
7770        fn _decode(
7771            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7772        ) -> Result<ScreenshotTakeFileResponse, fidl::Error> {
7773            let _response = fidl::client::decode_transaction_body::<
7774                ScreenshotTakeFileResponse,
7775                fidl::encoding::DefaultFuchsiaResourceDialect,
7776                0x470aeea0a4d32903,
7777            >(_buf?)?;
7778            Ok(_response)
7779        }
7780        self.client.send_query_and_decode::<ScreenshotTakeFileRequest, ScreenshotTakeFileResponse>(
7781            &mut payload,
7782            0x470aeea0a4d32903,
7783            fidl::encoding::DynamicFlags::empty(),
7784            _decode,
7785        )
7786    }
7787}
7788
7789pub struct ScreenshotEventStream {
7790    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7791}
7792
7793impl std::marker::Unpin for ScreenshotEventStream {}
7794
7795impl futures::stream::FusedStream for ScreenshotEventStream {
7796    fn is_terminated(&self) -> bool {
7797        self.event_receiver.is_terminated()
7798    }
7799}
7800
7801impl futures::Stream for ScreenshotEventStream {
7802    type Item = Result<ScreenshotEvent, fidl::Error>;
7803
7804    fn poll_next(
7805        mut self: std::pin::Pin<&mut Self>,
7806        cx: &mut std::task::Context<'_>,
7807    ) -> std::task::Poll<Option<Self::Item>> {
7808        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7809            &mut self.event_receiver,
7810            cx
7811        )?) {
7812            Some(buf) => std::task::Poll::Ready(Some(ScreenshotEvent::decode(buf))),
7813            None => std::task::Poll::Ready(None),
7814        }
7815    }
7816}
7817
7818#[derive(Debug)]
7819pub enum ScreenshotEvent {}
7820
7821impl ScreenshotEvent {
7822    /// Decodes a message buffer as a [`ScreenshotEvent`].
7823    fn decode(
7824        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7825    ) -> Result<ScreenshotEvent, fidl::Error> {
7826        let (bytes, _handles) = buf.split_mut();
7827        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7828        debug_assert_eq!(tx_header.tx_id, 0);
7829        match tx_header.ordinal {
7830            _ => Err(fidl::Error::UnknownOrdinal {
7831                ordinal: tx_header.ordinal,
7832                protocol_name: <ScreenshotMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7833            }),
7834        }
7835    }
7836}
7837
7838/// A Stream of incoming requests for fuchsia.ui.composition/Screenshot.
7839pub struct ScreenshotRequestStream {
7840    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7841    is_terminated: bool,
7842}
7843
7844impl std::marker::Unpin for ScreenshotRequestStream {}
7845
7846impl futures::stream::FusedStream for ScreenshotRequestStream {
7847    fn is_terminated(&self) -> bool {
7848        self.is_terminated
7849    }
7850}
7851
7852impl fidl::endpoints::RequestStream for ScreenshotRequestStream {
7853    type Protocol = ScreenshotMarker;
7854    type ControlHandle = ScreenshotControlHandle;
7855
7856    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7857        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7858    }
7859
7860    fn control_handle(&self) -> Self::ControlHandle {
7861        ScreenshotControlHandle { inner: self.inner.clone() }
7862    }
7863
7864    fn into_inner(
7865        self,
7866    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7867    {
7868        (self.inner, self.is_terminated)
7869    }
7870
7871    fn from_inner(
7872        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7873        is_terminated: bool,
7874    ) -> Self {
7875        Self { inner, is_terminated }
7876    }
7877}
7878
7879impl futures::Stream for ScreenshotRequestStream {
7880    type Item = Result<ScreenshotRequest, fidl::Error>;
7881
7882    fn poll_next(
7883        mut self: std::pin::Pin<&mut Self>,
7884        cx: &mut std::task::Context<'_>,
7885    ) -> std::task::Poll<Option<Self::Item>> {
7886        let this = &mut *self;
7887        if this.inner.check_shutdown(cx) {
7888            this.is_terminated = true;
7889            return std::task::Poll::Ready(None);
7890        }
7891        if this.is_terminated {
7892            panic!("polled ScreenshotRequestStream after completion");
7893        }
7894        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7895            |bytes, handles| {
7896                match this.inner.channel().read_etc(cx, bytes, handles) {
7897                    std::task::Poll::Ready(Ok(())) => {}
7898                    std::task::Poll::Pending => return std::task::Poll::Pending,
7899                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7900                        this.is_terminated = true;
7901                        return std::task::Poll::Ready(None);
7902                    }
7903                    std::task::Poll::Ready(Err(e)) => {
7904                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7905                            e.into(),
7906                        ))));
7907                    }
7908                }
7909
7910                // A message has been received from the channel
7911                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7912
7913                std::task::Poll::Ready(Some(match header.ordinal {
7914                    0x51341396e9fd2fd0 => {
7915                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7916                        let mut req = fidl::new_empty!(
7917                            ScreenshotTakeRequest,
7918                            fidl::encoding::DefaultFuchsiaResourceDialect
7919                        );
7920                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenshotTakeRequest>(&header, _body_bytes, handles, &mut req)?;
7921                        let control_handle = ScreenshotControlHandle { inner: this.inner.clone() };
7922                        Ok(ScreenshotRequest::Take {
7923                            payload: req,
7924                            responder: ScreenshotTakeResponder {
7925                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7926                                tx_id: header.tx_id,
7927                            },
7928                        })
7929                    }
7930                    0x470aeea0a4d32903 => {
7931                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7932                        let mut req = fidl::new_empty!(
7933                            ScreenshotTakeFileRequest,
7934                            fidl::encoding::DefaultFuchsiaResourceDialect
7935                        );
7936                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenshotTakeFileRequest>(&header, _body_bytes, handles, &mut req)?;
7937                        let control_handle = ScreenshotControlHandle { inner: this.inner.clone() };
7938                        Ok(ScreenshotRequest::TakeFile {
7939                            payload: req,
7940                            responder: ScreenshotTakeFileResponder {
7941                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7942                                tx_id: header.tx_id,
7943                            },
7944                        })
7945                    }
7946                    _ => Err(fidl::Error::UnknownOrdinal {
7947                        ordinal: header.ordinal,
7948                        protocol_name:
7949                            <ScreenshotMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7950                    }),
7951                }))
7952            },
7953        )
7954    }
7955}
7956
7957/// Collects the current graphical content of a display.
7958#[derive(Debug)]
7959pub enum ScreenshotRequest {
7960    /// Collects the current graphical content of a display in a specified buffer `format` in the
7961    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7962    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7963    /// linear color space.
7964    ///
7965    /// See https://fuchsia.dev/fuchsia-src/concepts/ui/scenic/color_spaces for more information.
7966    ///
7967    /// Screenshot is taken immediately, populated with the display's content from the most recent
7968    /// VSYNC.
7969    ///
7970    /// If the client calls [`Take`] a second time before a first [`Take`] call returns, the server
7971    /// will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7972    ///
7973    /// If capture fails due to an internal error, the server will close the Screenshot connection
7974    /// with a ZX_ERR_INTERNAL epitaph.
7975    Take { payload: ScreenshotTakeRequest, responder: ScreenshotTakeResponder },
7976    /// Collects the current graphical content of a display in a specified buffer `format` in the
7977    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7978    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7979    /// linear color space.
7980    ///
7981    /// TODO(https://fxbug.dev/42065844): Link to fuchsia.dev documentation when it's up.
7982    ///
7983    /// Screenshot is taken immediately, populated with the display's content from the most recent
7984    /// VSYNC.
7985    ///
7986    /// If the client calls [`TakeFile`] a second time before a first [`TakeFile`] call returns,
7987    /// the server will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7988    ///
7989    /// If capture fails due to an internal error, the server will close the Screenshot connection
7990    /// with a ZX_ERR_INTERNAL epitaph.
7991    ///
7992    /// This call should be used if the client is on the host and does not support VMOs,
7993    /// as is the case for ffx tools.
7994    TakeFile { payload: ScreenshotTakeFileRequest, responder: ScreenshotTakeFileResponder },
7995}
7996
7997impl ScreenshotRequest {
7998    #[allow(irrefutable_let_patterns)]
7999    pub fn into_take(self) -> Option<(ScreenshotTakeRequest, ScreenshotTakeResponder)> {
8000        if let ScreenshotRequest::Take { payload, responder } = self {
8001            Some((payload, responder))
8002        } else {
8003            None
8004        }
8005    }
8006
8007    #[allow(irrefutable_let_patterns)]
8008    pub fn into_take_file(
8009        self,
8010    ) -> Option<(ScreenshotTakeFileRequest, ScreenshotTakeFileResponder)> {
8011        if let ScreenshotRequest::TakeFile { payload, responder } = self {
8012            Some((payload, responder))
8013        } else {
8014            None
8015        }
8016    }
8017
8018    /// Name of the method defined in FIDL
8019    pub fn method_name(&self) -> &'static str {
8020        match *self {
8021            ScreenshotRequest::Take { .. } => "take",
8022            ScreenshotRequest::TakeFile { .. } => "take_file",
8023        }
8024    }
8025}
8026
8027#[derive(Debug, Clone)]
8028pub struct ScreenshotControlHandle {
8029    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8030}
8031
8032impl fidl::endpoints::ControlHandle for ScreenshotControlHandle {
8033    fn shutdown(&self) {
8034        self.inner.shutdown()
8035    }
8036
8037    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8038        self.inner.shutdown_with_epitaph(status)
8039    }
8040
8041    fn is_closed(&self) -> bool {
8042        self.inner.channel().is_closed()
8043    }
8044    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8045        self.inner.channel().on_closed()
8046    }
8047
8048    #[cfg(target_os = "fuchsia")]
8049    fn signal_peer(
8050        &self,
8051        clear_mask: zx::Signals,
8052        set_mask: zx::Signals,
8053    ) -> Result<(), zx_status::Status> {
8054        use fidl::Peered;
8055        self.inner.channel().signal_peer(clear_mask, set_mask)
8056    }
8057}
8058
8059impl ScreenshotControlHandle {}
8060
8061#[must_use = "FIDL methods require a response to be sent"]
8062#[derive(Debug)]
8063pub struct ScreenshotTakeResponder {
8064    control_handle: std::mem::ManuallyDrop<ScreenshotControlHandle>,
8065    tx_id: u32,
8066}
8067
8068/// Set the the channel to be shutdown (see [`ScreenshotControlHandle::shutdown`])
8069/// if the responder is dropped without sending a response, so that the client
8070/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8071impl std::ops::Drop for ScreenshotTakeResponder {
8072    fn drop(&mut self) {
8073        self.control_handle.shutdown();
8074        // Safety: drops once, never accessed again
8075        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8076    }
8077}
8078
8079impl fidl::endpoints::Responder for ScreenshotTakeResponder {
8080    type ControlHandle = ScreenshotControlHandle;
8081
8082    fn control_handle(&self) -> &ScreenshotControlHandle {
8083        &self.control_handle
8084    }
8085
8086    fn drop_without_shutdown(mut self) {
8087        // Safety: drops once, never accessed again due to mem::forget
8088        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8089        // Prevent Drop from running (which would shut down the channel)
8090        std::mem::forget(self);
8091    }
8092}
8093
8094impl ScreenshotTakeResponder {
8095    /// Sends a response to the FIDL transaction.
8096    ///
8097    /// Sets the channel to shutdown if an error occurs.
8098    pub fn send(self, mut payload: ScreenshotTakeResponse) -> Result<(), fidl::Error> {
8099        let _result = self.send_raw(payload);
8100        if _result.is_err() {
8101            self.control_handle.shutdown();
8102        }
8103        self.drop_without_shutdown();
8104        _result
8105    }
8106
8107    /// Similar to "send" but does not shutdown the channel if an error occurs.
8108    pub fn send_no_shutdown_on_err(
8109        self,
8110        mut payload: ScreenshotTakeResponse,
8111    ) -> Result<(), fidl::Error> {
8112        let _result = self.send_raw(payload);
8113        self.drop_without_shutdown();
8114        _result
8115    }
8116
8117    fn send_raw(&self, mut payload: ScreenshotTakeResponse) -> Result<(), fidl::Error> {
8118        self.control_handle.inner.send::<ScreenshotTakeResponse>(
8119            &mut payload,
8120            self.tx_id,
8121            0x51341396e9fd2fd0,
8122            fidl::encoding::DynamicFlags::empty(),
8123        )
8124    }
8125}
8126
8127#[must_use = "FIDL methods require a response to be sent"]
8128#[derive(Debug)]
8129pub struct ScreenshotTakeFileResponder {
8130    control_handle: std::mem::ManuallyDrop<ScreenshotControlHandle>,
8131    tx_id: u32,
8132}
8133
8134/// Set the the channel to be shutdown (see [`ScreenshotControlHandle::shutdown`])
8135/// if the responder is dropped without sending a response, so that the client
8136/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8137impl std::ops::Drop for ScreenshotTakeFileResponder {
8138    fn drop(&mut self) {
8139        self.control_handle.shutdown();
8140        // Safety: drops once, never accessed again
8141        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8142    }
8143}
8144
8145impl fidl::endpoints::Responder for ScreenshotTakeFileResponder {
8146    type ControlHandle = ScreenshotControlHandle;
8147
8148    fn control_handle(&self) -> &ScreenshotControlHandle {
8149        &self.control_handle
8150    }
8151
8152    fn drop_without_shutdown(mut self) {
8153        // Safety: drops once, never accessed again due to mem::forget
8154        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8155        // Prevent Drop from running (which would shut down the channel)
8156        std::mem::forget(self);
8157    }
8158}
8159
8160impl ScreenshotTakeFileResponder {
8161    /// Sends a response to the FIDL transaction.
8162    ///
8163    /// Sets the channel to shutdown if an error occurs.
8164    pub fn send(self, mut payload: ScreenshotTakeFileResponse) -> Result<(), fidl::Error> {
8165        let _result = self.send_raw(payload);
8166        if _result.is_err() {
8167            self.control_handle.shutdown();
8168        }
8169        self.drop_without_shutdown();
8170        _result
8171    }
8172
8173    /// Similar to "send" but does not shutdown the channel if an error occurs.
8174    pub fn send_no_shutdown_on_err(
8175        self,
8176        mut payload: ScreenshotTakeFileResponse,
8177    ) -> Result<(), fidl::Error> {
8178        let _result = self.send_raw(payload);
8179        self.drop_without_shutdown();
8180        _result
8181    }
8182
8183    fn send_raw(&self, mut payload: ScreenshotTakeFileResponse) -> Result<(), fidl::Error> {
8184        self.control_handle.inner.send::<ScreenshotTakeFileResponse>(
8185            &mut payload,
8186            self.tx_id,
8187            0x470aeea0a4d32903,
8188            fidl::encoding::DynamicFlags::empty(),
8189        )
8190    }
8191}
8192
8193#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8194pub struct TrustedFlatlandMarker;
8195
8196impl fidl::endpoints::ProtocolMarker for TrustedFlatlandMarker {
8197    type Proxy = TrustedFlatlandProxy;
8198    type RequestStream = TrustedFlatlandRequestStream;
8199    #[cfg(target_os = "fuchsia")]
8200    type SynchronousProxy = TrustedFlatlandSynchronousProxy;
8201
8202    const DEBUG_NAME: &'static str = "(anonymous) TrustedFlatland";
8203}
8204
8205pub trait TrustedFlatlandProxyInterface: Send + Sync {
8206    fn r#release_image_immediately(&self, image_id: &ContentId) -> Result<(), fidl::Error>;
8207}
8208#[derive(Debug)]
8209#[cfg(target_os = "fuchsia")]
8210pub struct TrustedFlatlandSynchronousProxy {
8211    client: fidl::client::sync::Client,
8212}
8213
8214#[cfg(target_os = "fuchsia")]
8215impl fidl::endpoints::SynchronousProxy for TrustedFlatlandSynchronousProxy {
8216    type Proxy = TrustedFlatlandProxy;
8217    type Protocol = TrustedFlatlandMarker;
8218
8219    fn from_channel(inner: fidl::Channel) -> Self {
8220        Self::new(inner)
8221    }
8222
8223    fn into_channel(self) -> fidl::Channel {
8224        self.client.into_channel()
8225    }
8226
8227    fn as_channel(&self) -> &fidl::Channel {
8228        self.client.as_channel()
8229    }
8230}
8231
8232#[cfg(target_os = "fuchsia")]
8233impl TrustedFlatlandSynchronousProxy {
8234    pub fn new(channel: fidl::Channel) -> Self {
8235        let protocol_name = <TrustedFlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8236        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8237    }
8238
8239    pub fn into_channel(self) -> fidl::Channel {
8240        self.client.into_channel()
8241    }
8242
8243    /// Waits until an event arrives and returns it. It is safe for other
8244    /// threads to make concurrent requests while waiting for an event.
8245    pub fn wait_for_event(
8246        &self,
8247        deadline: zx::MonotonicInstant,
8248    ) -> Result<TrustedFlatlandEvent, fidl::Error> {
8249        TrustedFlatlandEvent::decode(self.client.wait_for_event(deadline)?)
8250    }
8251
8252    /// Releases an image immediately, without waiting for the next present.
8253    pub fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
8254        self.client.send::<TrustedFlatlandReleaseImageImmediatelyRequest>(
8255            (image_id,),
8256            0x245e1ac080772c8,
8257            fidl::encoding::DynamicFlags::empty(),
8258        )
8259    }
8260}
8261
8262#[cfg(target_os = "fuchsia")]
8263impl From<TrustedFlatlandSynchronousProxy> for zx::NullableHandle {
8264    fn from(value: TrustedFlatlandSynchronousProxy) -> Self {
8265        value.into_channel().into()
8266    }
8267}
8268
8269#[cfg(target_os = "fuchsia")]
8270impl From<fidl::Channel> for TrustedFlatlandSynchronousProxy {
8271    fn from(value: fidl::Channel) -> Self {
8272        Self::new(value)
8273    }
8274}
8275
8276#[cfg(target_os = "fuchsia")]
8277impl fidl::endpoints::FromClient for TrustedFlatlandSynchronousProxy {
8278    type Protocol = TrustedFlatlandMarker;
8279
8280    fn from_client(value: fidl::endpoints::ClientEnd<TrustedFlatlandMarker>) -> Self {
8281        Self::new(value.into_channel())
8282    }
8283}
8284
8285#[derive(Debug, Clone)]
8286pub struct TrustedFlatlandProxy {
8287    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8288}
8289
8290impl fidl::endpoints::Proxy for TrustedFlatlandProxy {
8291    type Protocol = TrustedFlatlandMarker;
8292
8293    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8294        Self::new(inner)
8295    }
8296
8297    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8298        self.client.into_channel().map_err(|client| Self { client })
8299    }
8300
8301    fn as_channel(&self) -> &::fidl::AsyncChannel {
8302        self.client.as_channel()
8303    }
8304}
8305
8306impl TrustedFlatlandProxy {
8307    /// Create a new Proxy for fuchsia.ui.composition/TrustedFlatland.
8308    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8309        let protocol_name = <TrustedFlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8310        Self { client: fidl::client::Client::new(channel, protocol_name) }
8311    }
8312
8313    /// Get a Stream of events from the remote end of the protocol.
8314    ///
8315    /// # Panics
8316    ///
8317    /// Panics if the event stream was already taken.
8318    pub fn take_event_stream(&self) -> TrustedFlatlandEventStream {
8319        TrustedFlatlandEventStream { event_receiver: self.client.take_event_receiver() }
8320    }
8321
8322    /// Releases an image immediately, without waiting for the next present.
8323    pub fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
8324        TrustedFlatlandProxyInterface::r#release_image_immediately(self, image_id)
8325    }
8326}
8327
8328impl TrustedFlatlandProxyInterface for TrustedFlatlandProxy {
8329    fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
8330        self.client.send::<TrustedFlatlandReleaseImageImmediatelyRequest>(
8331            (image_id,),
8332            0x245e1ac080772c8,
8333            fidl::encoding::DynamicFlags::empty(),
8334        )
8335    }
8336}
8337
8338pub struct TrustedFlatlandEventStream {
8339    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8340}
8341
8342impl std::marker::Unpin for TrustedFlatlandEventStream {}
8343
8344impl futures::stream::FusedStream for TrustedFlatlandEventStream {
8345    fn is_terminated(&self) -> bool {
8346        self.event_receiver.is_terminated()
8347    }
8348}
8349
8350impl futures::Stream for TrustedFlatlandEventStream {
8351    type Item = Result<TrustedFlatlandEvent, fidl::Error>;
8352
8353    fn poll_next(
8354        mut self: std::pin::Pin<&mut Self>,
8355        cx: &mut std::task::Context<'_>,
8356    ) -> std::task::Poll<Option<Self::Item>> {
8357        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8358            &mut self.event_receiver,
8359            cx
8360        )?) {
8361            Some(buf) => std::task::Poll::Ready(Some(TrustedFlatlandEvent::decode(buf))),
8362            None => std::task::Poll::Ready(None),
8363        }
8364    }
8365}
8366
8367#[derive(Debug)]
8368pub enum TrustedFlatlandEvent {}
8369
8370impl TrustedFlatlandEvent {
8371    /// Decodes a message buffer as a [`TrustedFlatlandEvent`].
8372    fn decode(
8373        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8374    ) -> Result<TrustedFlatlandEvent, fidl::Error> {
8375        let (bytes, _handles) = buf.split_mut();
8376        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8377        debug_assert_eq!(tx_header.tx_id, 0);
8378        match tx_header.ordinal {
8379            _ => Err(fidl::Error::UnknownOrdinal {
8380                ordinal: tx_header.ordinal,
8381                protocol_name:
8382                    <TrustedFlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8383            }),
8384        }
8385    }
8386}
8387
8388/// A Stream of incoming requests for fuchsia.ui.composition/TrustedFlatland.
8389pub struct TrustedFlatlandRequestStream {
8390    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8391    is_terminated: bool,
8392}
8393
8394impl std::marker::Unpin for TrustedFlatlandRequestStream {}
8395
8396impl futures::stream::FusedStream for TrustedFlatlandRequestStream {
8397    fn is_terminated(&self) -> bool {
8398        self.is_terminated
8399    }
8400}
8401
8402impl fidl::endpoints::RequestStream for TrustedFlatlandRequestStream {
8403    type Protocol = TrustedFlatlandMarker;
8404    type ControlHandle = TrustedFlatlandControlHandle;
8405
8406    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8407        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8408    }
8409
8410    fn control_handle(&self) -> Self::ControlHandle {
8411        TrustedFlatlandControlHandle { inner: self.inner.clone() }
8412    }
8413
8414    fn into_inner(
8415        self,
8416    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8417    {
8418        (self.inner, self.is_terminated)
8419    }
8420
8421    fn from_inner(
8422        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8423        is_terminated: bool,
8424    ) -> Self {
8425        Self { inner, is_terminated }
8426    }
8427}
8428
8429impl futures::Stream for TrustedFlatlandRequestStream {
8430    type Item = Result<TrustedFlatlandRequest, fidl::Error>;
8431
8432    fn poll_next(
8433        mut self: std::pin::Pin<&mut Self>,
8434        cx: &mut std::task::Context<'_>,
8435    ) -> std::task::Poll<Option<Self::Item>> {
8436        let this = &mut *self;
8437        if this.inner.check_shutdown(cx) {
8438            this.is_terminated = true;
8439            return std::task::Poll::Ready(None);
8440        }
8441        if this.is_terminated {
8442            panic!("polled TrustedFlatlandRequestStream after completion");
8443        }
8444        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8445            |bytes, handles| {
8446                match this.inner.channel().read_etc(cx, bytes, handles) {
8447                    std::task::Poll::Ready(Ok(())) => {}
8448                    std::task::Poll::Pending => return std::task::Poll::Pending,
8449                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8450                        this.is_terminated = true;
8451                        return std::task::Poll::Ready(None);
8452                    }
8453                    std::task::Poll::Ready(Err(e)) => {
8454                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8455                            e.into(),
8456                        ))));
8457                    }
8458                }
8459
8460                // A message has been received from the channel
8461                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8462
8463                std::task::Poll::Ready(Some(match header.ordinal {
8464                    0x245e1ac080772c8 => {
8465                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8466                        let mut req = fidl::new_empty!(
8467                            TrustedFlatlandReleaseImageImmediatelyRequest,
8468                            fidl::encoding::DefaultFuchsiaResourceDialect
8469                        );
8470                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TrustedFlatlandReleaseImageImmediatelyRequest>(&header, _body_bytes, handles, &mut req)?;
8471                        let control_handle =
8472                            TrustedFlatlandControlHandle { inner: this.inner.clone() };
8473                        Ok(TrustedFlatlandRequest::ReleaseImageImmediately {
8474                            image_id: req.image_id,
8475
8476                            control_handle,
8477                        })
8478                    }
8479                    _ => Err(fidl::Error::UnknownOrdinal {
8480                        ordinal: header.ordinal,
8481                        protocol_name:
8482                            <TrustedFlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8483                    }),
8484                }))
8485            },
8486        )
8487    }
8488}
8489
8490/// A privileged protocol for trusted Flatland instances that require special capabilities.
8491///
8492/// This protocol is composed into [`fuchsia.ui.composition/Flatland`]. Methods in this protocol
8493/// are only available if the `Flatland` instance was created through
8494/// [`fuchsia.ui.composition/TrustedFlatlandFactory`].
8495#[derive(Debug)]
8496pub enum TrustedFlatlandRequest {
8497    /// Releases an image immediately, without waiting for the next present.
8498    ReleaseImageImmediately { image_id: ContentId, control_handle: TrustedFlatlandControlHandle },
8499}
8500
8501impl TrustedFlatlandRequest {
8502    #[allow(irrefutable_let_patterns)]
8503    pub fn into_release_image_immediately(
8504        self,
8505    ) -> Option<(ContentId, TrustedFlatlandControlHandle)> {
8506        if let TrustedFlatlandRequest::ReleaseImageImmediately { image_id, control_handle } = self {
8507            Some((image_id, control_handle))
8508        } else {
8509            None
8510        }
8511    }
8512
8513    /// Name of the method defined in FIDL
8514    pub fn method_name(&self) -> &'static str {
8515        match *self {
8516            TrustedFlatlandRequest::ReleaseImageImmediately { .. } => "release_image_immediately",
8517        }
8518    }
8519}
8520
8521#[derive(Debug, Clone)]
8522pub struct TrustedFlatlandControlHandle {
8523    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8524}
8525
8526impl fidl::endpoints::ControlHandle for TrustedFlatlandControlHandle {
8527    fn shutdown(&self) {
8528        self.inner.shutdown()
8529    }
8530
8531    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8532        self.inner.shutdown_with_epitaph(status)
8533    }
8534
8535    fn is_closed(&self) -> bool {
8536        self.inner.channel().is_closed()
8537    }
8538    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8539        self.inner.channel().on_closed()
8540    }
8541
8542    #[cfg(target_os = "fuchsia")]
8543    fn signal_peer(
8544        &self,
8545        clear_mask: zx::Signals,
8546        set_mask: zx::Signals,
8547    ) -> Result<(), zx_status::Status> {
8548        use fidl::Peered;
8549        self.inner.channel().signal_peer(clear_mask, set_mask)
8550    }
8551}
8552
8553impl TrustedFlatlandControlHandle {}
8554
8555#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8556pub struct TrustedFlatlandFactoryMarker;
8557
8558impl fidl::endpoints::ProtocolMarker for TrustedFlatlandFactoryMarker {
8559    type Proxy = TrustedFlatlandFactoryProxy;
8560    type RequestStream = TrustedFlatlandFactoryRequestStream;
8561    #[cfg(target_os = "fuchsia")]
8562    type SynchronousProxy = TrustedFlatlandFactorySynchronousProxy;
8563
8564    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.TrustedFlatlandFactory";
8565}
8566impl fidl::endpoints::DiscoverableProtocolMarker for TrustedFlatlandFactoryMarker {}
8567pub type TrustedFlatlandFactoryCreateFlatlandResult = Result<(), TrustedFlatlandFactoryError>;
8568
8569pub trait TrustedFlatlandFactoryProxyInterface: Send + Sync {
8570    type CreateFlatlandResponseFut: std::future::Future<
8571            Output = Result<TrustedFlatlandFactoryCreateFlatlandResult, fidl::Error>,
8572        > + Send;
8573    fn r#create_flatland(
8574        &self,
8575        server_end: fidl::endpoints::ServerEnd<FlatlandMarker>,
8576        config: TrustedFlatlandConfig,
8577    ) -> Self::CreateFlatlandResponseFut;
8578}
8579#[derive(Debug)]
8580#[cfg(target_os = "fuchsia")]
8581pub struct TrustedFlatlandFactorySynchronousProxy {
8582    client: fidl::client::sync::Client,
8583}
8584
8585#[cfg(target_os = "fuchsia")]
8586impl fidl::endpoints::SynchronousProxy for TrustedFlatlandFactorySynchronousProxy {
8587    type Proxy = TrustedFlatlandFactoryProxy;
8588    type Protocol = TrustedFlatlandFactoryMarker;
8589
8590    fn from_channel(inner: fidl::Channel) -> Self {
8591        Self::new(inner)
8592    }
8593
8594    fn into_channel(self) -> fidl::Channel {
8595        self.client.into_channel()
8596    }
8597
8598    fn as_channel(&self) -> &fidl::Channel {
8599        self.client.as_channel()
8600    }
8601}
8602
8603#[cfg(target_os = "fuchsia")]
8604impl TrustedFlatlandFactorySynchronousProxy {
8605    pub fn new(channel: fidl::Channel) -> Self {
8606        let protocol_name =
8607            <TrustedFlatlandFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8608        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8609    }
8610
8611    pub fn into_channel(self) -> fidl::Channel {
8612        self.client.into_channel()
8613    }
8614
8615    /// Waits until an event arrives and returns it. It is safe for other
8616    /// threads to make concurrent requests while waiting for an event.
8617    pub fn wait_for_event(
8618        &self,
8619        deadline: zx::MonotonicInstant,
8620    ) -> Result<TrustedFlatlandFactoryEvent, fidl::Error> {
8621        TrustedFlatlandFactoryEvent::decode(self.client.wait_for_event(deadline)?)
8622    }
8623
8624    /// Creates a new Flatland instance with the specified configuration.
8625    ///
8626    /// ## Error
8627    ///
8628    /// Returns a `TrustedFlatlandFactoryError` error if the operation fails.
8629    pub fn r#create_flatland(
8630        &self,
8631        mut server_end: fidl::endpoints::ServerEnd<FlatlandMarker>,
8632        mut config: TrustedFlatlandConfig,
8633        ___deadline: zx::MonotonicInstant,
8634    ) -> Result<TrustedFlatlandFactoryCreateFlatlandResult, fidl::Error> {
8635        let _response = self.client.send_query::<
8636            TrustedFlatlandFactoryCreateFlatlandRequest,
8637            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, TrustedFlatlandFactoryError>,
8638        >(
8639            (server_end, &mut config,),
8640            0x48e89c53f00561dc,
8641            fidl::encoding::DynamicFlags::empty(),
8642            ___deadline,
8643        )?;
8644        Ok(_response.map(|x| x))
8645    }
8646}
8647
8648#[cfg(target_os = "fuchsia")]
8649impl From<TrustedFlatlandFactorySynchronousProxy> for zx::NullableHandle {
8650    fn from(value: TrustedFlatlandFactorySynchronousProxy) -> Self {
8651        value.into_channel().into()
8652    }
8653}
8654
8655#[cfg(target_os = "fuchsia")]
8656impl From<fidl::Channel> for TrustedFlatlandFactorySynchronousProxy {
8657    fn from(value: fidl::Channel) -> Self {
8658        Self::new(value)
8659    }
8660}
8661
8662#[cfg(target_os = "fuchsia")]
8663impl fidl::endpoints::FromClient for TrustedFlatlandFactorySynchronousProxy {
8664    type Protocol = TrustedFlatlandFactoryMarker;
8665
8666    fn from_client(value: fidl::endpoints::ClientEnd<TrustedFlatlandFactoryMarker>) -> Self {
8667        Self::new(value.into_channel())
8668    }
8669}
8670
8671#[derive(Debug, Clone)]
8672pub struct TrustedFlatlandFactoryProxy {
8673    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8674}
8675
8676impl fidl::endpoints::Proxy for TrustedFlatlandFactoryProxy {
8677    type Protocol = TrustedFlatlandFactoryMarker;
8678
8679    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8680        Self::new(inner)
8681    }
8682
8683    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8684        self.client.into_channel().map_err(|client| Self { client })
8685    }
8686
8687    fn as_channel(&self) -> &::fidl::AsyncChannel {
8688        self.client.as_channel()
8689    }
8690}
8691
8692impl TrustedFlatlandFactoryProxy {
8693    /// Create a new Proxy for fuchsia.ui.composition/TrustedFlatlandFactory.
8694    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8695        let protocol_name =
8696            <TrustedFlatlandFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8697        Self { client: fidl::client::Client::new(channel, protocol_name) }
8698    }
8699
8700    /// Get a Stream of events from the remote end of the protocol.
8701    ///
8702    /// # Panics
8703    ///
8704    /// Panics if the event stream was already taken.
8705    pub fn take_event_stream(&self) -> TrustedFlatlandFactoryEventStream {
8706        TrustedFlatlandFactoryEventStream { event_receiver: self.client.take_event_receiver() }
8707    }
8708
8709    /// Creates a new Flatland instance with the specified configuration.
8710    ///
8711    /// ## Error
8712    ///
8713    /// Returns a `TrustedFlatlandFactoryError` error if the operation fails.
8714    pub fn r#create_flatland(
8715        &self,
8716        mut server_end: fidl::endpoints::ServerEnd<FlatlandMarker>,
8717        mut config: TrustedFlatlandConfig,
8718    ) -> fidl::client::QueryResponseFut<
8719        TrustedFlatlandFactoryCreateFlatlandResult,
8720        fidl::encoding::DefaultFuchsiaResourceDialect,
8721    > {
8722        TrustedFlatlandFactoryProxyInterface::r#create_flatland(self, server_end, config)
8723    }
8724}
8725
8726impl TrustedFlatlandFactoryProxyInterface for TrustedFlatlandFactoryProxy {
8727    type CreateFlatlandResponseFut = fidl::client::QueryResponseFut<
8728        TrustedFlatlandFactoryCreateFlatlandResult,
8729        fidl::encoding::DefaultFuchsiaResourceDialect,
8730    >;
8731    fn r#create_flatland(
8732        &self,
8733        mut server_end: fidl::endpoints::ServerEnd<FlatlandMarker>,
8734        mut config: TrustedFlatlandConfig,
8735    ) -> Self::CreateFlatlandResponseFut {
8736        fn _decode(
8737            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8738        ) -> Result<TrustedFlatlandFactoryCreateFlatlandResult, fidl::Error> {
8739            let _response = fidl::client::decode_transaction_body::<
8740                fidl::encoding::ResultType<
8741                    fidl::encoding::EmptyStruct,
8742                    TrustedFlatlandFactoryError,
8743                >,
8744                fidl::encoding::DefaultFuchsiaResourceDialect,
8745                0x48e89c53f00561dc,
8746            >(_buf?)?;
8747            Ok(_response.map(|x| x))
8748        }
8749        self.client.send_query_and_decode::<
8750            TrustedFlatlandFactoryCreateFlatlandRequest,
8751            TrustedFlatlandFactoryCreateFlatlandResult,
8752        >(
8753            (server_end, &mut config,),
8754            0x48e89c53f00561dc,
8755            fidl::encoding::DynamicFlags::empty(),
8756            _decode,
8757        )
8758    }
8759}
8760
8761pub struct TrustedFlatlandFactoryEventStream {
8762    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8763}
8764
8765impl std::marker::Unpin for TrustedFlatlandFactoryEventStream {}
8766
8767impl futures::stream::FusedStream for TrustedFlatlandFactoryEventStream {
8768    fn is_terminated(&self) -> bool {
8769        self.event_receiver.is_terminated()
8770    }
8771}
8772
8773impl futures::Stream for TrustedFlatlandFactoryEventStream {
8774    type Item = Result<TrustedFlatlandFactoryEvent, fidl::Error>;
8775
8776    fn poll_next(
8777        mut self: std::pin::Pin<&mut Self>,
8778        cx: &mut std::task::Context<'_>,
8779    ) -> std::task::Poll<Option<Self::Item>> {
8780        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8781            &mut self.event_receiver,
8782            cx
8783        )?) {
8784            Some(buf) => std::task::Poll::Ready(Some(TrustedFlatlandFactoryEvent::decode(buf))),
8785            None => std::task::Poll::Ready(None),
8786        }
8787    }
8788}
8789
8790#[derive(Debug)]
8791pub enum TrustedFlatlandFactoryEvent {}
8792
8793impl TrustedFlatlandFactoryEvent {
8794    /// Decodes a message buffer as a [`TrustedFlatlandFactoryEvent`].
8795    fn decode(
8796        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8797    ) -> Result<TrustedFlatlandFactoryEvent, fidl::Error> {
8798        let (bytes, _handles) = buf.split_mut();
8799        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8800        debug_assert_eq!(tx_header.tx_id, 0);
8801        match tx_header.ordinal {
8802            _ => Err(fidl::Error::UnknownOrdinal {
8803                ordinal: tx_header.ordinal,
8804                protocol_name:
8805                    <TrustedFlatlandFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8806            }),
8807        }
8808    }
8809}
8810
8811/// A Stream of incoming requests for fuchsia.ui.composition/TrustedFlatlandFactory.
8812pub struct TrustedFlatlandFactoryRequestStream {
8813    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8814    is_terminated: bool,
8815}
8816
8817impl std::marker::Unpin for TrustedFlatlandFactoryRequestStream {}
8818
8819impl futures::stream::FusedStream for TrustedFlatlandFactoryRequestStream {
8820    fn is_terminated(&self) -> bool {
8821        self.is_terminated
8822    }
8823}
8824
8825impl fidl::endpoints::RequestStream for TrustedFlatlandFactoryRequestStream {
8826    type Protocol = TrustedFlatlandFactoryMarker;
8827    type ControlHandle = TrustedFlatlandFactoryControlHandle;
8828
8829    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8830        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8831    }
8832
8833    fn control_handle(&self) -> Self::ControlHandle {
8834        TrustedFlatlandFactoryControlHandle { inner: self.inner.clone() }
8835    }
8836
8837    fn into_inner(
8838        self,
8839    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8840    {
8841        (self.inner, self.is_terminated)
8842    }
8843
8844    fn from_inner(
8845        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8846        is_terminated: bool,
8847    ) -> Self {
8848        Self { inner, is_terminated }
8849    }
8850}
8851
8852impl futures::Stream for TrustedFlatlandFactoryRequestStream {
8853    type Item = Result<TrustedFlatlandFactoryRequest, fidl::Error>;
8854
8855    fn poll_next(
8856        mut self: std::pin::Pin<&mut Self>,
8857        cx: &mut std::task::Context<'_>,
8858    ) -> std::task::Poll<Option<Self::Item>> {
8859        let this = &mut *self;
8860        if this.inner.check_shutdown(cx) {
8861            this.is_terminated = true;
8862            return std::task::Poll::Ready(None);
8863        }
8864        if this.is_terminated {
8865            panic!("polled TrustedFlatlandFactoryRequestStream after completion");
8866        }
8867        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8868            |bytes, handles| {
8869                match this.inner.channel().read_etc(cx, bytes, handles) {
8870                    std::task::Poll::Ready(Ok(())) => {}
8871                    std::task::Poll::Pending => return std::task::Poll::Pending,
8872                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8873                        this.is_terminated = true;
8874                        return std::task::Poll::Ready(None);
8875                    }
8876                    std::task::Poll::Ready(Err(e)) => {
8877                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8878                            e.into(),
8879                        ))));
8880                    }
8881                }
8882
8883                // A message has been received from the channel
8884                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8885
8886                std::task::Poll::Ready(Some(match header.ordinal {
8887                0x48e89c53f00561dc => {
8888                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8889                    let mut req = fidl::new_empty!(TrustedFlatlandFactoryCreateFlatlandRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8890                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TrustedFlatlandFactoryCreateFlatlandRequest>(&header, _body_bytes, handles, &mut req)?;
8891                    let control_handle = TrustedFlatlandFactoryControlHandle {
8892                        inner: this.inner.clone(),
8893                    };
8894                    Ok(TrustedFlatlandFactoryRequest::CreateFlatland {server_end: req.server_end,
8895config: req.config,
8896
8897                        responder: TrustedFlatlandFactoryCreateFlatlandResponder {
8898                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8899                            tx_id: header.tx_id,
8900                        },
8901                    })
8902                }
8903                _ => Err(fidl::Error::UnknownOrdinal {
8904                    ordinal: header.ordinal,
8905                    protocol_name: <TrustedFlatlandFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8906                }),
8907            }))
8908            },
8909        )
8910    }
8911}
8912
8913/// A privileged factory for creating Flatland instances with special configurations.
8914///
8915/// This protocol is intended for trusted clients that require fine-grained control over
8916/// Flatland's behavior for performance-critical applications. It is not intended for
8917/// general use. Misuse of this API can negatively impact system performance and stability.
8918#[derive(Debug)]
8919pub enum TrustedFlatlandFactoryRequest {
8920    /// Creates a new Flatland instance with the specified configuration.
8921    ///
8922    /// ## Error
8923    ///
8924    /// Returns a `TrustedFlatlandFactoryError` error if the operation fails.
8925    CreateFlatland {
8926        server_end: fidl::endpoints::ServerEnd<FlatlandMarker>,
8927        config: TrustedFlatlandConfig,
8928        responder: TrustedFlatlandFactoryCreateFlatlandResponder,
8929    },
8930}
8931
8932impl TrustedFlatlandFactoryRequest {
8933    #[allow(irrefutable_let_patterns)]
8934    pub fn into_create_flatland(
8935        self,
8936    ) -> Option<(
8937        fidl::endpoints::ServerEnd<FlatlandMarker>,
8938        TrustedFlatlandConfig,
8939        TrustedFlatlandFactoryCreateFlatlandResponder,
8940    )> {
8941        if let TrustedFlatlandFactoryRequest::CreateFlatland { server_end, config, responder } =
8942            self
8943        {
8944            Some((server_end, config, responder))
8945        } else {
8946            None
8947        }
8948    }
8949
8950    /// Name of the method defined in FIDL
8951    pub fn method_name(&self) -> &'static str {
8952        match *self {
8953            TrustedFlatlandFactoryRequest::CreateFlatland { .. } => "create_flatland",
8954        }
8955    }
8956}
8957
8958#[derive(Debug, Clone)]
8959pub struct TrustedFlatlandFactoryControlHandle {
8960    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8961}
8962
8963impl fidl::endpoints::ControlHandle for TrustedFlatlandFactoryControlHandle {
8964    fn shutdown(&self) {
8965        self.inner.shutdown()
8966    }
8967
8968    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8969        self.inner.shutdown_with_epitaph(status)
8970    }
8971
8972    fn is_closed(&self) -> bool {
8973        self.inner.channel().is_closed()
8974    }
8975    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8976        self.inner.channel().on_closed()
8977    }
8978
8979    #[cfg(target_os = "fuchsia")]
8980    fn signal_peer(
8981        &self,
8982        clear_mask: zx::Signals,
8983        set_mask: zx::Signals,
8984    ) -> Result<(), zx_status::Status> {
8985        use fidl::Peered;
8986        self.inner.channel().signal_peer(clear_mask, set_mask)
8987    }
8988}
8989
8990impl TrustedFlatlandFactoryControlHandle {}
8991
8992#[must_use = "FIDL methods require a response to be sent"]
8993#[derive(Debug)]
8994pub struct TrustedFlatlandFactoryCreateFlatlandResponder {
8995    control_handle: std::mem::ManuallyDrop<TrustedFlatlandFactoryControlHandle>,
8996    tx_id: u32,
8997}
8998
8999/// Set the the channel to be shutdown (see [`TrustedFlatlandFactoryControlHandle::shutdown`])
9000/// if the responder is dropped without sending a response, so that the client
9001/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9002impl std::ops::Drop for TrustedFlatlandFactoryCreateFlatlandResponder {
9003    fn drop(&mut self) {
9004        self.control_handle.shutdown();
9005        // Safety: drops once, never accessed again
9006        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9007    }
9008}
9009
9010impl fidl::endpoints::Responder for TrustedFlatlandFactoryCreateFlatlandResponder {
9011    type ControlHandle = TrustedFlatlandFactoryControlHandle;
9012
9013    fn control_handle(&self) -> &TrustedFlatlandFactoryControlHandle {
9014        &self.control_handle
9015    }
9016
9017    fn drop_without_shutdown(mut self) {
9018        // Safety: drops once, never accessed again due to mem::forget
9019        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9020        // Prevent Drop from running (which would shut down the channel)
9021        std::mem::forget(self);
9022    }
9023}
9024
9025impl TrustedFlatlandFactoryCreateFlatlandResponder {
9026    /// Sends a response to the FIDL transaction.
9027    ///
9028    /// Sets the channel to shutdown if an error occurs.
9029    pub fn send(
9030        self,
9031        mut result: Result<(), TrustedFlatlandFactoryError>,
9032    ) -> Result<(), fidl::Error> {
9033        let _result = self.send_raw(result);
9034        if _result.is_err() {
9035            self.control_handle.shutdown();
9036        }
9037        self.drop_without_shutdown();
9038        _result
9039    }
9040
9041    /// Similar to "send" but does not shutdown the channel if an error occurs.
9042    pub fn send_no_shutdown_on_err(
9043        self,
9044        mut result: Result<(), TrustedFlatlandFactoryError>,
9045    ) -> Result<(), fidl::Error> {
9046        let _result = self.send_raw(result);
9047        self.drop_without_shutdown();
9048        _result
9049    }
9050
9051    fn send_raw(
9052        &self,
9053        mut result: Result<(), TrustedFlatlandFactoryError>,
9054    ) -> Result<(), fidl::Error> {
9055        self.control_handle.inner.send::<fidl::encoding::ResultType<
9056            fidl::encoding::EmptyStruct,
9057            TrustedFlatlandFactoryError,
9058        >>(
9059            result,
9060            self.tx_id,
9061            0x48e89c53f00561dc,
9062            fidl::encoding::DynamicFlags::empty(),
9063        )
9064    }
9065}
9066
9067mod internal {
9068    use super::*;
9069
9070    impl fidl::encoding::ResourceTypeMarker for AllocatorRegisterBufferCollectionRequest {
9071        type Borrowed<'a> = &'a mut Self;
9072        fn take_or_borrow<'a>(
9073            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9074        ) -> Self::Borrowed<'a> {
9075            value
9076        }
9077    }
9078
9079    unsafe impl fidl::encoding::TypeMarker for AllocatorRegisterBufferCollectionRequest {
9080        type Owned = Self;
9081
9082        #[inline(always)]
9083        fn inline_align(_context: fidl::encoding::Context) -> usize {
9084            8
9085        }
9086
9087        #[inline(always)]
9088        fn inline_size(_context: fidl::encoding::Context) -> usize {
9089            16
9090        }
9091    }
9092
9093    unsafe impl
9094        fidl::encoding::Encode<
9095            AllocatorRegisterBufferCollectionRequest,
9096            fidl::encoding::DefaultFuchsiaResourceDialect,
9097        > for &mut AllocatorRegisterBufferCollectionRequest
9098    {
9099        #[inline]
9100        unsafe fn encode(
9101            self,
9102            encoder: &mut fidl::encoding::Encoder<
9103                '_,
9104                fidl::encoding::DefaultFuchsiaResourceDialect,
9105            >,
9106            offset: usize,
9107            _depth: fidl::encoding::Depth,
9108        ) -> fidl::Result<()> {
9109            encoder.debug_check_bounds::<AllocatorRegisterBufferCollectionRequest>(offset);
9110            // Delegate to tuple encoding.
9111            fidl::encoding::Encode::<AllocatorRegisterBufferCollectionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9112                (
9113                    <RegisterBufferCollectionArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.args),
9114                ),
9115                encoder, offset, _depth
9116            )
9117        }
9118    }
9119    unsafe impl<
9120        T0: fidl::encoding::Encode<
9121                RegisterBufferCollectionArgs,
9122                fidl::encoding::DefaultFuchsiaResourceDialect,
9123            >,
9124    >
9125        fidl::encoding::Encode<
9126            AllocatorRegisterBufferCollectionRequest,
9127            fidl::encoding::DefaultFuchsiaResourceDialect,
9128        > for (T0,)
9129    {
9130        #[inline]
9131        unsafe fn encode(
9132            self,
9133            encoder: &mut fidl::encoding::Encoder<
9134                '_,
9135                fidl::encoding::DefaultFuchsiaResourceDialect,
9136            >,
9137            offset: usize,
9138            depth: fidl::encoding::Depth,
9139        ) -> fidl::Result<()> {
9140            encoder.debug_check_bounds::<AllocatorRegisterBufferCollectionRequest>(offset);
9141            // Zero out padding regions. There's no need to apply masks
9142            // because the unmasked parts will be overwritten by fields.
9143            // Write the fields.
9144            self.0.encode(encoder, offset + 0, depth)?;
9145            Ok(())
9146        }
9147    }
9148
9149    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9150        for AllocatorRegisterBufferCollectionRequest
9151    {
9152        #[inline(always)]
9153        fn new_empty() -> Self {
9154            Self {
9155                args: fidl::new_empty!(
9156                    RegisterBufferCollectionArgs,
9157                    fidl::encoding::DefaultFuchsiaResourceDialect
9158                ),
9159            }
9160        }
9161
9162        #[inline]
9163        unsafe fn decode(
9164            &mut self,
9165            decoder: &mut fidl::encoding::Decoder<
9166                '_,
9167                fidl::encoding::DefaultFuchsiaResourceDialect,
9168            >,
9169            offset: usize,
9170            _depth: fidl::encoding::Depth,
9171        ) -> fidl::Result<()> {
9172            decoder.debug_check_bounds::<Self>(offset);
9173            // Verify that padding bytes are zero.
9174            fidl::decode!(
9175                RegisterBufferCollectionArgs,
9176                fidl::encoding::DefaultFuchsiaResourceDialect,
9177                &mut self.args,
9178                decoder,
9179                offset + 0,
9180                _depth
9181            )?;
9182            Ok(())
9183        }
9184    }
9185
9186    impl fidl::encoding::ResourceTypeMarker for BufferCollectionExportToken {
9187        type Borrowed<'a> = &'a mut Self;
9188        fn take_or_borrow<'a>(
9189            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9190        ) -> Self::Borrowed<'a> {
9191            value
9192        }
9193    }
9194
9195    unsafe impl fidl::encoding::TypeMarker for BufferCollectionExportToken {
9196        type Owned = Self;
9197
9198        #[inline(always)]
9199        fn inline_align(_context: fidl::encoding::Context) -> usize {
9200            4
9201        }
9202
9203        #[inline(always)]
9204        fn inline_size(_context: fidl::encoding::Context) -> usize {
9205            4
9206        }
9207    }
9208
9209    unsafe impl
9210        fidl::encoding::Encode<
9211            BufferCollectionExportToken,
9212            fidl::encoding::DefaultFuchsiaResourceDialect,
9213        > for &mut BufferCollectionExportToken
9214    {
9215        #[inline]
9216        unsafe fn encode(
9217            self,
9218            encoder: &mut fidl::encoding::Encoder<
9219                '_,
9220                fidl::encoding::DefaultFuchsiaResourceDialect,
9221            >,
9222            offset: usize,
9223            _depth: fidl::encoding::Depth,
9224        ) -> fidl::Result<()> {
9225            encoder.debug_check_bounds::<BufferCollectionExportToken>(offset);
9226            // Delegate to tuple encoding.
9227            fidl::encoding::Encode::<
9228                BufferCollectionExportToken,
9229                fidl::encoding::DefaultFuchsiaResourceDialect,
9230            >::encode(
9231                (<fidl::encoding::HandleType<
9232                    fidl::EventPair,
9233                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9234                    2147483648,
9235                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9236                    &mut self.value
9237                ),),
9238                encoder,
9239                offset,
9240                _depth,
9241            )
9242        }
9243    }
9244    unsafe impl<
9245        T0: fidl::encoding::Encode<
9246                fidl::encoding::HandleType<
9247                    fidl::EventPair,
9248                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9249                    2147483648,
9250                >,
9251                fidl::encoding::DefaultFuchsiaResourceDialect,
9252            >,
9253    >
9254        fidl::encoding::Encode<
9255            BufferCollectionExportToken,
9256            fidl::encoding::DefaultFuchsiaResourceDialect,
9257        > for (T0,)
9258    {
9259        #[inline]
9260        unsafe fn encode(
9261            self,
9262            encoder: &mut fidl::encoding::Encoder<
9263                '_,
9264                fidl::encoding::DefaultFuchsiaResourceDialect,
9265            >,
9266            offset: usize,
9267            depth: fidl::encoding::Depth,
9268        ) -> fidl::Result<()> {
9269            encoder.debug_check_bounds::<BufferCollectionExportToken>(offset);
9270            // Zero out padding regions. There's no need to apply masks
9271            // because the unmasked parts will be overwritten by fields.
9272            // Write the fields.
9273            self.0.encode(encoder, offset + 0, depth)?;
9274            Ok(())
9275        }
9276    }
9277
9278    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9279        for BufferCollectionExportToken
9280    {
9281        #[inline(always)]
9282        fn new_empty() -> Self {
9283            Self {
9284                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9285            }
9286        }
9287
9288        #[inline]
9289        unsafe fn decode(
9290            &mut self,
9291            decoder: &mut fidl::encoding::Decoder<
9292                '_,
9293                fidl::encoding::DefaultFuchsiaResourceDialect,
9294            >,
9295            offset: usize,
9296            _depth: fidl::encoding::Depth,
9297        ) -> fidl::Result<()> {
9298            decoder.debug_check_bounds::<Self>(offset);
9299            // Verify that padding bytes are zero.
9300            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
9301            Ok(())
9302        }
9303    }
9304
9305    impl fidl::encoding::ResourceTypeMarker for BufferCollectionImportToken {
9306        type Borrowed<'a> = &'a mut Self;
9307        fn take_or_borrow<'a>(
9308            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9309        ) -> Self::Borrowed<'a> {
9310            value
9311        }
9312    }
9313
9314    unsafe impl fidl::encoding::TypeMarker for BufferCollectionImportToken {
9315        type Owned = Self;
9316
9317        #[inline(always)]
9318        fn inline_align(_context: fidl::encoding::Context) -> usize {
9319            4
9320        }
9321
9322        #[inline(always)]
9323        fn inline_size(_context: fidl::encoding::Context) -> usize {
9324            4
9325        }
9326    }
9327
9328    unsafe impl
9329        fidl::encoding::Encode<
9330            BufferCollectionImportToken,
9331            fidl::encoding::DefaultFuchsiaResourceDialect,
9332        > for &mut BufferCollectionImportToken
9333    {
9334        #[inline]
9335        unsafe fn encode(
9336            self,
9337            encoder: &mut fidl::encoding::Encoder<
9338                '_,
9339                fidl::encoding::DefaultFuchsiaResourceDialect,
9340            >,
9341            offset: usize,
9342            _depth: fidl::encoding::Depth,
9343        ) -> fidl::Result<()> {
9344            encoder.debug_check_bounds::<BufferCollectionImportToken>(offset);
9345            // Delegate to tuple encoding.
9346            fidl::encoding::Encode::<
9347                BufferCollectionImportToken,
9348                fidl::encoding::DefaultFuchsiaResourceDialect,
9349            >::encode(
9350                (<fidl::encoding::HandleType<
9351                    fidl::EventPair,
9352                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9353                    2147483648,
9354                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9355                    &mut self.value
9356                ),),
9357                encoder,
9358                offset,
9359                _depth,
9360            )
9361        }
9362    }
9363    unsafe impl<
9364        T0: fidl::encoding::Encode<
9365                fidl::encoding::HandleType<
9366                    fidl::EventPair,
9367                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9368                    2147483648,
9369                >,
9370                fidl::encoding::DefaultFuchsiaResourceDialect,
9371            >,
9372    >
9373        fidl::encoding::Encode<
9374            BufferCollectionImportToken,
9375            fidl::encoding::DefaultFuchsiaResourceDialect,
9376        > for (T0,)
9377    {
9378        #[inline]
9379        unsafe fn encode(
9380            self,
9381            encoder: &mut fidl::encoding::Encoder<
9382                '_,
9383                fidl::encoding::DefaultFuchsiaResourceDialect,
9384            >,
9385            offset: usize,
9386            depth: fidl::encoding::Depth,
9387        ) -> fidl::Result<()> {
9388            encoder.debug_check_bounds::<BufferCollectionImportToken>(offset);
9389            // Zero out padding regions. There's no need to apply masks
9390            // because the unmasked parts will be overwritten by fields.
9391            // Write the fields.
9392            self.0.encode(encoder, offset + 0, depth)?;
9393            Ok(())
9394        }
9395    }
9396
9397    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9398        for BufferCollectionImportToken
9399    {
9400        #[inline(always)]
9401        fn new_empty() -> Self {
9402            Self {
9403                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9404            }
9405        }
9406
9407        #[inline]
9408        unsafe fn decode(
9409            &mut self,
9410            decoder: &mut fidl::encoding::Decoder<
9411                '_,
9412                fidl::encoding::DefaultFuchsiaResourceDialect,
9413            >,
9414            offset: usize,
9415            _depth: fidl::encoding::Depth,
9416        ) -> fidl::Result<()> {
9417            decoder.debug_check_bounds::<Self>(offset);
9418            // Verify that padding bytes are zero.
9419            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
9420            Ok(())
9421        }
9422    }
9423
9424    impl fidl::encoding::ResourceTypeMarker for ChildViewWatcherGetViewRefResponse {
9425        type Borrowed<'a> = &'a mut Self;
9426        fn take_or_borrow<'a>(
9427            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9428        ) -> Self::Borrowed<'a> {
9429            value
9430        }
9431    }
9432
9433    unsafe impl fidl::encoding::TypeMarker for ChildViewWatcherGetViewRefResponse {
9434        type Owned = Self;
9435
9436        #[inline(always)]
9437        fn inline_align(_context: fidl::encoding::Context) -> usize {
9438            4
9439        }
9440
9441        #[inline(always)]
9442        fn inline_size(_context: fidl::encoding::Context) -> usize {
9443            4
9444        }
9445    }
9446
9447    unsafe impl
9448        fidl::encoding::Encode<
9449            ChildViewWatcherGetViewRefResponse,
9450            fidl::encoding::DefaultFuchsiaResourceDialect,
9451        > for &mut ChildViewWatcherGetViewRefResponse
9452    {
9453        #[inline]
9454        unsafe fn encode(
9455            self,
9456            encoder: &mut fidl::encoding::Encoder<
9457                '_,
9458                fidl::encoding::DefaultFuchsiaResourceDialect,
9459            >,
9460            offset: usize,
9461            _depth: fidl::encoding::Depth,
9462        ) -> fidl::Result<()> {
9463            encoder.debug_check_bounds::<ChildViewWatcherGetViewRefResponse>(offset);
9464            // Delegate to tuple encoding.
9465            fidl::encoding::Encode::<ChildViewWatcherGetViewRefResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9466                (
9467                    <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_ref),
9468                ),
9469                encoder, offset, _depth
9470            )
9471        }
9472    }
9473    unsafe impl<
9474        T0: fidl::encoding::Encode<
9475                fidl_fuchsia_ui_views::ViewRef,
9476                fidl::encoding::DefaultFuchsiaResourceDialect,
9477            >,
9478    >
9479        fidl::encoding::Encode<
9480            ChildViewWatcherGetViewRefResponse,
9481            fidl::encoding::DefaultFuchsiaResourceDialect,
9482        > for (T0,)
9483    {
9484        #[inline]
9485        unsafe fn encode(
9486            self,
9487            encoder: &mut fidl::encoding::Encoder<
9488                '_,
9489                fidl::encoding::DefaultFuchsiaResourceDialect,
9490            >,
9491            offset: usize,
9492            depth: fidl::encoding::Depth,
9493        ) -> fidl::Result<()> {
9494            encoder.debug_check_bounds::<ChildViewWatcherGetViewRefResponse>(offset);
9495            // Zero out padding regions. There's no need to apply masks
9496            // because the unmasked parts will be overwritten by fields.
9497            // Write the fields.
9498            self.0.encode(encoder, offset + 0, depth)?;
9499            Ok(())
9500        }
9501    }
9502
9503    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9504        for ChildViewWatcherGetViewRefResponse
9505    {
9506        #[inline(always)]
9507        fn new_empty() -> Self {
9508            Self {
9509                view_ref: fidl::new_empty!(
9510                    fidl_fuchsia_ui_views::ViewRef,
9511                    fidl::encoding::DefaultFuchsiaResourceDialect
9512                ),
9513            }
9514        }
9515
9516        #[inline]
9517        unsafe fn decode(
9518            &mut self,
9519            decoder: &mut fidl::encoding::Decoder<
9520                '_,
9521                fidl::encoding::DefaultFuchsiaResourceDialect,
9522            >,
9523            offset: usize,
9524            _depth: fidl::encoding::Depth,
9525        ) -> fidl::Result<()> {
9526            decoder.debug_check_bounds::<Self>(offset);
9527            // Verify that padding bytes are zero.
9528            fidl::decode!(
9529                fidl_fuchsia_ui_views::ViewRef,
9530                fidl::encoding::DefaultFuchsiaResourceDialect,
9531                &mut self.view_ref,
9532                decoder,
9533                offset + 0,
9534                _depth
9535            )?;
9536            Ok(())
9537        }
9538    }
9539
9540    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateFilledRectRequest {
9541        type Borrowed<'a> = &'a mut Self;
9542        fn take_or_borrow<'a>(
9543            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9544        ) -> Self::Borrowed<'a> {
9545            value
9546        }
9547    }
9548
9549    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateFilledRectRequest {
9550        type Owned = Self;
9551
9552        #[inline(always)]
9553        fn inline_align(_context: fidl::encoding::Context) -> usize {
9554            8
9555        }
9556
9557        #[inline(always)]
9558        fn inline_size(_context: fidl::encoding::Context) -> usize {
9559            8
9560        }
9561        #[inline(always)]
9562        fn encode_is_copy() -> bool {
9563            true
9564        }
9565
9566        #[inline(always)]
9567        fn decode_is_copy() -> bool {
9568            true
9569        }
9570    }
9571
9572    unsafe impl
9573        fidl::encoding::Encode<
9574            FlatlandCreateFilledRectRequest,
9575            fidl::encoding::DefaultFuchsiaResourceDialect,
9576        > for &mut FlatlandCreateFilledRectRequest
9577    {
9578        #[inline]
9579        unsafe fn encode(
9580            self,
9581            encoder: &mut fidl::encoding::Encoder<
9582                '_,
9583                fidl::encoding::DefaultFuchsiaResourceDialect,
9584            >,
9585            offset: usize,
9586            _depth: fidl::encoding::Depth,
9587        ) -> fidl::Result<()> {
9588            encoder.debug_check_bounds::<FlatlandCreateFilledRectRequest>(offset);
9589            unsafe {
9590                // Copy the object into the buffer.
9591                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
9592                (buf_ptr as *mut FlatlandCreateFilledRectRequest)
9593                    .write_unaligned((self as *const FlatlandCreateFilledRectRequest).read());
9594                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
9595                // done second because the memcpy will write garbage to these bytes.
9596            }
9597            Ok(())
9598        }
9599    }
9600    unsafe impl<
9601        T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>,
9602    >
9603        fidl::encoding::Encode<
9604            FlatlandCreateFilledRectRequest,
9605            fidl::encoding::DefaultFuchsiaResourceDialect,
9606        > for (T0,)
9607    {
9608        #[inline]
9609        unsafe fn encode(
9610            self,
9611            encoder: &mut fidl::encoding::Encoder<
9612                '_,
9613                fidl::encoding::DefaultFuchsiaResourceDialect,
9614            >,
9615            offset: usize,
9616            depth: fidl::encoding::Depth,
9617        ) -> fidl::Result<()> {
9618            encoder.debug_check_bounds::<FlatlandCreateFilledRectRequest>(offset);
9619            // Zero out padding regions. There's no need to apply masks
9620            // because the unmasked parts will be overwritten by fields.
9621            // Write the fields.
9622            self.0.encode(encoder, offset + 0, depth)?;
9623            Ok(())
9624        }
9625    }
9626
9627    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9628        for FlatlandCreateFilledRectRequest
9629    {
9630        #[inline(always)]
9631        fn new_empty() -> Self {
9632            Self {
9633                rect_id: fidl::new_empty!(ContentId, fidl::encoding::DefaultFuchsiaResourceDialect),
9634            }
9635        }
9636
9637        #[inline]
9638        unsafe fn decode(
9639            &mut self,
9640            decoder: &mut fidl::encoding::Decoder<
9641                '_,
9642                fidl::encoding::DefaultFuchsiaResourceDialect,
9643            >,
9644            offset: usize,
9645            _depth: fidl::encoding::Depth,
9646        ) -> fidl::Result<()> {
9647            decoder.debug_check_bounds::<Self>(offset);
9648            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
9649            // Verify that padding bytes are zero.
9650            // Copy from the buffer into the object.
9651            unsafe {
9652                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
9653            }
9654            Ok(())
9655        }
9656    }
9657
9658    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateImageRequest {
9659        type Borrowed<'a> = &'a mut Self;
9660        fn take_or_borrow<'a>(
9661            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9662        ) -> Self::Borrowed<'a> {
9663            value
9664        }
9665    }
9666
9667    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateImageRequest {
9668        type Owned = Self;
9669
9670        #[inline(always)]
9671        fn inline_align(_context: fidl::encoding::Context) -> usize {
9672            8
9673        }
9674
9675        #[inline(always)]
9676        fn inline_size(_context: fidl::encoding::Context) -> usize {
9677            32
9678        }
9679    }
9680
9681    unsafe impl
9682        fidl::encoding::Encode<
9683            FlatlandCreateImageRequest,
9684            fidl::encoding::DefaultFuchsiaResourceDialect,
9685        > for &mut FlatlandCreateImageRequest
9686    {
9687        #[inline]
9688        unsafe fn encode(
9689            self,
9690            encoder: &mut fidl::encoding::Encoder<
9691                '_,
9692                fidl::encoding::DefaultFuchsiaResourceDialect,
9693            >,
9694            offset: usize,
9695            _depth: fidl::encoding::Depth,
9696        ) -> fidl::Result<()> {
9697            encoder.debug_check_bounds::<FlatlandCreateImageRequest>(offset);
9698            // Delegate to tuple encoding.
9699            fidl::encoding::Encode::<FlatlandCreateImageRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9700                (
9701                    <ContentId as fidl::encoding::ValueTypeMarker>::borrow(&self.image_id),
9702                    <BufferCollectionImportToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.import_token),
9703                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_index),
9704                    <ImageProperties as fidl::encoding::ValueTypeMarker>::borrow(&self.properties),
9705                ),
9706                encoder, offset, _depth
9707            )
9708        }
9709    }
9710    unsafe impl<
9711        T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>,
9712        T1: fidl::encoding::Encode<
9713                BufferCollectionImportToken,
9714                fidl::encoding::DefaultFuchsiaResourceDialect,
9715            >,
9716        T2: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
9717        T3: fidl::encoding::Encode<ImageProperties, fidl::encoding::DefaultFuchsiaResourceDialect>,
9718    >
9719        fidl::encoding::Encode<
9720            FlatlandCreateImageRequest,
9721            fidl::encoding::DefaultFuchsiaResourceDialect,
9722        > for (T0, T1, T2, T3)
9723    {
9724        #[inline]
9725        unsafe fn encode(
9726            self,
9727            encoder: &mut fidl::encoding::Encoder<
9728                '_,
9729                fidl::encoding::DefaultFuchsiaResourceDialect,
9730            >,
9731            offset: usize,
9732            depth: fidl::encoding::Depth,
9733        ) -> fidl::Result<()> {
9734            encoder.debug_check_bounds::<FlatlandCreateImageRequest>(offset);
9735            // Zero out padding regions. There's no need to apply masks
9736            // because the unmasked parts will be overwritten by fields.
9737            // Write the fields.
9738            self.0.encode(encoder, offset + 0, depth)?;
9739            self.1.encode(encoder, offset + 8, depth)?;
9740            self.2.encode(encoder, offset + 12, depth)?;
9741            self.3.encode(encoder, offset + 16, depth)?;
9742            Ok(())
9743        }
9744    }
9745
9746    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9747        for FlatlandCreateImageRequest
9748    {
9749        #[inline(always)]
9750        fn new_empty() -> Self {
9751            Self {
9752                image_id: fidl::new_empty!(
9753                    ContentId,
9754                    fidl::encoding::DefaultFuchsiaResourceDialect
9755                ),
9756                import_token: fidl::new_empty!(
9757                    BufferCollectionImportToken,
9758                    fidl::encoding::DefaultFuchsiaResourceDialect
9759                ),
9760                vmo_index: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
9761                properties: fidl::new_empty!(
9762                    ImageProperties,
9763                    fidl::encoding::DefaultFuchsiaResourceDialect
9764                ),
9765            }
9766        }
9767
9768        #[inline]
9769        unsafe fn decode(
9770            &mut self,
9771            decoder: &mut fidl::encoding::Decoder<
9772                '_,
9773                fidl::encoding::DefaultFuchsiaResourceDialect,
9774            >,
9775            offset: usize,
9776            _depth: fidl::encoding::Depth,
9777        ) -> fidl::Result<()> {
9778            decoder.debug_check_bounds::<Self>(offset);
9779            // Verify that padding bytes are zero.
9780            fidl::decode!(
9781                ContentId,
9782                fidl::encoding::DefaultFuchsiaResourceDialect,
9783                &mut self.image_id,
9784                decoder,
9785                offset + 0,
9786                _depth
9787            )?;
9788            fidl::decode!(
9789                BufferCollectionImportToken,
9790                fidl::encoding::DefaultFuchsiaResourceDialect,
9791                &mut self.import_token,
9792                decoder,
9793                offset + 8,
9794                _depth
9795            )?;
9796            fidl::decode!(
9797                u32,
9798                fidl::encoding::DefaultFuchsiaResourceDialect,
9799                &mut self.vmo_index,
9800                decoder,
9801                offset + 12,
9802                _depth
9803            )?;
9804            fidl::decode!(
9805                ImageProperties,
9806                fidl::encoding::DefaultFuchsiaResourceDialect,
9807                &mut self.properties,
9808                decoder,
9809                offset + 16,
9810                _depth
9811            )?;
9812            Ok(())
9813        }
9814    }
9815
9816    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateView2Request {
9817        type Borrowed<'a> = &'a mut Self;
9818        fn take_or_borrow<'a>(
9819            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9820        ) -> Self::Borrowed<'a> {
9821            value
9822        }
9823    }
9824
9825    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateView2Request {
9826        type Owned = Self;
9827
9828        #[inline(always)]
9829        fn inline_align(_context: fidl::encoding::Context) -> usize {
9830            8
9831        }
9832
9833        #[inline(always)]
9834        fn inline_size(_context: fidl::encoding::Context) -> usize {
9835            40
9836        }
9837    }
9838
9839    unsafe impl
9840        fidl::encoding::Encode<
9841            FlatlandCreateView2Request,
9842            fidl::encoding::DefaultFuchsiaResourceDialect,
9843        > for &mut FlatlandCreateView2Request
9844    {
9845        #[inline]
9846        unsafe fn encode(
9847            self,
9848            encoder: &mut fidl::encoding::Encoder<
9849                '_,
9850                fidl::encoding::DefaultFuchsiaResourceDialect,
9851            >,
9852            offset: usize,
9853            _depth: fidl::encoding::Depth,
9854        ) -> fidl::Result<()> {
9855            encoder.debug_check_bounds::<FlatlandCreateView2Request>(offset);
9856            // Delegate to tuple encoding.
9857            fidl::encoding::Encode::<FlatlandCreateView2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9858                (
9859                    <fidl_fuchsia_ui_views::ViewCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
9860                    <fidl_fuchsia_ui_views::ViewIdentityOnCreation as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_identity),
9861                    <ViewBoundProtocols as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.protocols),
9862                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.parent_viewport_watcher),
9863                ),
9864                encoder, offset, _depth
9865            )
9866        }
9867    }
9868    unsafe impl<
9869        T0: fidl::encoding::Encode<
9870                fidl_fuchsia_ui_views::ViewCreationToken,
9871                fidl::encoding::DefaultFuchsiaResourceDialect,
9872            >,
9873        T1: fidl::encoding::Encode<
9874                fidl_fuchsia_ui_views::ViewIdentityOnCreation,
9875                fidl::encoding::DefaultFuchsiaResourceDialect,
9876            >,
9877        T2: fidl::encoding::Encode<ViewBoundProtocols, fidl::encoding::DefaultFuchsiaResourceDialect>,
9878        T3: fidl::encoding::Encode<
9879                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
9880                fidl::encoding::DefaultFuchsiaResourceDialect,
9881            >,
9882    >
9883        fidl::encoding::Encode<
9884            FlatlandCreateView2Request,
9885            fidl::encoding::DefaultFuchsiaResourceDialect,
9886        > for (T0, T1, T2, T3)
9887    {
9888        #[inline]
9889        unsafe fn encode(
9890            self,
9891            encoder: &mut fidl::encoding::Encoder<
9892                '_,
9893                fidl::encoding::DefaultFuchsiaResourceDialect,
9894            >,
9895            offset: usize,
9896            depth: fidl::encoding::Depth,
9897        ) -> fidl::Result<()> {
9898            encoder.debug_check_bounds::<FlatlandCreateView2Request>(offset);
9899            // Zero out padding regions. There's no need to apply masks
9900            // because the unmasked parts will be overwritten by fields.
9901            unsafe {
9902                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
9903                (ptr as *mut u64).write_unaligned(0);
9904            }
9905            unsafe {
9906                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
9907                (ptr as *mut u64).write_unaligned(0);
9908            }
9909            // Write the fields.
9910            self.0.encode(encoder, offset + 0, depth)?;
9911            self.1.encode(encoder, offset + 4, depth)?;
9912            self.2.encode(encoder, offset + 16, depth)?;
9913            self.3.encode(encoder, offset + 32, depth)?;
9914            Ok(())
9915        }
9916    }
9917
9918    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9919        for FlatlandCreateView2Request
9920    {
9921        #[inline(always)]
9922        fn new_empty() -> Self {
9923            Self {
9924                token: fidl::new_empty!(
9925                    fidl_fuchsia_ui_views::ViewCreationToken,
9926                    fidl::encoding::DefaultFuchsiaResourceDialect
9927                ),
9928                view_identity: fidl::new_empty!(
9929                    fidl_fuchsia_ui_views::ViewIdentityOnCreation,
9930                    fidl::encoding::DefaultFuchsiaResourceDialect
9931                ),
9932                protocols: fidl::new_empty!(
9933                    ViewBoundProtocols,
9934                    fidl::encoding::DefaultFuchsiaResourceDialect
9935                ),
9936                parent_viewport_watcher: fidl::new_empty!(
9937                    fidl::encoding::Endpoint<
9938                        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
9939                    >,
9940                    fidl::encoding::DefaultFuchsiaResourceDialect
9941                ),
9942            }
9943        }
9944
9945        #[inline]
9946        unsafe fn decode(
9947            &mut self,
9948            decoder: &mut fidl::encoding::Decoder<
9949                '_,
9950                fidl::encoding::DefaultFuchsiaResourceDialect,
9951            >,
9952            offset: usize,
9953            _depth: fidl::encoding::Depth,
9954        ) -> fidl::Result<()> {
9955            decoder.debug_check_bounds::<Self>(offset);
9956            // Verify that padding bytes are zero.
9957            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
9958            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9959            let mask = 0xffffffff00000000u64;
9960            let maskedval = padval & mask;
9961            if maskedval != 0 {
9962                return Err(fidl::Error::NonZeroPadding {
9963                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
9964                });
9965            }
9966            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
9967            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9968            let mask = 0xffffffff00000000u64;
9969            let maskedval = padval & mask;
9970            if maskedval != 0 {
9971                return Err(fidl::Error::NonZeroPadding {
9972                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
9973                });
9974            }
9975            fidl::decode!(
9976                fidl_fuchsia_ui_views::ViewCreationToken,
9977                fidl::encoding::DefaultFuchsiaResourceDialect,
9978                &mut self.token,
9979                decoder,
9980                offset + 0,
9981                _depth
9982            )?;
9983            fidl::decode!(
9984                fidl_fuchsia_ui_views::ViewIdentityOnCreation,
9985                fidl::encoding::DefaultFuchsiaResourceDialect,
9986                &mut self.view_identity,
9987                decoder,
9988                offset + 4,
9989                _depth
9990            )?;
9991            fidl::decode!(
9992                ViewBoundProtocols,
9993                fidl::encoding::DefaultFuchsiaResourceDialect,
9994                &mut self.protocols,
9995                decoder,
9996                offset + 16,
9997                _depth
9998            )?;
9999            fidl::decode!(
10000                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
10001                fidl::encoding::DefaultFuchsiaResourceDialect,
10002                &mut self.parent_viewport_watcher,
10003                decoder,
10004                offset + 32,
10005                _depth
10006            )?;
10007            Ok(())
10008        }
10009    }
10010
10011    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateViewRequest {
10012        type Borrowed<'a> = &'a mut Self;
10013        fn take_or_borrow<'a>(
10014            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10015        ) -> Self::Borrowed<'a> {
10016            value
10017        }
10018    }
10019
10020    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateViewRequest {
10021        type Owned = Self;
10022
10023        #[inline(always)]
10024        fn inline_align(_context: fidl::encoding::Context) -> usize {
10025            4
10026        }
10027
10028        #[inline(always)]
10029        fn inline_size(_context: fidl::encoding::Context) -> usize {
10030            8
10031        }
10032    }
10033
10034    unsafe impl
10035        fidl::encoding::Encode<
10036            FlatlandCreateViewRequest,
10037            fidl::encoding::DefaultFuchsiaResourceDialect,
10038        > for &mut FlatlandCreateViewRequest
10039    {
10040        #[inline]
10041        unsafe fn encode(
10042            self,
10043            encoder: &mut fidl::encoding::Encoder<
10044                '_,
10045                fidl::encoding::DefaultFuchsiaResourceDialect,
10046            >,
10047            offset: usize,
10048            _depth: fidl::encoding::Depth,
10049        ) -> fidl::Result<()> {
10050            encoder.debug_check_bounds::<FlatlandCreateViewRequest>(offset);
10051            // Delegate to tuple encoding.
10052            fidl::encoding::Encode::<FlatlandCreateViewRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10053                (
10054                    <fidl_fuchsia_ui_views::ViewCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
10055                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.parent_viewport_watcher),
10056                ),
10057                encoder, offset, _depth
10058            )
10059        }
10060    }
10061    unsafe impl<
10062        T0: fidl::encoding::Encode<
10063                fidl_fuchsia_ui_views::ViewCreationToken,
10064                fidl::encoding::DefaultFuchsiaResourceDialect,
10065            >,
10066        T1: fidl::encoding::Encode<
10067                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
10068                fidl::encoding::DefaultFuchsiaResourceDialect,
10069            >,
10070    >
10071        fidl::encoding::Encode<
10072            FlatlandCreateViewRequest,
10073            fidl::encoding::DefaultFuchsiaResourceDialect,
10074        > for (T0, T1)
10075    {
10076        #[inline]
10077        unsafe fn encode(
10078            self,
10079            encoder: &mut fidl::encoding::Encoder<
10080                '_,
10081                fidl::encoding::DefaultFuchsiaResourceDialect,
10082            >,
10083            offset: usize,
10084            depth: fidl::encoding::Depth,
10085        ) -> fidl::Result<()> {
10086            encoder.debug_check_bounds::<FlatlandCreateViewRequest>(offset);
10087            // Zero out padding regions. There's no need to apply masks
10088            // because the unmasked parts will be overwritten by fields.
10089            // Write the fields.
10090            self.0.encode(encoder, offset + 0, depth)?;
10091            self.1.encode(encoder, offset + 4, depth)?;
10092            Ok(())
10093        }
10094    }
10095
10096    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10097        for FlatlandCreateViewRequest
10098    {
10099        #[inline(always)]
10100        fn new_empty() -> Self {
10101            Self {
10102                token: fidl::new_empty!(
10103                    fidl_fuchsia_ui_views::ViewCreationToken,
10104                    fidl::encoding::DefaultFuchsiaResourceDialect
10105                ),
10106                parent_viewport_watcher: fidl::new_empty!(
10107                    fidl::encoding::Endpoint<
10108                        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
10109                    >,
10110                    fidl::encoding::DefaultFuchsiaResourceDialect
10111                ),
10112            }
10113        }
10114
10115        #[inline]
10116        unsafe fn decode(
10117            &mut self,
10118            decoder: &mut fidl::encoding::Decoder<
10119                '_,
10120                fidl::encoding::DefaultFuchsiaResourceDialect,
10121            >,
10122            offset: usize,
10123            _depth: fidl::encoding::Depth,
10124        ) -> fidl::Result<()> {
10125            decoder.debug_check_bounds::<Self>(offset);
10126            // Verify that padding bytes are zero.
10127            fidl::decode!(
10128                fidl_fuchsia_ui_views::ViewCreationToken,
10129                fidl::encoding::DefaultFuchsiaResourceDialect,
10130                &mut self.token,
10131                decoder,
10132                offset + 0,
10133                _depth
10134            )?;
10135            fidl::decode!(
10136                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
10137                fidl::encoding::DefaultFuchsiaResourceDialect,
10138                &mut self.parent_viewport_watcher,
10139                decoder,
10140                offset + 4,
10141                _depth
10142            )?;
10143            Ok(())
10144        }
10145    }
10146
10147    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateViewportRequest {
10148        type Borrowed<'a> = &'a mut Self;
10149        fn take_or_borrow<'a>(
10150            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10151        ) -> Self::Borrowed<'a> {
10152            value
10153        }
10154    }
10155
10156    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateViewportRequest {
10157        type Owned = Self;
10158
10159        #[inline(always)]
10160        fn inline_align(_context: fidl::encoding::Context) -> usize {
10161            8
10162        }
10163
10164        #[inline(always)]
10165        fn inline_size(_context: fidl::encoding::Context) -> usize {
10166            40
10167        }
10168    }
10169
10170    unsafe impl
10171        fidl::encoding::Encode<
10172            FlatlandCreateViewportRequest,
10173            fidl::encoding::DefaultFuchsiaResourceDialect,
10174        > for &mut FlatlandCreateViewportRequest
10175    {
10176        #[inline]
10177        unsafe fn encode(
10178            self,
10179            encoder: &mut fidl::encoding::Encoder<
10180                '_,
10181                fidl::encoding::DefaultFuchsiaResourceDialect,
10182            >,
10183            offset: usize,
10184            _depth: fidl::encoding::Depth,
10185        ) -> fidl::Result<()> {
10186            encoder.debug_check_bounds::<FlatlandCreateViewportRequest>(offset);
10187            // Delegate to tuple encoding.
10188            fidl::encoding::Encode::<FlatlandCreateViewportRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10189                (
10190                    <ContentId as fidl::encoding::ValueTypeMarker>::borrow(&self.viewport_id),
10191                    <fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
10192                    <ViewportProperties as fidl::encoding::ValueTypeMarker>::borrow(&self.properties),
10193                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.child_view_watcher),
10194                ),
10195                encoder, offset, _depth
10196            )
10197        }
10198    }
10199    unsafe impl<
10200        T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>,
10201        T1: fidl::encoding::Encode<
10202                fidl_fuchsia_ui_views::ViewportCreationToken,
10203                fidl::encoding::DefaultFuchsiaResourceDialect,
10204            >,
10205        T2: fidl::encoding::Encode<ViewportProperties, fidl::encoding::DefaultFuchsiaResourceDialect>,
10206        T3: fidl::encoding::Encode<
10207                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10208                fidl::encoding::DefaultFuchsiaResourceDialect,
10209            >,
10210    >
10211        fidl::encoding::Encode<
10212            FlatlandCreateViewportRequest,
10213            fidl::encoding::DefaultFuchsiaResourceDialect,
10214        > for (T0, T1, T2, T3)
10215    {
10216        #[inline]
10217        unsafe fn encode(
10218            self,
10219            encoder: &mut fidl::encoding::Encoder<
10220                '_,
10221                fidl::encoding::DefaultFuchsiaResourceDialect,
10222            >,
10223            offset: usize,
10224            depth: fidl::encoding::Depth,
10225        ) -> fidl::Result<()> {
10226            encoder.debug_check_bounds::<FlatlandCreateViewportRequest>(offset);
10227            // Zero out padding regions. There's no need to apply masks
10228            // because the unmasked parts will be overwritten by fields.
10229            unsafe {
10230                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
10231                (ptr as *mut u64).write_unaligned(0);
10232            }
10233            unsafe {
10234                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
10235                (ptr as *mut u64).write_unaligned(0);
10236            }
10237            // Write the fields.
10238            self.0.encode(encoder, offset + 0, depth)?;
10239            self.1.encode(encoder, offset + 8, depth)?;
10240            self.2.encode(encoder, offset + 16, depth)?;
10241            self.3.encode(encoder, offset + 32, depth)?;
10242            Ok(())
10243        }
10244    }
10245
10246    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10247        for FlatlandCreateViewportRequest
10248    {
10249        #[inline(always)]
10250        fn new_empty() -> Self {
10251            Self {
10252                viewport_id: fidl::new_empty!(
10253                    ContentId,
10254                    fidl::encoding::DefaultFuchsiaResourceDialect
10255                ),
10256                token: fidl::new_empty!(
10257                    fidl_fuchsia_ui_views::ViewportCreationToken,
10258                    fidl::encoding::DefaultFuchsiaResourceDialect
10259                ),
10260                properties: fidl::new_empty!(
10261                    ViewportProperties,
10262                    fidl::encoding::DefaultFuchsiaResourceDialect
10263                ),
10264                child_view_watcher: fidl::new_empty!(
10265                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10266                    fidl::encoding::DefaultFuchsiaResourceDialect
10267                ),
10268            }
10269        }
10270
10271        #[inline]
10272        unsafe fn decode(
10273            &mut self,
10274            decoder: &mut fidl::encoding::Decoder<
10275                '_,
10276                fidl::encoding::DefaultFuchsiaResourceDialect,
10277            >,
10278            offset: usize,
10279            _depth: fidl::encoding::Depth,
10280        ) -> fidl::Result<()> {
10281            decoder.debug_check_bounds::<Self>(offset);
10282            // Verify that padding bytes are zero.
10283            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
10284            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10285            let mask = 0xffffffff00000000u64;
10286            let maskedval = padval & mask;
10287            if maskedval != 0 {
10288                return Err(fidl::Error::NonZeroPadding {
10289                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
10290                });
10291            }
10292            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
10293            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10294            let mask = 0xffffffff00000000u64;
10295            let maskedval = padval & mask;
10296            if maskedval != 0 {
10297                return Err(fidl::Error::NonZeroPadding {
10298                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
10299                });
10300            }
10301            fidl::decode!(
10302                ContentId,
10303                fidl::encoding::DefaultFuchsiaResourceDialect,
10304                &mut self.viewport_id,
10305                decoder,
10306                offset + 0,
10307                _depth
10308            )?;
10309            fidl::decode!(
10310                fidl_fuchsia_ui_views::ViewportCreationToken,
10311                fidl::encoding::DefaultFuchsiaResourceDialect,
10312                &mut self.token,
10313                decoder,
10314                offset + 8,
10315                _depth
10316            )?;
10317            fidl::decode!(
10318                ViewportProperties,
10319                fidl::encoding::DefaultFuchsiaResourceDialect,
10320                &mut self.properties,
10321                decoder,
10322                offset + 16,
10323                _depth
10324            )?;
10325            fidl::decode!(
10326                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10327                fidl::encoding::DefaultFuchsiaResourceDialect,
10328                &mut self.child_view_watcher,
10329                decoder,
10330                offset + 32,
10331                _depth
10332            )?;
10333            Ok(())
10334        }
10335    }
10336
10337    impl fidl::encoding::ResourceTypeMarker for FlatlandDisplaySetContentRequest {
10338        type Borrowed<'a> = &'a mut Self;
10339        fn take_or_borrow<'a>(
10340            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10341        ) -> Self::Borrowed<'a> {
10342            value
10343        }
10344    }
10345
10346    unsafe impl fidl::encoding::TypeMarker for FlatlandDisplaySetContentRequest {
10347        type Owned = Self;
10348
10349        #[inline(always)]
10350        fn inline_align(_context: fidl::encoding::Context) -> usize {
10351            4
10352        }
10353
10354        #[inline(always)]
10355        fn inline_size(_context: fidl::encoding::Context) -> usize {
10356            8
10357        }
10358    }
10359
10360    unsafe impl
10361        fidl::encoding::Encode<
10362            FlatlandDisplaySetContentRequest,
10363            fidl::encoding::DefaultFuchsiaResourceDialect,
10364        > for &mut FlatlandDisplaySetContentRequest
10365    {
10366        #[inline]
10367        unsafe fn encode(
10368            self,
10369            encoder: &mut fidl::encoding::Encoder<
10370                '_,
10371                fidl::encoding::DefaultFuchsiaResourceDialect,
10372            >,
10373            offset: usize,
10374            _depth: fidl::encoding::Depth,
10375        ) -> fidl::Result<()> {
10376            encoder.debug_check_bounds::<FlatlandDisplaySetContentRequest>(offset);
10377            // Delegate to tuple encoding.
10378            fidl::encoding::Encode::<FlatlandDisplaySetContentRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10379                (
10380                    <fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
10381                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.child_view_watcher),
10382                ),
10383                encoder, offset, _depth
10384            )
10385        }
10386    }
10387    unsafe impl<
10388        T0: fidl::encoding::Encode<
10389                fidl_fuchsia_ui_views::ViewportCreationToken,
10390                fidl::encoding::DefaultFuchsiaResourceDialect,
10391            >,
10392        T1: fidl::encoding::Encode<
10393                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10394                fidl::encoding::DefaultFuchsiaResourceDialect,
10395            >,
10396    >
10397        fidl::encoding::Encode<
10398            FlatlandDisplaySetContentRequest,
10399            fidl::encoding::DefaultFuchsiaResourceDialect,
10400        > for (T0, T1)
10401    {
10402        #[inline]
10403        unsafe fn encode(
10404            self,
10405            encoder: &mut fidl::encoding::Encoder<
10406                '_,
10407                fidl::encoding::DefaultFuchsiaResourceDialect,
10408            >,
10409            offset: usize,
10410            depth: fidl::encoding::Depth,
10411        ) -> fidl::Result<()> {
10412            encoder.debug_check_bounds::<FlatlandDisplaySetContentRequest>(offset);
10413            // Zero out padding regions. There's no need to apply masks
10414            // because the unmasked parts will be overwritten by fields.
10415            // Write the fields.
10416            self.0.encode(encoder, offset + 0, depth)?;
10417            self.1.encode(encoder, offset + 4, depth)?;
10418            Ok(())
10419        }
10420    }
10421
10422    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10423        for FlatlandDisplaySetContentRequest
10424    {
10425        #[inline(always)]
10426        fn new_empty() -> Self {
10427            Self {
10428                token: fidl::new_empty!(
10429                    fidl_fuchsia_ui_views::ViewportCreationToken,
10430                    fidl::encoding::DefaultFuchsiaResourceDialect
10431                ),
10432                child_view_watcher: fidl::new_empty!(
10433                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10434                    fidl::encoding::DefaultFuchsiaResourceDialect
10435                ),
10436            }
10437        }
10438
10439        #[inline]
10440        unsafe fn decode(
10441            &mut self,
10442            decoder: &mut fidl::encoding::Decoder<
10443                '_,
10444                fidl::encoding::DefaultFuchsiaResourceDialect,
10445            >,
10446            offset: usize,
10447            _depth: fidl::encoding::Depth,
10448        ) -> fidl::Result<()> {
10449            decoder.debug_check_bounds::<Self>(offset);
10450            // Verify that padding bytes are zero.
10451            fidl::decode!(
10452                fidl_fuchsia_ui_views::ViewportCreationToken,
10453                fidl::encoding::DefaultFuchsiaResourceDialect,
10454                &mut self.token,
10455                decoder,
10456                offset + 0,
10457                _depth
10458            )?;
10459            fidl::decode!(
10460                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10461                fidl::encoding::DefaultFuchsiaResourceDialect,
10462                &mut self.child_view_watcher,
10463                decoder,
10464                offset + 4,
10465                _depth
10466            )?;
10467            Ok(())
10468        }
10469    }
10470
10471    impl fidl::encoding::ResourceTypeMarker for FlatlandPresentRequest {
10472        type Borrowed<'a> = &'a mut Self;
10473        fn take_or_borrow<'a>(
10474            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10475        ) -> Self::Borrowed<'a> {
10476            value
10477        }
10478    }
10479
10480    unsafe impl fidl::encoding::TypeMarker for FlatlandPresentRequest {
10481        type Owned = Self;
10482
10483        #[inline(always)]
10484        fn inline_align(_context: fidl::encoding::Context) -> usize {
10485            8
10486        }
10487
10488        #[inline(always)]
10489        fn inline_size(_context: fidl::encoding::Context) -> usize {
10490            16
10491        }
10492    }
10493
10494    unsafe impl
10495        fidl::encoding::Encode<
10496            FlatlandPresentRequest,
10497            fidl::encoding::DefaultFuchsiaResourceDialect,
10498        > for &mut FlatlandPresentRequest
10499    {
10500        #[inline]
10501        unsafe fn encode(
10502            self,
10503            encoder: &mut fidl::encoding::Encoder<
10504                '_,
10505                fidl::encoding::DefaultFuchsiaResourceDialect,
10506            >,
10507            offset: usize,
10508            _depth: fidl::encoding::Depth,
10509        ) -> fidl::Result<()> {
10510            encoder.debug_check_bounds::<FlatlandPresentRequest>(offset);
10511            // Delegate to tuple encoding.
10512            fidl::encoding::Encode::<
10513                FlatlandPresentRequest,
10514                fidl::encoding::DefaultFuchsiaResourceDialect,
10515            >::encode(
10516                (<PresentArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10517                    &mut self.args,
10518                ),),
10519                encoder,
10520                offset,
10521                _depth,
10522            )
10523        }
10524    }
10525    unsafe impl<
10526        T0: fidl::encoding::Encode<PresentArgs, fidl::encoding::DefaultFuchsiaResourceDialect>,
10527    >
10528        fidl::encoding::Encode<
10529            FlatlandPresentRequest,
10530            fidl::encoding::DefaultFuchsiaResourceDialect,
10531        > for (T0,)
10532    {
10533        #[inline]
10534        unsafe fn encode(
10535            self,
10536            encoder: &mut fidl::encoding::Encoder<
10537                '_,
10538                fidl::encoding::DefaultFuchsiaResourceDialect,
10539            >,
10540            offset: usize,
10541            depth: fidl::encoding::Depth,
10542        ) -> fidl::Result<()> {
10543            encoder.debug_check_bounds::<FlatlandPresentRequest>(offset);
10544            // Zero out padding regions. There's no need to apply masks
10545            // because the unmasked parts will be overwritten by fields.
10546            // Write the fields.
10547            self.0.encode(encoder, offset + 0, depth)?;
10548            Ok(())
10549        }
10550    }
10551
10552    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10553        for FlatlandPresentRequest
10554    {
10555        #[inline(always)]
10556        fn new_empty() -> Self {
10557            Self {
10558                args: fidl::new_empty!(PresentArgs, fidl::encoding::DefaultFuchsiaResourceDialect),
10559            }
10560        }
10561
10562        #[inline]
10563        unsafe fn decode(
10564            &mut self,
10565            decoder: &mut fidl::encoding::Decoder<
10566                '_,
10567                fidl::encoding::DefaultFuchsiaResourceDialect,
10568            >,
10569            offset: usize,
10570            _depth: fidl::encoding::Depth,
10571        ) -> fidl::Result<()> {
10572            decoder.debug_check_bounds::<Self>(offset);
10573            // Verify that padding bytes are zero.
10574            fidl::decode!(
10575                PresentArgs,
10576                fidl::encoding::DefaultFuchsiaResourceDialect,
10577                &mut self.args,
10578                decoder,
10579                offset + 0,
10580                _depth
10581            )?;
10582            Ok(())
10583        }
10584    }
10585
10586    impl fidl::encoding::ResourceTypeMarker for FlatlandReleaseViewportResponse {
10587        type Borrowed<'a> = &'a mut Self;
10588        fn take_or_borrow<'a>(
10589            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10590        ) -> Self::Borrowed<'a> {
10591            value
10592        }
10593    }
10594
10595    unsafe impl fidl::encoding::TypeMarker for FlatlandReleaseViewportResponse {
10596        type Owned = Self;
10597
10598        #[inline(always)]
10599        fn inline_align(_context: fidl::encoding::Context) -> usize {
10600            4
10601        }
10602
10603        #[inline(always)]
10604        fn inline_size(_context: fidl::encoding::Context) -> usize {
10605            4
10606        }
10607    }
10608
10609    unsafe impl
10610        fidl::encoding::Encode<
10611            FlatlandReleaseViewportResponse,
10612            fidl::encoding::DefaultFuchsiaResourceDialect,
10613        > for &mut FlatlandReleaseViewportResponse
10614    {
10615        #[inline]
10616        unsafe fn encode(
10617            self,
10618            encoder: &mut fidl::encoding::Encoder<
10619                '_,
10620                fidl::encoding::DefaultFuchsiaResourceDialect,
10621            >,
10622            offset: usize,
10623            _depth: fidl::encoding::Depth,
10624        ) -> fidl::Result<()> {
10625            encoder.debug_check_bounds::<FlatlandReleaseViewportResponse>(offset);
10626            // Delegate to tuple encoding.
10627            fidl::encoding::Encode::<FlatlandReleaseViewportResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10628                (
10629                    <fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
10630                ),
10631                encoder, offset, _depth
10632            )
10633        }
10634    }
10635    unsafe impl<
10636        T0: fidl::encoding::Encode<
10637                fidl_fuchsia_ui_views::ViewportCreationToken,
10638                fidl::encoding::DefaultFuchsiaResourceDialect,
10639            >,
10640    >
10641        fidl::encoding::Encode<
10642            FlatlandReleaseViewportResponse,
10643            fidl::encoding::DefaultFuchsiaResourceDialect,
10644        > for (T0,)
10645    {
10646        #[inline]
10647        unsafe fn encode(
10648            self,
10649            encoder: &mut fidl::encoding::Encoder<
10650                '_,
10651                fidl::encoding::DefaultFuchsiaResourceDialect,
10652            >,
10653            offset: usize,
10654            depth: fidl::encoding::Depth,
10655        ) -> fidl::Result<()> {
10656            encoder.debug_check_bounds::<FlatlandReleaseViewportResponse>(offset);
10657            // Zero out padding regions. There's no need to apply masks
10658            // because the unmasked parts will be overwritten by fields.
10659            // Write the fields.
10660            self.0.encode(encoder, offset + 0, depth)?;
10661            Ok(())
10662        }
10663    }
10664
10665    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10666        for FlatlandReleaseViewportResponse
10667    {
10668        #[inline(always)]
10669        fn new_empty() -> Self {
10670            Self {
10671                token: fidl::new_empty!(
10672                    fidl_fuchsia_ui_views::ViewportCreationToken,
10673                    fidl::encoding::DefaultFuchsiaResourceDialect
10674                ),
10675            }
10676        }
10677
10678        #[inline]
10679        unsafe fn decode(
10680            &mut self,
10681            decoder: &mut fidl::encoding::Decoder<
10682                '_,
10683                fidl::encoding::DefaultFuchsiaResourceDialect,
10684            >,
10685            offset: usize,
10686            _depth: fidl::encoding::Depth,
10687        ) -> fidl::Result<()> {
10688            decoder.debug_check_bounds::<Self>(offset);
10689            // Verify that padding bytes are zero.
10690            fidl::decode!(
10691                fidl_fuchsia_ui_views::ViewportCreationToken,
10692                fidl::encoding::DefaultFuchsiaResourceDialect,
10693                &mut self.token,
10694                decoder,
10695                offset + 0,
10696                _depth
10697            )?;
10698            Ok(())
10699        }
10700    }
10701
10702    impl fidl::encoding::ResourceTypeMarker for FlatlandSetSolidFillRequest {
10703        type Borrowed<'a> = &'a mut Self;
10704        fn take_or_borrow<'a>(
10705            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10706        ) -> Self::Borrowed<'a> {
10707            value
10708        }
10709    }
10710
10711    unsafe impl fidl::encoding::TypeMarker for FlatlandSetSolidFillRequest {
10712        type Owned = Self;
10713
10714        #[inline(always)]
10715        fn inline_align(_context: fidl::encoding::Context) -> usize {
10716            8
10717        }
10718
10719        #[inline(always)]
10720        fn inline_size(_context: fidl::encoding::Context) -> usize {
10721            32
10722        }
10723    }
10724
10725    unsafe impl
10726        fidl::encoding::Encode<
10727            FlatlandSetSolidFillRequest,
10728            fidl::encoding::DefaultFuchsiaResourceDialect,
10729        > for &mut FlatlandSetSolidFillRequest
10730    {
10731        #[inline]
10732        unsafe fn encode(
10733            self,
10734            encoder: &mut fidl::encoding::Encoder<
10735                '_,
10736                fidl::encoding::DefaultFuchsiaResourceDialect,
10737            >,
10738            offset: usize,
10739            _depth: fidl::encoding::Depth,
10740        ) -> fidl::Result<()> {
10741            encoder.debug_check_bounds::<FlatlandSetSolidFillRequest>(offset);
10742            // Delegate to tuple encoding.
10743            fidl::encoding::Encode::<
10744                FlatlandSetSolidFillRequest,
10745                fidl::encoding::DefaultFuchsiaResourceDialect,
10746            >::encode(
10747                (
10748                    <ContentId as fidl::encoding::ValueTypeMarker>::borrow(&self.rect_id),
10749                    <ColorRgba as fidl::encoding::ValueTypeMarker>::borrow(&self.color),
10750                    <fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow(
10751                        &self.size,
10752                    ),
10753                ),
10754                encoder,
10755                offset,
10756                _depth,
10757            )
10758        }
10759    }
10760    unsafe impl<
10761        T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>,
10762        T1: fidl::encoding::Encode<ColorRgba, fidl::encoding::DefaultFuchsiaResourceDialect>,
10763        T2: fidl::encoding::Encode<
10764                fidl_fuchsia_math::SizeU,
10765                fidl::encoding::DefaultFuchsiaResourceDialect,
10766            >,
10767    >
10768        fidl::encoding::Encode<
10769            FlatlandSetSolidFillRequest,
10770            fidl::encoding::DefaultFuchsiaResourceDialect,
10771        > for (T0, T1, T2)
10772    {
10773        #[inline]
10774        unsafe fn encode(
10775            self,
10776            encoder: &mut fidl::encoding::Encoder<
10777                '_,
10778                fidl::encoding::DefaultFuchsiaResourceDialect,
10779            >,
10780            offset: usize,
10781            depth: fidl::encoding::Depth,
10782        ) -> fidl::Result<()> {
10783            encoder.debug_check_bounds::<FlatlandSetSolidFillRequest>(offset);
10784            // Zero out padding regions. There's no need to apply masks
10785            // because the unmasked parts will be overwritten by fields.
10786            // Write the fields.
10787            self.0.encode(encoder, offset + 0, depth)?;
10788            self.1.encode(encoder, offset + 8, depth)?;
10789            self.2.encode(encoder, offset + 24, depth)?;
10790            Ok(())
10791        }
10792    }
10793
10794    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10795        for FlatlandSetSolidFillRequest
10796    {
10797        #[inline(always)]
10798        fn new_empty() -> Self {
10799            Self {
10800                rect_id: fidl::new_empty!(ContentId, fidl::encoding::DefaultFuchsiaResourceDialect),
10801                color: fidl::new_empty!(ColorRgba, fidl::encoding::DefaultFuchsiaResourceDialect),
10802                size: fidl::new_empty!(
10803                    fidl_fuchsia_math::SizeU,
10804                    fidl::encoding::DefaultFuchsiaResourceDialect
10805                ),
10806            }
10807        }
10808
10809        #[inline]
10810        unsafe fn decode(
10811            &mut self,
10812            decoder: &mut fidl::encoding::Decoder<
10813                '_,
10814                fidl::encoding::DefaultFuchsiaResourceDialect,
10815            >,
10816            offset: usize,
10817            _depth: fidl::encoding::Depth,
10818        ) -> fidl::Result<()> {
10819            decoder.debug_check_bounds::<Self>(offset);
10820            // Verify that padding bytes are zero.
10821            fidl::decode!(
10822                ContentId,
10823                fidl::encoding::DefaultFuchsiaResourceDialect,
10824                &mut self.rect_id,
10825                decoder,
10826                offset + 0,
10827                _depth
10828            )?;
10829            fidl::decode!(
10830                ColorRgba,
10831                fidl::encoding::DefaultFuchsiaResourceDialect,
10832                &mut self.color,
10833                decoder,
10834                offset + 8,
10835                _depth
10836            )?;
10837            fidl::decode!(
10838                fidl_fuchsia_math::SizeU,
10839                fidl::encoding::DefaultFuchsiaResourceDialect,
10840                &mut self.size,
10841                decoder,
10842                offset + 24,
10843                _depth
10844            )?;
10845            Ok(())
10846        }
10847    }
10848
10849    impl fidl::encoding::ResourceTypeMarker for TrustedFlatlandFactoryCreateFlatlandRequest {
10850        type Borrowed<'a> = &'a mut Self;
10851        fn take_or_borrow<'a>(
10852            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10853        ) -> Self::Borrowed<'a> {
10854            value
10855        }
10856    }
10857
10858    unsafe impl fidl::encoding::TypeMarker for TrustedFlatlandFactoryCreateFlatlandRequest {
10859        type Owned = Self;
10860
10861        #[inline(always)]
10862        fn inline_align(_context: fidl::encoding::Context) -> usize {
10863            8
10864        }
10865
10866        #[inline(always)]
10867        fn inline_size(_context: fidl::encoding::Context) -> usize {
10868            24
10869        }
10870    }
10871
10872    unsafe impl
10873        fidl::encoding::Encode<
10874            TrustedFlatlandFactoryCreateFlatlandRequest,
10875            fidl::encoding::DefaultFuchsiaResourceDialect,
10876        > for &mut TrustedFlatlandFactoryCreateFlatlandRequest
10877    {
10878        #[inline]
10879        unsafe fn encode(
10880            self,
10881            encoder: &mut fidl::encoding::Encoder<
10882                '_,
10883                fidl::encoding::DefaultFuchsiaResourceDialect,
10884            >,
10885            offset: usize,
10886            _depth: fidl::encoding::Depth,
10887        ) -> fidl::Result<()> {
10888            encoder.debug_check_bounds::<TrustedFlatlandFactoryCreateFlatlandRequest>(offset);
10889            // Delegate to tuple encoding.
10890            fidl::encoding::Encode::<TrustedFlatlandFactoryCreateFlatlandRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10891                (
10892                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FlatlandMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.server_end),
10893                    <TrustedFlatlandConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.config),
10894                ),
10895                encoder, offset, _depth
10896            )
10897        }
10898    }
10899    unsafe impl<
10900        T0: fidl::encoding::Encode<
10901                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FlatlandMarker>>,
10902                fidl::encoding::DefaultFuchsiaResourceDialect,
10903            >,
10904        T1: fidl::encoding::Encode<
10905                TrustedFlatlandConfig,
10906                fidl::encoding::DefaultFuchsiaResourceDialect,
10907            >,
10908    >
10909        fidl::encoding::Encode<
10910            TrustedFlatlandFactoryCreateFlatlandRequest,
10911            fidl::encoding::DefaultFuchsiaResourceDialect,
10912        > for (T0, T1)
10913    {
10914        #[inline]
10915        unsafe fn encode(
10916            self,
10917            encoder: &mut fidl::encoding::Encoder<
10918                '_,
10919                fidl::encoding::DefaultFuchsiaResourceDialect,
10920            >,
10921            offset: usize,
10922            depth: fidl::encoding::Depth,
10923        ) -> fidl::Result<()> {
10924            encoder.debug_check_bounds::<TrustedFlatlandFactoryCreateFlatlandRequest>(offset);
10925            // Zero out padding regions. There's no need to apply masks
10926            // because the unmasked parts will be overwritten by fields.
10927            unsafe {
10928                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
10929                (ptr as *mut u64).write_unaligned(0);
10930            }
10931            // Write the fields.
10932            self.0.encode(encoder, offset + 0, depth)?;
10933            self.1.encode(encoder, offset + 8, depth)?;
10934            Ok(())
10935        }
10936    }
10937
10938    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10939        for TrustedFlatlandFactoryCreateFlatlandRequest
10940    {
10941        #[inline(always)]
10942        fn new_empty() -> Self {
10943            Self {
10944                server_end: fidl::new_empty!(
10945                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FlatlandMarker>>,
10946                    fidl::encoding::DefaultFuchsiaResourceDialect
10947                ),
10948                config: fidl::new_empty!(
10949                    TrustedFlatlandConfig,
10950                    fidl::encoding::DefaultFuchsiaResourceDialect
10951                ),
10952            }
10953        }
10954
10955        #[inline]
10956        unsafe fn decode(
10957            &mut self,
10958            decoder: &mut fidl::encoding::Decoder<
10959                '_,
10960                fidl::encoding::DefaultFuchsiaResourceDialect,
10961            >,
10962            offset: usize,
10963            _depth: fidl::encoding::Depth,
10964        ) -> fidl::Result<()> {
10965            decoder.debug_check_bounds::<Self>(offset);
10966            // Verify that padding bytes are zero.
10967            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
10968            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10969            let mask = 0xffffffff00000000u64;
10970            let maskedval = padval & mask;
10971            if maskedval != 0 {
10972                return Err(fidl::Error::NonZeroPadding {
10973                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
10974                });
10975            }
10976            fidl::decode!(
10977                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FlatlandMarker>>,
10978                fidl::encoding::DefaultFuchsiaResourceDialect,
10979                &mut self.server_end,
10980                decoder,
10981                offset + 0,
10982                _depth
10983            )?;
10984            fidl::decode!(
10985                TrustedFlatlandConfig,
10986                fidl::encoding::DefaultFuchsiaResourceDialect,
10987                &mut self.config,
10988                decoder,
10989                offset + 8,
10990                _depth
10991            )?;
10992            Ok(())
10993        }
10994    }
10995
10996    impl FrameInfo {
10997        #[inline(always)]
10998        fn max_ordinal_present(&self) -> u64 {
10999            if let Some(_) = self.buffer_id {
11000                return 1;
11001            }
11002            0
11003        }
11004    }
11005
11006    impl fidl::encoding::ResourceTypeMarker for FrameInfo {
11007        type Borrowed<'a> = &'a mut Self;
11008        fn take_or_borrow<'a>(
11009            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11010        ) -> Self::Borrowed<'a> {
11011            value
11012        }
11013    }
11014
11015    unsafe impl fidl::encoding::TypeMarker for FrameInfo {
11016        type Owned = Self;
11017
11018        #[inline(always)]
11019        fn inline_align(_context: fidl::encoding::Context) -> usize {
11020            8
11021        }
11022
11023        #[inline(always)]
11024        fn inline_size(_context: fidl::encoding::Context) -> usize {
11025            16
11026        }
11027    }
11028
11029    unsafe impl fidl::encoding::Encode<FrameInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
11030        for &mut FrameInfo
11031    {
11032        unsafe fn encode(
11033            self,
11034            encoder: &mut fidl::encoding::Encoder<
11035                '_,
11036                fidl::encoding::DefaultFuchsiaResourceDialect,
11037            >,
11038            offset: usize,
11039            mut depth: fidl::encoding::Depth,
11040        ) -> fidl::Result<()> {
11041            encoder.debug_check_bounds::<FrameInfo>(offset);
11042            // Vector header
11043            let max_ordinal: u64 = self.max_ordinal_present();
11044            encoder.write_num(max_ordinal, offset);
11045            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11046            // Calling encoder.out_of_line_offset(0) is not allowed.
11047            if max_ordinal == 0 {
11048                return Ok(());
11049            }
11050            depth.increment()?;
11051            let envelope_size = 8;
11052            let bytes_len = max_ordinal as usize * envelope_size;
11053            #[allow(unused_variables)]
11054            let offset = encoder.out_of_line_offset(bytes_len);
11055            let mut _prev_end_offset: usize = 0;
11056            if 1 > max_ordinal {
11057                return Ok(());
11058            }
11059
11060            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11061            // are envelope_size bytes.
11062            let cur_offset: usize = (1 - 1) * envelope_size;
11063
11064            // Zero reserved fields.
11065            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11066
11067            // Safety:
11068            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11069            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11070            //   envelope_size bytes, there is always sufficient room.
11071            fidl::encoding::encode_in_envelope_optional::<
11072                u32,
11073                fidl::encoding::DefaultFuchsiaResourceDialect,
11074            >(
11075                self.buffer_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
11076                encoder,
11077                offset + cur_offset,
11078                depth,
11079            )?;
11080
11081            _prev_end_offset = cur_offset + envelope_size;
11082
11083            Ok(())
11084        }
11085    }
11086
11087    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FrameInfo {
11088        #[inline(always)]
11089        fn new_empty() -> Self {
11090            Self::default()
11091        }
11092
11093        unsafe fn decode(
11094            &mut self,
11095            decoder: &mut fidl::encoding::Decoder<
11096                '_,
11097                fidl::encoding::DefaultFuchsiaResourceDialect,
11098            >,
11099            offset: usize,
11100            mut depth: fidl::encoding::Depth,
11101        ) -> fidl::Result<()> {
11102            decoder.debug_check_bounds::<Self>(offset);
11103            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11104                None => return Err(fidl::Error::NotNullable),
11105                Some(len) => len,
11106            };
11107            // Calling decoder.out_of_line_offset(0) is not allowed.
11108            if len == 0 {
11109                return Ok(());
11110            };
11111            depth.increment()?;
11112            let envelope_size = 8;
11113            let bytes_len = len * envelope_size;
11114            let offset = decoder.out_of_line_offset(bytes_len)?;
11115            // Decode the envelope for each type.
11116            let mut _next_ordinal_to_read = 0;
11117            let mut next_offset = offset;
11118            let end_offset = offset + bytes_len;
11119            _next_ordinal_to_read += 1;
11120            if next_offset >= end_offset {
11121                return Ok(());
11122            }
11123
11124            // Decode unknown envelopes for gaps in ordinals.
11125            while _next_ordinal_to_read < 1 {
11126                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11127                _next_ordinal_to_read += 1;
11128                next_offset += envelope_size;
11129            }
11130
11131            let next_out_of_line = decoder.next_out_of_line();
11132            let handles_before = decoder.remaining_handles();
11133            if let Some((inlined, num_bytes, num_handles)) =
11134                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11135            {
11136                let member_inline_size =
11137                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11138                if inlined != (member_inline_size <= 4) {
11139                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11140                }
11141                let inner_offset;
11142                let mut inner_depth = depth.clone();
11143                if inlined {
11144                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11145                    inner_offset = next_offset;
11146                } else {
11147                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11148                    inner_depth.increment()?;
11149                }
11150                let val_ref = self.buffer_id.get_or_insert_with(|| {
11151                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
11152                });
11153                fidl::decode!(
11154                    u32,
11155                    fidl::encoding::DefaultFuchsiaResourceDialect,
11156                    val_ref,
11157                    decoder,
11158                    inner_offset,
11159                    inner_depth
11160                )?;
11161                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11162                {
11163                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11164                }
11165                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11166                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11167                }
11168            }
11169
11170            next_offset += envelope_size;
11171
11172            // Decode the remaining unknown envelopes.
11173            while next_offset < end_offset {
11174                _next_ordinal_to_read += 1;
11175                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11176                next_offset += envelope_size;
11177            }
11178
11179            Ok(())
11180        }
11181    }
11182
11183    impl GetNextFrameArgs {
11184        #[inline(always)]
11185        fn max_ordinal_present(&self) -> u64 {
11186            if let Some(_) = self.event {
11187                return 1;
11188            }
11189            0
11190        }
11191    }
11192
11193    impl fidl::encoding::ResourceTypeMarker for GetNextFrameArgs {
11194        type Borrowed<'a> = &'a mut Self;
11195        fn take_or_borrow<'a>(
11196            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11197        ) -> Self::Borrowed<'a> {
11198            value
11199        }
11200    }
11201
11202    unsafe impl fidl::encoding::TypeMarker for GetNextFrameArgs {
11203        type Owned = Self;
11204
11205        #[inline(always)]
11206        fn inline_align(_context: fidl::encoding::Context) -> usize {
11207            8
11208        }
11209
11210        #[inline(always)]
11211        fn inline_size(_context: fidl::encoding::Context) -> usize {
11212            16
11213        }
11214    }
11215
11216    unsafe impl
11217        fidl::encoding::Encode<GetNextFrameArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
11218        for &mut GetNextFrameArgs
11219    {
11220        unsafe fn encode(
11221            self,
11222            encoder: &mut fidl::encoding::Encoder<
11223                '_,
11224                fidl::encoding::DefaultFuchsiaResourceDialect,
11225            >,
11226            offset: usize,
11227            mut depth: fidl::encoding::Depth,
11228        ) -> fidl::Result<()> {
11229            encoder.debug_check_bounds::<GetNextFrameArgs>(offset);
11230            // Vector header
11231            let max_ordinal: u64 = self.max_ordinal_present();
11232            encoder.write_num(max_ordinal, offset);
11233            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11234            // Calling encoder.out_of_line_offset(0) is not allowed.
11235            if max_ordinal == 0 {
11236                return Ok(());
11237            }
11238            depth.increment()?;
11239            let envelope_size = 8;
11240            let bytes_len = max_ordinal as usize * envelope_size;
11241            #[allow(unused_variables)]
11242            let offset = encoder.out_of_line_offset(bytes_len);
11243            let mut _prev_end_offset: usize = 0;
11244            if 1 > max_ordinal {
11245                return Ok(());
11246            }
11247
11248            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11249            // are envelope_size bytes.
11250            let cur_offset: usize = (1 - 1) * envelope_size;
11251
11252            // Zero reserved fields.
11253            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11254
11255            // Safety:
11256            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11257            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11258            //   envelope_size bytes, there is always sufficient room.
11259            fidl::encoding::encode_in_envelope_optional::<
11260                fidl::encoding::HandleType<
11261                    fidl::Event,
11262                    { fidl::ObjectType::EVENT.into_raw() },
11263                    2147483648,
11264                >,
11265                fidl::encoding::DefaultFuchsiaResourceDialect,
11266            >(
11267                self.event.as_mut().map(
11268                    <fidl::encoding::HandleType<
11269                        fidl::Event,
11270                        { fidl::ObjectType::EVENT.into_raw() },
11271                        2147483648,
11272                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11273                ),
11274                encoder,
11275                offset + cur_offset,
11276                depth,
11277            )?;
11278
11279            _prev_end_offset = cur_offset + envelope_size;
11280
11281            Ok(())
11282        }
11283    }
11284
11285    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11286        for GetNextFrameArgs
11287    {
11288        #[inline(always)]
11289        fn new_empty() -> Self {
11290            Self::default()
11291        }
11292
11293        unsafe fn decode(
11294            &mut self,
11295            decoder: &mut fidl::encoding::Decoder<
11296                '_,
11297                fidl::encoding::DefaultFuchsiaResourceDialect,
11298            >,
11299            offset: usize,
11300            mut depth: fidl::encoding::Depth,
11301        ) -> fidl::Result<()> {
11302            decoder.debug_check_bounds::<Self>(offset);
11303            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11304                None => return Err(fidl::Error::NotNullable),
11305                Some(len) => len,
11306            };
11307            // Calling decoder.out_of_line_offset(0) is not allowed.
11308            if len == 0 {
11309                return Ok(());
11310            };
11311            depth.increment()?;
11312            let envelope_size = 8;
11313            let bytes_len = len * envelope_size;
11314            let offset = decoder.out_of_line_offset(bytes_len)?;
11315            // Decode the envelope for each type.
11316            let mut _next_ordinal_to_read = 0;
11317            let mut next_offset = offset;
11318            let end_offset = offset + bytes_len;
11319            _next_ordinal_to_read += 1;
11320            if next_offset >= end_offset {
11321                return Ok(());
11322            }
11323
11324            // Decode unknown envelopes for gaps in ordinals.
11325            while _next_ordinal_to_read < 1 {
11326                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11327                _next_ordinal_to_read += 1;
11328                next_offset += envelope_size;
11329            }
11330
11331            let next_out_of_line = decoder.next_out_of_line();
11332            let handles_before = decoder.remaining_handles();
11333            if let Some((inlined, num_bytes, num_handles)) =
11334                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11335            {
11336                let member_inline_size = <fidl::encoding::HandleType<
11337                    fidl::Event,
11338                    { fidl::ObjectType::EVENT.into_raw() },
11339                    2147483648,
11340                > as fidl::encoding::TypeMarker>::inline_size(
11341                    decoder.context
11342                );
11343                if inlined != (member_inline_size <= 4) {
11344                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11345                }
11346                let inner_offset;
11347                let mut inner_depth = depth.clone();
11348                if inlined {
11349                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11350                    inner_offset = next_offset;
11351                } else {
11352                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11353                    inner_depth.increment()?;
11354                }
11355                let val_ref =
11356                self.event.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
11357                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
11358                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11359                {
11360                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11361                }
11362                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11363                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11364                }
11365            }
11366
11367            next_offset += envelope_size;
11368
11369            // Decode the remaining unknown envelopes.
11370            while next_offset < end_offset {
11371                _next_ordinal_to_read += 1;
11372                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11373                next_offset += envelope_size;
11374            }
11375
11376            Ok(())
11377        }
11378    }
11379
11380    impl PresentArgs {
11381        #[inline(always)]
11382        fn max_ordinal_present(&self) -> u64 {
11383            if let Some(_) = self.unsquashable {
11384                return 4;
11385            }
11386            if let Some(_) = self.release_fences {
11387                return 3;
11388            }
11389            if let Some(_) = self.acquire_fences {
11390                return 2;
11391            }
11392            if let Some(_) = self.requested_presentation_time {
11393                return 1;
11394            }
11395            0
11396        }
11397    }
11398
11399    impl fidl::encoding::ResourceTypeMarker for PresentArgs {
11400        type Borrowed<'a> = &'a mut Self;
11401        fn take_or_borrow<'a>(
11402            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11403        ) -> Self::Borrowed<'a> {
11404            value
11405        }
11406    }
11407
11408    unsafe impl fidl::encoding::TypeMarker for PresentArgs {
11409        type Owned = Self;
11410
11411        #[inline(always)]
11412        fn inline_align(_context: fidl::encoding::Context) -> usize {
11413            8
11414        }
11415
11416        #[inline(always)]
11417        fn inline_size(_context: fidl::encoding::Context) -> usize {
11418            16
11419        }
11420    }
11421
11422    unsafe impl fidl::encoding::Encode<PresentArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
11423        for &mut PresentArgs
11424    {
11425        unsafe fn encode(
11426            self,
11427            encoder: &mut fidl::encoding::Encoder<
11428                '_,
11429                fidl::encoding::DefaultFuchsiaResourceDialect,
11430            >,
11431            offset: usize,
11432            mut depth: fidl::encoding::Depth,
11433        ) -> fidl::Result<()> {
11434            encoder.debug_check_bounds::<PresentArgs>(offset);
11435            // Vector header
11436            let max_ordinal: u64 = self.max_ordinal_present();
11437            encoder.write_num(max_ordinal, offset);
11438            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11439            // Calling encoder.out_of_line_offset(0) is not allowed.
11440            if max_ordinal == 0 {
11441                return Ok(());
11442            }
11443            depth.increment()?;
11444            let envelope_size = 8;
11445            let bytes_len = max_ordinal as usize * envelope_size;
11446            #[allow(unused_variables)]
11447            let offset = encoder.out_of_line_offset(bytes_len);
11448            let mut _prev_end_offset: usize = 0;
11449            if 1 > max_ordinal {
11450                return Ok(());
11451            }
11452
11453            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11454            // are envelope_size bytes.
11455            let cur_offset: usize = (1 - 1) * envelope_size;
11456
11457            // Zero reserved fields.
11458            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11459
11460            // Safety:
11461            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11462            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11463            //   envelope_size bytes, there is always sufficient room.
11464            fidl::encoding::encode_in_envelope_optional::<
11465                i64,
11466                fidl::encoding::DefaultFuchsiaResourceDialect,
11467            >(
11468                self.requested_presentation_time
11469                    .as_ref()
11470                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
11471                encoder,
11472                offset + cur_offset,
11473                depth,
11474            )?;
11475
11476            _prev_end_offset = cur_offset + envelope_size;
11477            if 2 > max_ordinal {
11478                return Ok(());
11479            }
11480
11481            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11482            // are envelope_size bytes.
11483            let cur_offset: usize = (2 - 1) * envelope_size;
11484
11485            // Zero reserved fields.
11486            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11487
11488            // Safety:
11489            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11490            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11491            //   envelope_size bytes, there is always sufficient room.
11492            fidl::encoding::encode_in_envelope_optional::<
11493                fidl::encoding::Vector<
11494                    fidl::encoding::HandleType<
11495                        fidl::Event,
11496                        { fidl::ObjectType::EVENT.into_raw() },
11497                        2147483648,
11498                    >,
11499                    16,
11500                >,
11501                fidl::encoding::DefaultFuchsiaResourceDialect,
11502            >(
11503                self.acquire_fences.as_mut().map(
11504                    <fidl::encoding::Vector<
11505                        fidl::encoding::HandleType<
11506                            fidl::Event,
11507                            { fidl::ObjectType::EVENT.into_raw() },
11508                            2147483648,
11509                        >,
11510                        16,
11511                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11512                ),
11513                encoder,
11514                offset + cur_offset,
11515                depth,
11516            )?;
11517
11518            _prev_end_offset = cur_offset + envelope_size;
11519            if 3 > max_ordinal {
11520                return Ok(());
11521            }
11522
11523            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11524            // are envelope_size bytes.
11525            let cur_offset: usize = (3 - 1) * envelope_size;
11526
11527            // Zero reserved fields.
11528            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11529
11530            // Safety:
11531            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11532            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11533            //   envelope_size bytes, there is always sufficient room.
11534            fidl::encoding::encode_in_envelope_optional::<
11535                fidl::encoding::Vector<
11536                    fidl::encoding::HandleType<
11537                        fidl::Event,
11538                        { fidl::ObjectType::EVENT.into_raw() },
11539                        2147483648,
11540                    >,
11541                    16,
11542                >,
11543                fidl::encoding::DefaultFuchsiaResourceDialect,
11544            >(
11545                self.release_fences.as_mut().map(
11546                    <fidl::encoding::Vector<
11547                        fidl::encoding::HandleType<
11548                            fidl::Event,
11549                            { fidl::ObjectType::EVENT.into_raw() },
11550                            2147483648,
11551                        >,
11552                        16,
11553                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11554                ),
11555                encoder,
11556                offset + cur_offset,
11557                depth,
11558            )?;
11559
11560            _prev_end_offset = cur_offset + envelope_size;
11561            if 4 > max_ordinal {
11562                return Ok(());
11563            }
11564
11565            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11566            // are envelope_size bytes.
11567            let cur_offset: usize = (4 - 1) * envelope_size;
11568
11569            // Zero reserved fields.
11570            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11571
11572            // Safety:
11573            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11574            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11575            //   envelope_size bytes, there is always sufficient room.
11576            fidl::encoding::encode_in_envelope_optional::<
11577                bool,
11578                fidl::encoding::DefaultFuchsiaResourceDialect,
11579            >(
11580                self.unsquashable.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11581                encoder,
11582                offset + cur_offset,
11583                depth,
11584            )?;
11585
11586            _prev_end_offset = cur_offset + envelope_size;
11587
11588            Ok(())
11589        }
11590    }
11591
11592    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for PresentArgs {
11593        #[inline(always)]
11594        fn new_empty() -> Self {
11595            Self::default()
11596        }
11597
11598        unsafe fn decode(
11599            &mut self,
11600            decoder: &mut fidl::encoding::Decoder<
11601                '_,
11602                fidl::encoding::DefaultFuchsiaResourceDialect,
11603            >,
11604            offset: usize,
11605            mut depth: fidl::encoding::Depth,
11606        ) -> fidl::Result<()> {
11607            decoder.debug_check_bounds::<Self>(offset);
11608            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11609                None => return Err(fidl::Error::NotNullable),
11610                Some(len) => len,
11611            };
11612            // Calling decoder.out_of_line_offset(0) is not allowed.
11613            if len == 0 {
11614                return Ok(());
11615            };
11616            depth.increment()?;
11617            let envelope_size = 8;
11618            let bytes_len = len * envelope_size;
11619            let offset = decoder.out_of_line_offset(bytes_len)?;
11620            // Decode the envelope for each type.
11621            let mut _next_ordinal_to_read = 0;
11622            let mut next_offset = offset;
11623            let end_offset = offset + bytes_len;
11624            _next_ordinal_to_read += 1;
11625            if next_offset >= end_offset {
11626                return Ok(());
11627            }
11628
11629            // Decode unknown envelopes for gaps in ordinals.
11630            while _next_ordinal_to_read < 1 {
11631                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11632                _next_ordinal_to_read += 1;
11633                next_offset += envelope_size;
11634            }
11635
11636            let next_out_of_line = decoder.next_out_of_line();
11637            let handles_before = decoder.remaining_handles();
11638            if let Some((inlined, num_bytes, num_handles)) =
11639                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11640            {
11641                let member_inline_size =
11642                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11643                if inlined != (member_inline_size <= 4) {
11644                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11645                }
11646                let inner_offset;
11647                let mut inner_depth = depth.clone();
11648                if inlined {
11649                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11650                    inner_offset = next_offset;
11651                } else {
11652                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11653                    inner_depth.increment()?;
11654                }
11655                let val_ref = self.requested_presentation_time.get_or_insert_with(|| {
11656                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
11657                });
11658                fidl::decode!(
11659                    i64,
11660                    fidl::encoding::DefaultFuchsiaResourceDialect,
11661                    val_ref,
11662                    decoder,
11663                    inner_offset,
11664                    inner_depth
11665                )?;
11666                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11667                {
11668                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11669                }
11670                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11671                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11672                }
11673            }
11674
11675            next_offset += envelope_size;
11676            _next_ordinal_to_read += 1;
11677            if next_offset >= end_offset {
11678                return Ok(());
11679            }
11680
11681            // Decode unknown envelopes for gaps in ordinals.
11682            while _next_ordinal_to_read < 2 {
11683                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11684                _next_ordinal_to_read += 1;
11685                next_offset += envelope_size;
11686            }
11687
11688            let next_out_of_line = decoder.next_out_of_line();
11689            let handles_before = decoder.remaining_handles();
11690            if let Some((inlined, num_bytes, num_handles)) =
11691                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11692            {
11693                let member_inline_size = <fidl::encoding::Vector<
11694                    fidl::encoding::HandleType<
11695                        fidl::Event,
11696                        { fidl::ObjectType::EVENT.into_raw() },
11697                        2147483648,
11698                    >,
11699                    16,
11700                > as fidl::encoding::TypeMarker>::inline_size(
11701                    decoder.context
11702                );
11703                if inlined != (member_inline_size <= 4) {
11704                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11705                }
11706                let inner_offset;
11707                let mut inner_depth = depth.clone();
11708                if inlined {
11709                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11710                    inner_offset = next_offset;
11711                } else {
11712                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11713                    inner_depth.increment()?;
11714                }
11715                let val_ref = self.acquire_fences.get_or_insert_with(|| {
11716                    fidl::new_empty!(
11717                        fidl::encoding::Vector<
11718                            fidl::encoding::HandleType<
11719                                fidl::Event,
11720                                { fidl::ObjectType::EVENT.into_raw() },
11721                                2147483648,
11722                            >,
11723                            16,
11724                        >,
11725                        fidl::encoding::DefaultFuchsiaResourceDialect
11726                    )
11727                });
11728                fidl::decode!(
11729                    fidl::encoding::Vector<
11730                        fidl::encoding::HandleType<
11731                            fidl::Event,
11732                            { fidl::ObjectType::EVENT.into_raw() },
11733                            2147483648,
11734                        >,
11735                        16,
11736                    >,
11737                    fidl::encoding::DefaultFuchsiaResourceDialect,
11738                    val_ref,
11739                    decoder,
11740                    inner_offset,
11741                    inner_depth
11742                )?;
11743                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11744                {
11745                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11746                }
11747                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11748                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11749                }
11750            }
11751
11752            next_offset += envelope_size;
11753            _next_ordinal_to_read += 1;
11754            if next_offset >= end_offset {
11755                return Ok(());
11756            }
11757
11758            // Decode unknown envelopes for gaps in ordinals.
11759            while _next_ordinal_to_read < 3 {
11760                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11761                _next_ordinal_to_read += 1;
11762                next_offset += envelope_size;
11763            }
11764
11765            let next_out_of_line = decoder.next_out_of_line();
11766            let handles_before = decoder.remaining_handles();
11767            if let Some((inlined, num_bytes, num_handles)) =
11768                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11769            {
11770                let member_inline_size = <fidl::encoding::Vector<
11771                    fidl::encoding::HandleType<
11772                        fidl::Event,
11773                        { fidl::ObjectType::EVENT.into_raw() },
11774                        2147483648,
11775                    >,
11776                    16,
11777                > as fidl::encoding::TypeMarker>::inline_size(
11778                    decoder.context
11779                );
11780                if inlined != (member_inline_size <= 4) {
11781                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11782                }
11783                let inner_offset;
11784                let mut inner_depth = depth.clone();
11785                if inlined {
11786                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11787                    inner_offset = next_offset;
11788                } else {
11789                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11790                    inner_depth.increment()?;
11791                }
11792                let val_ref = self.release_fences.get_or_insert_with(|| {
11793                    fidl::new_empty!(
11794                        fidl::encoding::Vector<
11795                            fidl::encoding::HandleType<
11796                                fidl::Event,
11797                                { fidl::ObjectType::EVENT.into_raw() },
11798                                2147483648,
11799                            >,
11800                            16,
11801                        >,
11802                        fidl::encoding::DefaultFuchsiaResourceDialect
11803                    )
11804                });
11805                fidl::decode!(
11806                    fidl::encoding::Vector<
11807                        fidl::encoding::HandleType<
11808                            fidl::Event,
11809                            { fidl::ObjectType::EVENT.into_raw() },
11810                            2147483648,
11811                        >,
11812                        16,
11813                    >,
11814                    fidl::encoding::DefaultFuchsiaResourceDialect,
11815                    val_ref,
11816                    decoder,
11817                    inner_offset,
11818                    inner_depth
11819                )?;
11820                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11821                {
11822                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11823                }
11824                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11825                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11826                }
11827            }
11828
11829            next_offset += envelope_size;
11830            _next_ordinal_to_read += 1;
11831            if next_offset >= end_offset {
11832                return Ok(());
11833            }
11834
11835            // Decode unknown envelopes for gaps in ordinals.
11836            while _next_ordinal_to_read < 4 {
11837                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11838                _next_ordinal_to_read += 1;
11839                next_offset += envelope_size;
11840            }
11841
11842            let next_out_of_line = decoder.next_out_of_line();
11843            let handles_before = decoder.remaining_handles();
11844            if let Some((inlined, num_bytes, num_handles)) =
11845                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11846            {
11847                let member_inline_size =
11848                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11849                if inlined != (member_inline_size <= 4) {
11850                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11851                }
11852                let inner_offset;
11853                let mut inner_depth = depth.clone();
11854                if inlined {
11855                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11856                    inner_offset = next_offset;
11857                } else {
11858                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11859                    inner_depth.increment()?;
11860                }
11861                let val_ref = self.unsquashable.get_or_insert_with(|| {
11862                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
11863                });
11864                fidl::decode!(
11865                    bool,
11866                    fidl::encoding::DefaultFuchsiaResourceDialect,
11867                    val_ref,
11868                    decoder,
11869                    inner_offset,
11870                    inner_depth
11871                )?;
11872                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11873                {
11874                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11875                }
11876                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11877                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11878                }
11879            }
11880
11881            next_offset += envelope_size;
11882
11883            // Decode the remaining unknown envelopes.
11884            while next_offset < end_offset {
11885                _next_ordinal_to_read += 1;
11886                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11887                next_offset += envelope_size;
11888            }
11889
11890            Ok(())
11891        }
11892    }
11893
11894    impl RegisterBufferCollectionArgs {
11895        #[inline(always)]
11896        fn max_ordinal_present(&self) -> u64 {
11897            if let Some(_) = self.buffer_collection_token2 {
11898                return 5;
11899            }
11900            if let Some(_) = self.usages {
11901                return 4;
11902            }
11903            if let Some(_) = self.usage {
11904                return 3;
11905            }
11906            if let Some(_) = self.buffer_collection_token {
11907                return 2;
11908            }
11909            if let Some(_) = self.export_token {
11910                return 1;
11911            }
11912            0
11913        }
11914    }
11915
11916    impl fidl::encoding::ResourceTypeMarker for RegisterBufferCollectionArgs {
11917        type Borrowed<'a> = &'a mut Self;
11918        fn take_or_borrow<'a>(
11919            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11920        ) -> Self::Borrowed<'a> {
11921            value
11922        }
11923    }
11924
11925    unsafe impl fidl::encoding::TypeMarker for RegisterBufferCollectionArgs {
11926        type Owned = Self;
11927
11928        #[inline(always)]
11929        fn inline_align(_context: fidl::encoding::Context) -> usize {
11930            8
11931        }
11932
11933        #[inline(always)]
11934        fn inline_size(_context: fidl::encoding::Context) -> usize {
11935            16
11936        }
11937    }
11938
11939    unsafe impl
11940        fidl::encoding::Encode<
11941            RegisterBufferCollectionArgs,
11942            fidl::encoding::DefaultFuchsiaResourceDialect,
11943        > for &mut RegisterBufferCollectionArgs
11944    {
11945        unsafe fn encode(
11946            self,
11947            encoder: &mut fidl::encoding::Encoder<
11948                '_,
11949                fidl::encoding::DefaultFuchsiaResourceDialect,
11950            >,
11951            offset: usize,
11952            mut depth: fidl::encoding::Depth,
11953        ) -> fidl::Result<()> {
11954            encoder.debug_check_bounds::<RegisterBufferCollectionArgs>(offset);
11955            // Vector header
11956            let max_ordinal: u64 = self.max_ordinal_present();
11957            encoder.write_num(max_ordinal, offset);
11958            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11959            // Calling encoder.out_of_line_offset(0) is not allowed.
11960            if max_ordinal == 0 {
11961                return Ok(());
11962            }
11963            depth.increment()?;
11964            let envelope_size = 8;
11965            let bytes_len = max_ordinal as usize * envelope_size;
11966            #[allow(unused_variables)]
11967            let offset = encoder.out_of_line_offset(bytes_len);
11968            let mut _prev_end_offset: usize = 0;
11969            if 1 > max_ordinal {
11970                return Ok(());
11971            }
11972
11973            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11974            // are envelope_size bytes.
11975            let cur_offset: usize = (1 - 1) * envelope_size;
11976
11977            // Zero reserved fields.
11978            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11979
11980            // Safety:
11981            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11982            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11983            //   envelope_size bytes, there is always sufficient room.
11984            fidl::encoding::encode_in_envelope_optional::<BufferCollectionExportToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
11985            self.export_token.as_mut().map(<BufferCollectionExportToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11986            encoder, offset + cur_offset, depth
11987        )?;
11988
11989            _prev_end_offset = cur_offset + envelope_size;
11990            if 2 > max_ordinal {
11991                return Ok(());
11992            }
11993
11994            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11995            // are envelope_size bytes.
11996            let cur_offset: usize = (2 - 1) * envelope_size;
11997
11998            // Zero reserved fields.
11999            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12000
12001            // Safety:
12002            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12003            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12004            //   envelope_size bytes, there is always sufficient room.
12005            fidl::encoding::encode_in_envelope_optional::<
12006                fidl::encoding::Endpoint<
12007                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
12008                >,
12009                fidl::encoding::DefaultFuchsiaResourceDialect,
12010            >(
12011                self.buffer_collection_token.as_mut().map(
12012                    <fidl::encoding::Endpoint<
12013                        fidl::endpoints::ClientEnd<
12014                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
12015                        >,
12016                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12017                ),
12018                encoder,
12019                offset + cur_offset,
12020                depth,
12021            )?;
12022
12023            _prev_end_offset = cur_offset + envelope_size;
12024            if 3 > max_ordinal {
12025                return Ok(());
12026            }
12027
12028            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12029            // are envelope_size bytes.
12030            let cur_offset: usize = (3 - 1) * envelope_size;
12031
12032            // Zero reserved fields.
12033            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12034
12035            // Safety:
12036            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12037            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12038            //   envelope_size bytes, there is always sufficient room.
12039            fidl::encoding::encode_in_envelope_optional::<
12040                RegisterBufferCollectionUsage,
12041                fidl::encoding::DefaultFuchsiaResourceDialect,
12042            >(
12043                self.usage.as_ref().map(
12044                    <RegisterBufferCollectionUsage as fidl::encoding::ValueTypeMarker>::borrow,
12045                ),
12046                encoder,
12047                offset + cur_offset,
12048                depth,
12049            )?;
12050
12051            _prev_end_offset = cur_offset + envelope_size;
12052            if 4 > max_ordinal {
12053                return Ok(());
12054            }
12055
12056            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12057            // are envelope_size bytes.
12058            let cur_offset: usize = (4 - 1) * envelope_size;
12059
12060            // Zero reserved fields.
12061            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12062
12063            // Safety:
12064            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12065            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12066            //   envelope_size bytes, there is always sufficient room.
12067            fidl::encoding::encode_in_envelope_optional::<
12068                RegisterBufferCollectionUsages,
12069                fidl::encoding::DefaultFuchsiaResourceDialect,
12070            >(
12071                self.usages.as_ref().map(
12072                    <RegisterBufferCollectionUsages as fidl::encoding::ValueTypeMarker>::borrow,
12073                ),
12074                encoder,
12075                offset + cur_offset,
12076                depth,
12077            )?;
12078
12079            _prev_end_offset = cur_offset + envelope_size;
12080            if 5 > max_ordinal {
12081                return Ok(());
12082            }
12083
12084            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12085            // are envelope_size bytes.
12086            let cur_offset: usize = (5 - 1) * envelope_size;
12087
12088            // Zero reserved fields.
12089            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12090
12091            // Safety:
12092            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12093            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12094            //   envelope_size bytes, there is always sufficient room.
12095            fidl::encoding::encode_in_envelope_optional::<
12096                fidl::encoding::Endpoint<
12097                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
12098                >,
12099                fidl::encoding::DefaultFuchsiaResourceDialect,
12100            >(
12101                self.buffer_collection_token2.as_mut().map(
12102                    <fidl::encoding::Endpoint<
12103                        fidl::endpoints::ClientEnd<
12104                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
12105                        >,
12106                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12107                ),
12108                encoder,
12109                offset + cur_offset,
12110                depth,
12111            )?;
12112
12113            _prev_end_offset = cur_offset + envelope_size;
12114
12115            Ok(())
12116        }
12117    }
12118
12119    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12120        for RegisterBufferCollectionArgs
12121    {
12122        #[inline(always)]
12123        fn new_empty() -> Self {
12124            Self::default()
12125        }
12126
12127        unsafe fn decode(
12128            &mut self,
12129            decoder: &mut fidl::encoding::Decoder<
12130                '_,
12131                fidl::encoding::DefaultFuchsiaResourceDialect,
12132            >,
12133            offset: usize,
12134            mut depth: fidl::encoding::Depth,
12135        ) -> fidl::Result<()> {
12136            decoder.debug_check_bounds::<Self>(offset);
12137            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12138                None => return Err(fidl::Error::NotNullable),
12139                Some(len) => len,
12140            };
12141            // Calling decoder.out_of_line_offset(0) is not allowed.
12142            if len == 0 {
12143                return Ok(());
12144            };
12145            depth.increment()?;
12146            let envelope_size = 8;
12147            let bytes_len = len * envelope_size;
12148            let offset = decoder.out_of_line_offset(bytes_len)?;
12149            // Decode the envelope for each type.
12150            let mut _next_ordinal_to_read = 0;
12151            let mut next_offset = offset;
12152            let end_offset = offset + bytes_len;
12153            _next_ordinal_to_read += 1;
12154            if next_offset >= end_offset {
12155                return Ok(());
12156            }
12157
12158            // Decode unknown envelopes for gaps in ordinals.
12159            while _next_ordinal_to_read < 1 {
12160                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12161                _next_ordinal_to_read += 1;
12162                next_offset += envelope_size;
12163            }
12164
12165            let next_out_of_line = decoder.next_out_of_line();
12166            let handles_before = decoder.remaining_handles();
12167            if let Some((inlined, num_bytes, num_handles)) =
12168                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12169            {
12170                let member_inline_size =
12171                    <BufferCollectionExportToken as fidl::encoding::TypeMarker>::inline_size(
12172                        decoder.context,
12173                    );
12174                if inlined != (member_inline_size <= 4) {
12175                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12176                }
12177                let inner_offset;
12178                let mut inner_depth = depth.clone();
12179                if inlined {
12180                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12181                    inner_offset = next_offset;
12182                } else {
12183                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12184                    inner_depth.increment()?;
12185                }
12186                let val_ref = self.export_token.get_or_insert_with(|| {
12187                    fidl::new_empty!(
12188                        BufferCollectionExportToken,
12189                        fidl::encoding::DefaultFuchsiaResourceDialect
12190                    )
12191                });
12192                fidl::decode!(
12193                    BufferCollectionExportToken,
12194                    fidl::encoding::DefaultFuchsiaResourceDialect,
12195                    val_ref,
12196                    decoder,
12197                    inner_offset,
12198                    inner_depth
12199                )?;
12200                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12201                {
12202                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12203                }
12204                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12205                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12206                }
12207            }
12208
12209            next_offset += envelope_size;
12210            _next_ordinal_to_read += 1;
12211            if next_offset >= end_offset {
12212                return Ok(());
12213            }
12214
12215            // Decode unknown envelopes for gaps in ordinals.
12216            while _next_ordinal_to_read < 2 {
12217                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12218                _next_ordinal_to_read += 1;
12219                next_offset += envelope_size;
12220            }
12221
12222            let next_out_of_line = decoder.next_out_of_line();
12223            let handles_before = decoder.remaining_handles();
12224            if let Some((inlined, num_bytes, num_handles)) =
12225                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12226            {
12227                let member_inline_size = <fidl::encoding::Endpoint<
12228                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
12229                > as fidl::encoding::TypeMarker>::inline_size(
12230                    decoder.context
12231                );
12232                if inlined != (member_inline_size <= 4) {
12233                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12234                }
12235                let inner_offset;
12236                let mut inner_depth = depth.clone();
12237                if inlined {
12238                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12239                    inner_offset = next_offset;
12240                } else {
12241                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12242                    inner_depth.increment()?;
12243                }
12244                let val_ref = self.buffer_collection_token.get_or_insert_with(|| {
12245                    fidl::new_empty!(
12246                        fidl::encoding::Endpoint<
12247                            fidl::endpoints::ClientEnd<
12248                                fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
12249                            >,
12250                        >,
12251                        fidl::encoding::DefaultFuchsiaResourceDialect
12252                    )
12253                });
12254                fidl::decode!(
12255                    fidl::encoding::Endpoint<
12256                        fidl::endpoints::ClientEnd<
12257                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
12258                        >,
12259                    >,
12260                    fidl::encoding::DefaultFuchsiaResourceDialect,
12261                    val_ref,
12262                    decoder,
12263                    inner_offset,
12264                    inner_depth
12265                )?;
12266                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12267                {
12268                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12269                }
12270                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12271                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12272                }
12273            }
12274
12275            next_offset += envelope_size;
12276            _next_ordinal_to_read += 1;
12277            if next_offset >= end_offset {
12278                return Ok(());
12279            }
12280
12281            // Decode unknown envelopes for gaps in ordinals.
12282            while _next_ordinal_to_read < 3 {
12283                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12284                _next_ordinal_to_read += 1;
12285                next_offset += envelope_size;
12286            }
12287
12288            let next_out_of_line = decoder.next_out_of_line();
12289            let handles_before = decoder.remaining_handles();
12290            if let Some((inlined, num_bytes, num_handles)) =
12291                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12292            {
12293                let member_inline_size =
12294                    <RegisterBufferCollectionUsage as fidl::encoding::TypeMarker>::inline_size(
12295                        decoder.context,
12296                    );
12297                if inlined != (member_inline_size <= 4) {
12298                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12299                }
12300                let inner_offset;
12301                let mut inner_depth = depth.clone();
12302                if inlined {
12303                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12304                    inner_offset = next_offset;
12305                } else {
12306                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12307                    inner_depth.increment()?;
12308                }
12309                let val_ref = self.usage.get_or_insert_with(|| {
12310                    fidl::new_empty!(
12311                        RegisterBufferCollectionUsage,
12312                        fidl::encoding::DefaultFuchsiaResourceDialect
12313                    )
12314                });
12315                fidl::decode!(
12316                    RegisterBufferCollectionUsage,
12317                    fidl::encoding::DefaultFuchsiaResourceDialect,
12318                    val_ref,
12319                    decoder,
12320                    inner_offset,
12321                    inner_depth
12322                )?;
12323                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12324                {
12325                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12326                }
12327                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12328                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12329                }
12330            }
12331
12332            next_offset += envelope_size;
12333            _next_ordinal_to_read += 1;
12334            if next_offset >= end_offset {
12335                return Ok(());
12336            }
12337
12338            // Decode unknown envelopes for gaps in ordinals.
12339            while _next_ordinal_to_read < 4 {
12340                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12341                _next_ordinal_to_read += 1;
12342                next_offset += envelope_size;
12343            }
12344
12345            let next_out_of_line = decoder.next_out_of_line();
12346            let handles_before = decoder.remaining_handles();
12347            if let Some((inlined, num_bytes, num_handles)) =
12348                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12349            {
12350                let member_inline_size =
12351                    <RegisterBufferCollectionUsages as fidl::encoding::TypeMarker>::inline_size(
12352                        decoder.context,
12353                    );
12354                if inlined != (member_inline_size <= 4) {
12355                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12356                }
12357                let inner_offset;
12358                let mut inner_depth = depth.clone();
12359                if inlined {
12360                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12361                    inner_offset = next_offset;
12362                } else {
12363                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12364                    inner_depth.increment()?;
12365                }
12366                let val_ref = self.usages.get_or_insert_with(|| {
12367                    fidl::new_empty!(
12368                        RegisterBufferCollectionUsages,
12369                        fidl::encoding::DefaultFuchsiaResourceDialect
12370                    )
12371                });
12372                fidl::decode!(
12373                    RegisterBufferCollectionUsages,
12374                    fidl::encoding::DefaultFuchsiaResourceDialect,
12375                    val_ref,
12376                    decoder,
12377                    inner_offset,
12378                    inner_depth
12379                )?;
12380                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12381                {
12382                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12383                }
12384                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12385                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12386                }
12387            }
12388
12389            next_offset += envelope_size;
12390            _next_ordinal_to_read += 1;
12391            if next_offset >= end_offset {
12392                return Ok(());
12393            }
12394
12395            // Decode unknown envelopes for gaps in ordinals.
12396            while _next_ordinal_to_read < 5 {
12397                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12398                _next_ordinal_to_read += 1;
12399                next_offset += envelope_size;
12400            }
12401
12402            let next_out_of_line = decoder.next_out_of_line();
12403            let handles_before = decoder.remaining_handles();
12404            if let Some((inlined, num_bytes, num_handles)) =
12405                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12406            {
12407                let member_inline_size = <fidl::encoding::Endpoint<
12408                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
12409                > as fidl::encoding::TypeMarker>::inline_size(
12410                    decoder.context
12411                );
12412                if inlined != (member_inline_size <= 4) {
12413                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12414                }
12415                let inner_offset;
12416                let mut inner_depth = depth.clone();
12417                if inlined {
12418                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12419                    inner_offset = next_offset;
12420                } else {
12421                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12422                    inner_depth.increment()?;
12423                }
12424                let val_ref = self.buffer_collection_token2.get_or_insert_with(|| {
12425                    fidl::new_empty!(
12426                        fidl::encoding::Endpoint<
12427                            fidl::endpoints::ClientEnd<
12428                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
12429                            >,
12430                        >,
12431                        fidl::encoding::DefaultFuchsiaResourceDialect
12432                    )
12433                });
12434                fidl::decode!(
12435                    fidl::encoding::Endpoint<
12436                        fidl::endpoints::ClientEnd<
12437                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
12438                        >,
12439                    >,
12440                    fidl::encoding::DefaultFuchsiaResourceDialect,
12441                    val_ref,
12442                    decoder,
12443                    inner_offset,
12444                    inner_depth
12445                )?;
12446                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12447                {
12448                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12449                }
12450                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12451                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12452                }
12453            }
12454
12455            next_offset += envelope_size;
12456
12457            // Decode the remaining unknown envelopes.
12458            while next_offset < end_offset {
12459                _next_ordinal_to_read += 1;
12460                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12461                next_offset += envelope_size;
12462            }
12463
12464            Ok(())
12465        }
12466    }
12467
12468    impl ScreenCaptureConfig {
12469        #[inline(always)]
12470        fn max_ordinal_present(&self) -> u64 {
12471            if let Some(_) = self.rotation {
12472                return 4;
12473            }
12474            if let Some(_) = self.buffer_count {
12475                return 3;
12476            }
12477            if let Some(_) = self.size {
12478                return 2;
12479            }
12480            if let Some(_) = self.import_token {
12481                return 1;
12482            }
12483            0
12484        }
12485    }
12486
12487    impl fidl::encoding::ResourceTypeMarker for ScreenCaptureConfig {
12488        type Borrowed<'a> = &'a mut Self;
12489        fn take_or_borrow<'a>(
12490            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12491        ) -> Self::Borrowed<'a> {
12492            value
12493        }
12494    }
12495
12496    unsafe impl fidl::encoding::TypeMarker for ScreenCaptureConfig {
12497        type Owned = Self;
12498
12499        #[inline(always)]
12500        fn inline_align(_context: fidl::encoding::Context) -> usize {
12501            8
12502        }
12503
12504        #[inline(always)]
12505        fn inline_size(_context: fidl::encoding::Context) -> usize {
12506            16
12507        }
12508    }
12509
12510    unsafe impl
12511        fidl::encoding::Encode<ScreenCaptureConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
12512        for &mut ScreenCaptureConfig
12513    {
12514        unsafe fn encode(
12515            self,
12516            encoder: &mut fidl::encoding::Encoder<
12517                '_,
12518                fidl::encoding::DefaultFuchsiaResourceDialect,
12519            >,
12520            offset: usize,
12521            mut depth: fidl::encoding::Depth,
12522        ) -> fidl::Result<()> {
12523            encoder.debug_check_bounds::<ScreenCaptureConfig>(offset);
12524            // Vector header
12525            let max_ordinal: u64 = self.max_ordinal_present();
12526            encoder.write_num(max_ordinal, offset);
12527            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12528            // Calling encoder.out_of_line_offset(0) is not allowed.
12529            if max_ordinal == 0 {
12530                return Ok(());
12531            }
12532            depth.increment()?;
12533            let envelope_size = 8;
12534            let bytes_len = max_ordinal as usize * envelope_size;
12535            #[allow(unused_variables)]
12536            let offset = encoder.out_of_line_offset(bytes_len);
12537            let mut _prev_end_offset: usize = 0;
12538            if 1 > max_ordinal {
12539                return Ok(());
12540            }
12541
12542            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12543            // are envelope_size bytes.
12544            let cur_offset: usize = (1 - 1) * envelope_size;
12545
12546            // Zero reserved fields.
12547            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12548
12549            // Safety:
12550            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12551            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12552            //   envelope_size bytes, there is always sufficient room.
12553            fidl::encoding::encode_in_envelope_optional::<BufferCollectionImportToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
12554            self.import_token.as_mut().map(<BufferCollectionImportToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
12555            encoder, offset + cur_offset, depth
12556        )?;
12557
12558            _prev_end_offset = cur_offset + envelope_size;
12559            if 2 > max_ordinal {
12560                return Ok(());
12561            }
12562
12563            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12564            // are envelope_size bytes.
12565            let cur_offset: usize = (2 - 1) * envelope_size;
12566
12567            // Zero reserved fields.
12568            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12569
12570            // Safety:
12571            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12572            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12573            //   envelope_size bytes, there is always sufficient room.
12574            fidl::encoding::encode_in_envelope_optional::<
12575                fidl_fuchsia_math::SizeU,
12576                fidl::encoding::DefaultFuchsiaResourceDialect,
12577            >(
12578                self.size
12579                    .as_ref()
12580                    .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
12581                encoder,
12582                offset + cur_offset,
12583                depth,
12584            )?;
12585
12586            _prev_end_offset = cur_offset + envelope_size;
12587            if 3 > max_ordinal {
12588                return Ok(());
12589            }
12590
12591            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12592            // are envelope_size bytes.
12593            let cur_offset: usize = (3 - 1) * envelope_size;
12594
12595            // Zero reserved fields.
12596            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12597
12598            // Safety:
12599            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12600            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12601            //   envelope_size bytes, there is always sufficient room.
12602            fidl::encoding::encode_in_envelope_optional::<
12603                u32,
12604                fidl::encoding::DefaultFuchsiaResourceDialect,
12605            >(
12606                self.buffer_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
12607                encoder,
12608                offset + cur_offset,
12609                depth,
12610            )?;
12611
12612            _prev_end_offset = cur_offset + envelope_size;
12613            if 4 > max_ordinal {
12614                return Ok(());
12615            }
12616
12617            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12618            // are envelope_size bytes.
12619            let cur_offset: usize = (4 - 1) * envelope_size;
12620
12621            // Zero reserved fields.
12622            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12623
12624            // Safety:
12625            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12626            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12627            //   envelope_size bytes, there is always sufficient room.
12628            fidl::encoding::encode_in_envelope_optional::<
12629                Rotation,
12630                fidl::encoding::DefaultFuchsiaResourceDialect,
12631            >(
12632                self.rotation.as_ref().map(<Rotation as fidl::encoding::ValueTypeMarker>::borrow),
12633                encoder,
12634                offset + cur_offset,
12635                depth,
12636            )?;
12637
12638            _prev_end_offset = cur_offset + envelope_size;
12639
12640            Ok(())
12641        }
12642    }
12643
12644    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12645        for ScreenCaptureConfig
12646    {
12647        #[inline(always)]
12648        fn new_empty() -> Self {
12649            Self::default()
12650        }
12651
12652        unsafe fn decode(
12653            &mut self,
12654            decoder: &mut fidl::encoding::Decoder<
12655                '_,
12656                fidl::encoding::DefaultFuchsiaResourceDialect,
12657            >,
12658            offset: usize,
12659            mut depth: fidl::encoding::Depth,
12660        ) -> fidl::Result<()> {
12661            decoder.debug_check_bounds::<Self>(offset);
12662            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12663                None => return Err(fidl::Error::NotNullable),
12664                Some(len) => len,
12665            };
12666            // Calling decoder.out_of_line_offset(0) is not allowed.
12667            if len == 0 {
12668                return Ok(());
12669            };
12670            depth.increment()?;
12671            let envelope_size = 8;
12672            let bytes_len = len * envelope_size;
12673            let offset = decoder.out_of_line_offset(bytes_len)?;
12674            // Decode the envelope for each type.
12675            let mut _next_ordinal_to_read = 0;
12676            let mut next_offset = offset;
12677            let end_offset = offset + bytes_len;
12678            _next_ordinal_to_read += 1;
12679            if next_offset >= end_offset {
12680                return Ok(());
12681            }
12682
12683            // Decode unknown envelopes for gaps in ordinals.
12684            while _next_ordinal_to_read < 1 {
12685                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12686                _next_ordinal_to_read += 1;
12687                next_offset += envelope_size;
12688            }
12689
12690            let next_out_of_line = decoder.next_out_of_line();
12691            let handles_before = decoder.remaining_handles();
12692            if let Some((inlined, num_bytes, num_handles)) =
12693                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12694            {
12695                let member_inline_size =
12696                    <BufferCollectionImportToken as fidl::encoding::TypeMarker>::inline_size(
12697                        decoder.context,
12698                    );
12699                if inlined != (member_inline_size <= 4) {
12700                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12701                }
12702                let inner_offset;
12703                let mut inner_depth = depth.clone();
12704                if inlined {
12705                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12706                    inner_offset = next_offset;
12707                } else {
12708                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12709                    inner_depth.increment()?;
12710                }
12711                let val_ref = self.import_token.get_or_insert_with(|| {
12712                    fidl::new_empty!(
12713                        BufferCollectionImportToken,
12714                        fidl::encoding::DefaultFuchsiaResourceDialect
12715                    )
12716                });
12717                fidl::decode!(
12718                    BufferCollectionImportToken,
12719                    fidl::encoding::DefaultFuchsiaResourceDialect,
12720                    val_ref,
12721                    decoder,
12722                    inner_offset,
12723                    inner_depth
12724                )?;
12725                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12726                {
12727                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12728                }
12729                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12730                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12731                }
12732            }
12733
12734            next_offset += envelope_size;
12735            _next_ordinal_to_read += 1;
12736            if next_offset >= end_offset {
12737                return Ok(());
12738            }
12739
12740            // Decode unknown envelopes for gaps in ordinals.
12741            while _next_ordinal_to_read < 2 {
12742                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12743                _next_ordinal_to_read += 1;
12744                next_offset += envelope_size;
12745            }
12746
12747            let next_out_of_line = decoder.next_out_of_line();
12748            let handles_before = decoder.remaining_handles();
12749            if let Some((inlined, num_bytes, num_handles)) =
12750                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12751            {
12752                let member_inline_size =
12753                    <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
12754                        decoder.context,
12755                    );
12756                if inlined != (member_inline_size <= 4) {
12757                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12758                }
12759                let inner_offset;
12760                let mut inner_depth = depth.clone();
12761                if inlined {
12762                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12763                    inner_offset = next_offset;
12764                } else {
12765                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12766                    inner_depth.increment()?;
12767                }
12768                let val_ref = self.size.get_or_insert_with(|| {
12769                    fidl::new_empty!(
12770                        fidl_fuchsia_math::SizeU,
12771                        fidl::encoding::DefaultFuchsiaResourceDialect
12772                    )
12773                });
12774                fidl::decode!(
12775                    fidl_fuchsia_math::SizeU,
12776                    fidl::encoding::DefaultFuchsiaResourceDialect,
12777                    val_ref,
12778                    decoder,
12779                    inner_offset,
12780                    inner_depth
12781                )?;
12782                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12783                {
12784                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12785                }
12786                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12787                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12788                }
12789            }
12790
12791            next_offset += envelope_size;
12792            _next_ordinal_to_read += 1;
12793            if next_offset >= end_offset {
12794                return Ok(());
12795            }
12796
12797            // Decode unknown envelopes for gaps in ordinals.
12798            while _next_ordinal_to_read < 3 {
12799                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12800                _next_ordinal_to_read += 1;
12801                next_offset += envelope_size;
12802            }
12803
12804            let next_out_of_line = decoder.next_out_of_line();
12805            let handles_before = decoder.remaining_handles();
12806            if let Some((inlined, num_bytes, num_handles)) =
12807                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12808            {
12809                let member_inline_size =
12810                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12811                if inlined != (member_inline_size <= 4) {
12812                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12813                }
12814                let inner_offset;
12815                let mut inner_depth = depth.clone();
12816                if inlined {
12817                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12818                    inner_offset = next_offset;
12819                } else {
12820                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12821                    inner_depth.increment()?;
12822                }
12823                let val_ref = self.buffer_count.get_or_insert_with(|| {
12824                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
12825                });
12826                fidl::decode!(
12827                    u32,
12828                    fidl::encoding::DefaultFuchsiaResourceDialect,
12829                    val_ref,
12830                    decoder,
12831                    inner_offset,
12832                    inner_depth
12833                )?;
12834                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12835                {
12836                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12837                }
12838                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12839                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12840                }
12841            }
12842
12843            next_offset += envelope_size;
12844            _next_ordinal_to_read += 1;
12845            if next_offset >= end_offset {
12846                return Ok(());
12847            }
12848
12849            // Decode unknown envelopes for gaps in ordinals.
12850            while _next_ordinal_to_read < 4 {
12851                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12852                _next_ordinal_to_read += 1;
12853                next_offset += envelope_size;
12854            }
12855
12856            let next_out_of_line = decoder.next_out_of_line();
12857            let handles_before = decoder.remaining_handles();
12858            if let Some((inlined, num_bytes, num_handles)) =
12859                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12860            {
12861                let member_inline_size =
12862                    <Rotation as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12863                if inlined != (member_inline_size <= 4) {
12864                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12865                }
12866                let inner_offset;
12867                let mut inner_depth = depth.clone();
12868                if inlined {
12869                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12870                    inner_offset = next_offset;
12871                } else {
12872                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12873                    inner_depth.increment()?;
12874                }
12875                let val_ref = self.rotation.get_or_insert_with(|| {
12876                    fidl::new_empty!(Rotation, fidl::encoding::DefaultFuchsiaResourceDialect)
12877                });
12878                fidl::decode!(
12879                    Rotation,
12880                    fidl::encoding::DefaultFuchsiaResourceDialect,
12881                    val_ref,
12882                    decoder,
12883                    inner_offset,
12884                    inner_depth
12885                )?;
12886                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12887                {
12888                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12889                }
12890                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12891                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12892                }
12893            }
12894
12895            next_offset += envelope_size;
12896
12897            // Decode the remaining unknown envelopes.
12898            while next_offset < end_offset {
12899                _next_ordinal_to_read += 1;
12900                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12901                next_offset += envelope_size;
12902            }
12903
12904            Ok(())
12905        }
12906    }
12907
12908    impl ScreenshotTakeFileRequest {
12909        #[inline(always)]
12910        fn max_ordinal_present(&self) -> u64 {
12911            if let Some(_) = self.format {
12912                return 1;
12913            }
12914            0
12915        }
12916    }
12917
12918    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeFileRequest {
12919        type Borrowed<'a> = &'a mut Self;
12920        fn take_or_borrow<'a>(
12921            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12922        ) -> Self::Borrowed<'a> {
12923            value
12924        }
12925    }
12926
12927    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeFileRequest {
12928        type Owned = Self;
12929
12930        #[inline(always)]
12931        fn inline_align(_context: fidl::encoding::Context) -> usize {
12932            8
12933        }
12934
12935        #[inline(always)]
12936        fn inline_size(_context: fidl::encoding::Context) -> usize {
12937            16
12938        }
12939    }
12940
12941    unsafe impl
12942        fidl::encoding::Encode<
12943            ScreenshotTakeFileRequest,
12944            fidl::encoding::DefaultFuchsiaResourceDialect,
12945        > for &mut ScreenshotTakeFileRequest
12946    {
12947        unsafe fn encode(
12948            self,
12949            encoder: &mut fidl::encoding::Encoder<
12950                '_,
12951                fidl::encoding::DefaultFuchsiaResourceDialect,
12952            >,
12953            offset: usize,
12954            mut depth: fidl::encoding::Depth,
12955        ) -> fidl::Result<()> {
12956            encoder.debug_check_bounds::<ScreenshotTakeFileRequest>(offset);
12957            // Vector header
12958            let max_ordinal: u64 = self.max_ordinal_present();
12959            encoder.write_num(max_ordinal, offset);
12960            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12961            // Calling encoder.out_of_line_offset(0) is not allowed.
12962            if max_ordinal == 0 {
12963                return Ok(());
12964            }
12965            depth.increment()?;
12966            let envelope_size = 8;
12967            let bytes_len = max_ordinal as usize * envelope_size;
12968            #[allow(unused_variables)]
12969            let offset = encoder.out_of_line_offset(bytes_len);
12970            let mut _prev_end_offset: usize = 0;
12971            if 1 > max_ordinal {
12972                return Ok(());
12973            }
12974
12975            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12976            // are envelope_size bytes.
12977            let cur_offset: usize = (1 - 1) * envelope_size;
12978
12979            // Zero reserved fields.
12980            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12981
12982            // Safety:
12983            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12984            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12985            //   envelope_size bytes, there is always sufficient room.
12986            fidl::encoding::encode_in_envelope_optional::<
12987                ScreenshotFormat,
12988                fidl::encoding::DefaultFuchsiaResourceDialect,
12989            >(
12990                self.format
12991                    .as_ref()
12992                    .map(<ScreenshotFormat as fidl::encoding::ValueTypeMarker>::borrow),
12993                encoder,
12994                offset + cur_offset,
12995                depth,
12996            )?;
12997
12998            _prev_end_offset = cur_offset + envelope_size;
12999
13000            Ok(())
13001        }
13002    }
13003
13004    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13005        for ScreenshotTakeFileRequest
13006    {
13007        #[inline(always)]
13008        fn new_empty() -> Self {
13009            Self::default()
13010        }
13011
13012        unsafe fn decode(
13013            &mut self,
13014            decoder: &mut fidl::encoding::Decoder<
13015                '_,
13016                fidl::encoding::DefaultFuchsiaResourceDialect,
13017            >,
13018            offset: usize,
13019            mut depth: fidl::encoding::Depth,
13020        ) -> fidl::Result<()> {
13021            decoder.debug_check_bounds::<Self>(offset);
13022            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13023                None => return Err(fidl::Error::NotNullable),
13024                Some(len) => len,
13025            };
13026            // Calling decoder.out_of_line_offset(0) is not allowed.
13027            if len == 0 {
13028                return Ok(());
13029            };
13030            depth.increment()?;
13031            let envelope_size = 8;
13032            let bytes_len = len * envelope_size;
13033            let offset = decoder.out_of_line_offset(bytes_len)?;
13034            // Decode the envelope for each type.
13035            let mut _next_ordinal_to_read = 0;
13036            let mut next_offset = offset;
13037            let end_offset = offset + bytes_len;
13038            _next_ordinal_to_read += 1;
13039            if next_offset >= end_offset {
13040                return Ok(());
13041            }
13042
13043            // Decode unknown envelopes for gaps in ordinals.
13044            while _next_ordinal_to_read < 1 {
13045                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13046                _next_ordinal_to_read += 1;
13047                next_offset += envelope_size;
13048            }
13049
13050            let next_out_of_line = decoder.next_out_of_line();
13051            let handles_before = decoder.remaining_handles();
13052            if let Some((inlined, num_bytes, num_handles)) =
13053                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13054            {
13055                let member_inline_size =
13056                    <ScreenshotFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13057                if inlined != (member_inline_size <= 4) {
13058                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13059                }
13060                let inner_offset;
13061                let mut inner_depth = depth.clone();
13062                if inlined {
13063                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13064                    inner_offset = next_offset;
13065                } else {
13066                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13067                    inner_depth.increment()?;
13068                }
13069                let val_ref = self.format.get_or_insert_with(|| {
13070                    fidl::new_empty!(
13071                        ScreenshotFormat,
13072                        fidl::encoding::DefaultFuchsiaResourceDialect
13073                    )
13074                });
13075                fidl::decode!(
13076                    ScreenshotFormat,
13077                    fidl::encoding::DefaultFuchsiaResourceDialect,
13078                    val_ref,
13079                    decoder,
13080                    inner_offset,
13081                    inner_depth
13082                )?;
13083                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13084                {
13085                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13086                }
13087                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13088                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13089                }
13090            }
13091
13092            next_offset += envelope_size;
13093
13094            // Decode the remaining unknown envelopes.
13095            while next_offset < end_offset {
13096                _next_ordinal_to_read += 1;
13097                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13098                next_offset += envelope_size;
13099            }
13100
13101            Ok(())
13102        }
13103    }
13104
13105    impl ScreenshotTakeFileResponse {
13106        #[inline(always)]
13107        fn max_ordinal_present(&self) -> u64 {
13108            if let Some(_) = self.size {
13109                return 2;
13110            }
13111            if let Some(_) = self.file {
13112                return 1;
13113            }
13114            0
13115        }
13116    }
13117
13118    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeFileResponse {
13119        type Borrowed<'a> = &'a mut Self;
13120        fn take_or_borrow<'a>(
13121            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13122        ) -> Self::Borrowed<'a> {
13123            value
13124        }
13125    }
13126
13127    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeFileResponse {
13128        type Owned = Self;
13129
13130        #[inline(always)]
13131        fn inline_align(_context: fidl::encoding::Context) -> usize {
13132            8
13133        }
13134
13135        #[inline(always)]
13136        fn inline_size(_context: fidl::encoding::Context) -> usize {
13137            16
13138        }
13139    }
13140
13141    unsafe impl
13142        fidl::encoding::Encode<
13143            ScreenshotTakeFileResponse,
13144            fidl::encoding::DefaultFuchsiaResourceDialect,
13145        > for &mut ScreenshotTakeFileResponse
13146    {
13147        unsafe fn encode(
13148            self,
13149            encoder: &mut fidl::encoding::Encoder<
13150                '_,
13151                fidl::encoding::DefaultFuchsiaResourceDialect,
13152            >,
13153            offset: usize,
13154            mut depth: fidl::encoding::Depth,
13155        ) -> fidl::Result<()> {
13156            encoder.debug_check_bounds::<ScreenshotTakeFileResponse>(offset);
13157            // Vector header
13158            let max_ordinal: u64 = self.max_ordinal_present();
13159            encoder.write_num(max_ordinal, offset);
13160            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13161            // Calling encoder.out_of_line_offset(0) is not allowed.
13162            if max_ordinal == 0 {
13163                return Ok(());
13164            }
13165            depth.increment()?;
13166            let envelope_size = 8;
13167            let bytes_len = max_ordinal as usize * envelope_size;
13168            #[allow(unused_variables)]
13169            let offset = encoder.out_of_line_offset(bytes_len);
13170            let mut _prev_end_offset: usize = 0;
13171            if 1 > max_ordinal {
13172                return Ok(());
13173            }
13174
13175            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13176            // are envelope_size bytes.
13177            let cur_offset: usize = (1 - 1) * envelope_size;
13178
13179            // Zero reserved fields.
13180            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13181
13182            // Safety:
13183            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13184            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13185            //   envelope_size bytes, there is always sufficient room.
13186            fidl::encoding::encode_in_envelope_optional::<
13187                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
13188                fidl::encoding::DefaultFuchsiaResourceDialect,
13189            >(
13190                self.file.as_mut().map(
13191                    <fidl::encoding::Endpoint<
13192                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13193                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13194                ),
13195                encoder,
13196                offset + cur_offset,
13197                depth,
13198            )?;
13199
13200            _prev_end_offset = cur_offset + envelope_size;
13201            if 2 > max_ordinal {
13202                return Ok(());
13203            }
13204
13205            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13206            // are envelope_size bytes.
13207            let cur_offset: usize = (2 - 1) * envelope_size;
13208
13209            // Zero reserved fields.
13210            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13211
13212            // Safety:
13213            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13214            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13215            //   envelope_size bytes, there is always sufficient room.
13216            fidl::encoding::encode_in_envelope_optional::<
13217                fidl_fuchsia_math::SizeU,
13218                fidl::encoding::DefaultFuchsiaResourceDialect,
13219            >(
13220                self.size
13221                    .as_ref()
13222                    .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
13223                encoder,
13224                offset + cur_offset,
13225                depth,
13226            )?;
13227
13228            _prev_end_offset = cur_offset + envelope_size;
13229
13230            Ok(())
13231        }
13232    }
13233
13234    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13235        for ScreenshotTakeFileResponse
13236    {
13237        #[inline(always)]
13238        fn new_empty() -> Self {
13239            Self::default()
13240        }
13241
13242        unsafe fn decode(
13243            &mut self,
13244            decoder: &mut fidl::encoding::Decoder<
13245                '_,
13246                fidl::encoding::DefaultFuchsiaResourceDialect,
13247            >,
13248            offset: usize,
13249            mut depth: fidl::encoding::Depth,
13250        ) -> fidl::Result<()> {
13251            decoder.debug_check_bounds::<Self>(offset);
13252            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13253                None => return Err(fidl::Error::NotNullable),
13254                Some(len) => len,
13255            };
13256            // Calling decoder.out_of_line_offset(0) is not allowed.
13257            if len == 0 {
13258                return Ok(());
13259            };
13260            depth.increment()?;
13261            let envelope_size = 8;
13262            let bytes_len = len * envelope_size;
13263            let offset = decoder.out_of_line_offset(bytes_len)?;
13264            // Decode the envelope for each type.
13265            let mut _next_ordinal_to_read = 0;
13266            let mut next_offset = offset;
13267            let end_offset = offset + bytes_len;
13268            _next_ordinal_to_read += 1;
13269            if next_offset >= end_offset {
13270                return Ok(());
13271            }
13272
13273            // Decode unknown envelopes for gaps in ordinals.
13274            while _next_ordinal_to_read < 1 {
13275                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13276                _next_ordinal_to_read += 1;
13277                next_offset += envelope_size;
13278            }
13279
13280            let next_out_of_line = decoder.next_out_of_line();
13281            let handles_before = decoder.remaining_handles();
13282            if let Some((inlined, num_bytes, num_handles)) =
13283                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13284            {
13285                let member_inline_size = <fidl::encoding::Endpoint<
13286                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13287                > as fidl::encoding::TypeMarker>::inline_size(
13288                    decoder.context
13289                );
13290                if inlined != (member_inline_size <= 4) {
13291                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13292                }
13293                let inner_offset;
13294                let mut inner_depth = depth.clone();
13295                if inlined {
13296                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13297                    inner_offset = next_offset;
13298                } else {
13299                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13300                    inner_depth.increment()?;
13301                }
13302                let val_ref = self.file.get_or_insert_with(|| {
13303                    fidl::new_empty!(
13304                        fidl::encoding::Endpoint<
13305                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13306                        >,
13307                        fidl::encoding::DefaultFuchsiaResourceDialect
13308                    )
13309                });
13310                fidl::decode!(
13311                    fidl::encoding::Endpoint<
13312                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13313                    >,
13314                    fidl::encoding::DefaultFuchsiaResourceDialect,
13315                    val_ref,
13316                    decoder,
13317                    inner_offset,
13318                    inner_depth
13319                )?;
13320                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13321                {
13322                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13323                }
13324                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13325                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13326                }
13327            }
13328
13329            next_offset += envelope_size;
13330            _next_ordinal_to_read += 1;
13331            if next_offset >= end_offset {
13332                return Ok(());
13333            }
13334
13335            // Decode unknown envelopes for gaps in ordinals.
13336            while _next_ordinal_to_read < 2 {
13337                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13338                _next_ordinal_to_read += 1;
13339                next_offset += envelope_size;
13340            }
13341
13342            let next_out_of_line = decoder.next_out_of_line();
13343            let handles_before = decoder.remaining_handles();
13344            if let Some((inlined, num_bytes, num_handles)) =
13345                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13346            {
13347                let member_inline_size =
13348                    <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
13349                        decoder.context,
13350                    );
13351                if inlined != (member_inline_size <= 4) {
13352                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13353                }
13354                let inner_offset;
13355                let mut inner_depth = depth.clone();
13356                if inlined {
13357                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13358                    inner_offset = next_offset;
13359                } else {
13360                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13361                    inner_depth.increment()?;
13362                }
13363                let val_ref = self.size.get_or_insert_with(|| {
13364                    fidl::new_empty!(
13365                        fidl_fuchsia_math::SizeU,
13366                        fidl::encoding::DefaultFuchsiaResourceDialect
13367                    )
13368                });
13369                fidl::decode!(
13370                    fidl_fuchsia_math::SizeU,
13371                    fidl::encoding::DefaultFuchsiaResourceDialect,
13372                    val_ref,
13373                    decoder,
13374                    inner_offset,
13375                    inner_depth
13376                )?;
13377                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13378                {
13379                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13380                }
13381                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13382                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13383                }
13384            }
13385
13386            next_offset += envelope_size;
13387
13388            // Decode the remaining unknown envelopes.
13389            while next_offset < end_offset {
13390                _next_ordinal_to_read += 1;
13391                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13392                next_offset += envelope_size;
13393            }
13394
13395            Ok(())
13396        }
13397    }
13398
13399    impl ScreenshotTakeRequest {
13400        #[inline(always)]
13401        fn max_ordinal_present(&self) -> u64 {
13402            if let Some(_) = self.format {
13403                return 1;
13404            }
13405            0
13406        }
13407    }
13408
13409    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeRequest {
13410        type Borrowed<'a> = &'a mut Self;
13411        fn take_or_borrow<'a>(
13412            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13413        ) -> Self::Borrowed<'a> {
13414            value
13415        }
13416    }
13417
13418    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeRequest {
13419        type Owned = Self;
13420
13421        #[inline(always)]
13422        fn inline_align(_context: fidl::encoding::Context) -> usize {
13423            8
13424        }
13425
13426        #[inline(always)]
13427        fn inline_size(_context: fidl::encoding::Context) -> usize {
13428            16
13429        }
13430    }
13431
13432    unsafe impl
13433        fidl::encoding::Encode<ScreenshotTakeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13434        for &mut ScreenshotTakeRequest
13435    {
13436        unsafe fn encode(
13437            self,
13438            encoder: &mut fidl::encoding::Encoder<
13439                '_,
13440                fidl::encoding::DefaultFuchsiaResourceDialect,
13441            >,
13442            offset: usize,
13443            mut depth: fidl::encoding::Depth,
13444        ) -> fidl::Result<()> {
13445            encoder.debug_check_bounds::<ScreenshotTakeRequest>(offset);
13446            // Vector header
13447            let max_ordinal: u64 = self.max_ordinal_present();
13448            encoder.write_num(max_ordinal, offset);
13449            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13450            // Calling encoder.out_of_line_offset(0) is not allowed.
13451            if max_ordinal == 0 {
13452                return Ok(());
13453            }
13454            depth.increment()?;
13455            let envelope_size = 8;
13456            let bytes_len = max_ordinal as usize * envelope_size;
13457            #[allow(unused_variables)]
13458            let offset = encoder.out_of_line_offset(bytes_len);
13459            let mut _prev_end_offset: usize = 0;
13460            if 1 > max_ordinal {
13461                return Ok(());
13462            }
13463
13464            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13465            // are envelope_size bytes.
13466            let cur_offset: usize = (1 - 1) * envelope_size;
13467
13468            // Zero reserved fields.
13469            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13470
13471            // Safety:
13472            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13473            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13474            //   envelope_size bytes, there is always sufficient room.
13475            fidl::encoding::encode_in_envelope_optional::<
13476                ScreenshotFormat,
13477                fidl::encoding::DefaultFuchsiaResourceDialect,
13478            >(
13479                self.format
13480                    .as_ref()
13481                    .map(<ScreenshotFormat as fidl::encoding::ValueTypeMarker>::borrow),
13482                encoder,
13483                offset + cur_offset,
13484                depth,
13485            )?;
13486
13487            _prev_end_offset = cur_offset + envelope_size;
13488
13489            Ok(())
13490        }
13491    }
13492
13493    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13494        for ScreenshotTakeRequest
13495    {
13496        #[inline(always)]
13497        fn new_empty() -> Self {
13498            Self::default()
13499        }
13500
13501        unsafe fn decode(
13502            &mut self,
13503            decoder: &mut fidl::encoding::Decoder<
13504                '_,
13505                fidl::encoding::DefaultFuchsiaResourceDialect,
13506            >,
13507            offset: usize,
13508            mut depth: fidl::encoding::Depth,
13509        ) -> fidl::Result<()> {
13510            decoder.debug_check_bounds::<Self>(offset);
13511            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13512                None => return Err(fidl::Error::NotNullable),
13513                Some(len) => len,
13514            };
13515            // Calling decoder.out_of_line_offset(0) is not allowed.
13516            if len == 0 {
13517                return Ok(());
13518            };
13519            depth.increment()?;
13520            let envelope_size = 8;
13521            let bytes_len = len * envelope_size;
13522            let offset = decoder.out_of_line_offset(bytes_len)?;
13523            // Decode the envelope for each type.
13524            let mut _next_ordinal_to_read = 0;
13525            let mut next_offset = offset;
13526            let end_offset = offset + bytes_len;
13527            _next_ordinal_to_read += 1;
13528            if next_offset >= end_offset {
13529                return Ok(());
13530            }
13531
13532            // Decode unknown envelopes for gaps in ordinals.
13533            while _next_ordinal_to_read < 1 {
13534                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13535                _next_ordinal_to_read += 1;
13536                next_offset += envelope_size;
13537            }
13538
13539            let next_out_of_line = decoder.next_out_of_line();
13540            let handles_before = decoder.remaining_handles();
13541            if let Some((inlined, num_bytes, num_handles)) =
13542                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13543            {
13544                let member_inline_size =
13545                    <ScreenshotFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13546                if inlined != (member_inline_size <= 4) {
13547                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13548                }
13549                let inner_offset;
13550                let mut inner_depth = depth.clone();
13551                if inlined {
13552                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13553                    inner_offset = next_offset;
13554                } else {
13555                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13556                    inner_depth.increment()?;
13557                }
13558                let val_ref = self.format.get_or_insert_with(|| {
13559                    fidl::new_empty!(
13560                        ScreenshotFormat,
13561                        fidl::encoding::DefaultFuchsiaResourceDialect
13562                    )
13563                });
13564                fidl::decode!(
13565                    ScreenshotFormat,
13566                    fidl::encoding::DefaultFuchsiaResourceDialect,
13567                    val_ref,
13568                    decoder,
13569                    inner_offset,
13570                    inner_depth
13571                )?;
13572                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13573                {
13574                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13575                }
13576                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13577                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13578                }
13579            }
13580
13581            next_offset += envelope_size;
13582
13583            // Decode the remaining unknown envelopes.
13584            while next_offset < end_offset {
13585                _next_ordinal_to_read += 1;
13586                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13587                next_offset += envelope_size;
13588            }
13589
13590            Ok(())
13591        }
13592    }
13593
13594    impl ScreenshotTakeResponse {
13595        #[inline(always)]
13596        fn max_ordinal_present(&self) -> u64 {
13597            if let Some(_) = self.size {
13598                return 2;
13599            }
13600            if let Some(_) = self.vmo {
13601                return 1;
13602            }
13603            0
13604        }
13605    }
13606
13607    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeResponse {
13608        type Borrowed<'a> = &'a mut Self;
13609        fn take_or_borrow<'a>(
13610            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13611        ) -> Self::Borrowed<'a> {
13612            value
13613        }
13614    }
13615
13616    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeResponse {
13617        type Owned = Self;
13618
13619        #[inline(always)]
13620        fn inline_align(_context: fidl::encoding::Context) -> usize {
13621            8
13622        }
13623
13624        #[inline(always)]
13625        fn inline_size(_context: fidl::encoding::Context) -> usize {
13626            16
13627        }
13628    }
13629
13630    unsafe impl
13631        fidl::encoding::Encode<
13632            ScreenshotTakeResponse,
13633            fidl::encoding::DefaultFuchsiaResourceDialect,
13634        > for &mut ScreenshotTakeResponse
13635    {
13636        unsafe fn encode(
13637            self,
13638            encoder: &mut fidl::encoding::Encoder<
13639                '_,
13640                fidl::encoding::DefaultFuchsiaResourceDialect,
13641            >,
13642            offset: usize,
13643            mut depth: fidl::encoding::Depth,
13644        ) -> fidl::Result<()> {
13645            encoder.debug_check_bounds::<ScreenshotTakeResponse>(offset);
13646            // Vector header
13647            let max_ordinal: u64 = self.max_ordinal_present();
13648            encoder.write_num(max_ordinal, offset);
13649            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13650            // Calling encoder.out_of_line_offset(0) is not allowed.
13651            if max_ordinal == 0 {
13652                return Ok(());
13653            }
13654            depth.increment()?;
13655            let envelope_size = 8;
13656            let bytes_len = max_ordinal as usize * envelope_size;
13657            #[allow(unused_variables)]
13658            let offset = encoder.out_of_line_offset(bytes_len);
13659            let mut _prev_end_offset: usize = 0;
13660            if 1 > max_ordinal {
13661                return Ok(());
13662            }
13663
13664            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13665            // are envelope_size bytes.
13666            let cur_offset: usize = (1 - 1) * envelope_size;
13667
13668            // Zero reserved fields.
13669            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13670
13671            // Safety:
13672            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13673            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13674            //   envelope_size bytes, there is always sufficient room.
13675            fidl::encoding::encode_in_envelope_optional::<
13676                fidl::encoding::HandleType<
13677                    fidl::Vmo,
13678                    { fidl::ObjectType::VMO.into_raw() },
13679                    2147483648,
13680                >,
13681                fidl::encoding::DefaultFuchsiaResourceDialect,
13682            >(
13683                self.vmo.as_mut().map(
13684                    <fidl::encoding::HandleType<
13685                        fidl::Vmo,
13686                        { fidl::ObjectType::VMO.into_raw() },
13687                        2147483648,
13688                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13689                ),
13690                encoder,
13691                offset + cur_offset,
13692                depth,
13693            )?;
13694
13695            _prev_end_offset = cur_offset + envelope_size;
13696            if 2 > max_ordinal {
13697                return Ok(());
13698            }
13699
13700            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13701            // are envelope_size bytes.
13702            let cur_offset: usize = (2 - 1) * envelope_size;
13703
13704            // Zero reserved fields.
13705            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13706
13707            // Safety:
13708            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13709            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13710            //   envelope_size bytes, there is always sufficient room.
13711            fidl::encoding::encode_in_envelope_optional::<
13712                fidl_fuchsia_math::SizeU,
13713                fidl::encoding::DefaultFuchsiaResourceDialect,
13714            >(
13715                self.size
13716                    .as_ref()
13717                    .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
13718                encoder,
13719                offset + cur_offset,
13720                depth,
13721            )?;
13722
13723            _prev_end_offset = cur_offset + envelope_size;
13724
13725            Ok(())
13726        }
13727    }
13728
13729    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13730        for ScreenshotTakeResponse
13731    {
13732        #[inline(always)]
13733        fn new_empty() -> Self {
13734            Self::default()
13735        }
13736
13737        unsafe fn decode(
13738            &mut self,
13739            decoder: &mut fidl::encoding::Decoder<
13740                '_,
13741                fidl::encoding::DefaultFuchsiaResourceDialect,
13742            >,
13743            offset: usize,
13744            mut depth: fidl::encoding::Depth,
13745        ) -> fidl::Result<()> {
13746            decoder.debug_check_bounds::<Self>(offset);
13747            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13748                None => return Err(fidl::Error::NotNullable),
13749                Some(len) => len,
13750            };
13751            // Calling decoder.out_of_line_offset(0) is not allowed.
13752            if len == 0 {
13753                return Ok(());
13754            };
13755            depth.increment()?;
13756            let envelope_size = 8;
13757            let bytes_len = len * envelope_size;
13758            let offset = decoder.out_of_line_offset(bytes_len)?;
13759            // Decode the envelope for each type.
13760            let mut _next_ordinal_to_read = 0;
13761            let mut next_offset = offset;
13762            let end_offset = offset + bytes_len;
13763            _next_ordinal_to_read += 1;
13764            if next_offset >= end_offset {
13765                return Ok(());
13766            }
13767
13768            // Decode unknown envelopes for gaps in ordinals.
13769            while _next_ordinal_to_read < 1 {
13770                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13771                _next_ordinal_to_read += 1;
13772                next_offset += envelope_size;
13773            }
13774
13775            let next_out_of_line = decoder.next_out_of_line();
13776            let handles_before = decoder.remaining_handles();
13777            if let Some((inlined, num_bytes, num_handles)) =
13778                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13779            {
13780                let member_inline_size = <fidl::encoding::HandleType<
13781                    fidl::Vmo,
13782                    { fidl::ObjectType::VMO.into_raw() },
13783                    2147483648,
13784                > as fidl::encoding::TypeMarker>::inline_size(
13785                    decoder.context
13786                );
13787                if inlined != (member_inline_size <= 4) {
13788                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13789                }
13790                let inner_offset;
13791                let mut inner_depth = depth.clone();
13792                if inlined {
13793                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13794                    inner_offset = next_offset;
13795                } else {
13796                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13797                    inner_depth.increment()?;
13798                }
13799                let val_ref =
13800                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
13801                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
13802                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13803                {
13804                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13805                }
13806                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13807                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13808                }
13809            }
13810
13811            next_offset += envelope_size;
13812            _next_ordinal_to_read += 1;
13813            if next_offset >= end_offset {
13814                return Ok(());
13815            }
13816
13817            // Decode unknown envelopes for gaps in ordinals.
13818            while _next_ordinal_to_read < 2 {
13819                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13820                _next_ordinal_to_read += 1;
13821                next_offset += envelope_size;
13822            }
13823
13824            let next_out_of_line = decoder.next_out_of_line();
13825            let handles_before = decoder.remaining_handles();
13826            if let Some((inlined, num_bytes, num_handles)) =
13827                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13828            {
13829                let member_inline_size =
13830                    <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
13831                        decoder.context,
13832                    );
13833                if inlined != (member_inline_size <= 4) {
13834                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13835                }
13836                let inner_offset;
13837                let mut inner_depth = depth.clone();
13838                if inlined {
13839                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13840                    inner_offset = next_offset;
13841                } else {
13842                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13843                    inner_depth.increment()?;
13844                }
13845                let val_ref = self.size.get_or_insert_with(|| {
13846                    fidl::new_empty!(
13847                        fidl_fuchsia_math::SizeU,
13848                        fidl::encoding::DefaultFuchsiaResourceDialect
13849                    )
13850                });
13851                fidl::decode!(
13852                    fidl_fuchsia_math::SizeU,
13853                    fidl::encoding::DefaultFuchsiaResourceDialect,
13854                    val_ref,
13855                    decoder,
13856                    inner_offset,
13857                    inner_depth
13858                )?;
13859                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13860                {
13861                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13862                }
13863                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13864                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13865                }
13866            }
13867
13868            next_offset += envelope_size;
13869
13870            // Decode the remaining unknown envelopes.
13871            while next_offset < end_offset {
13872                _next_ordinal_to_read += 1;
13873                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13874                next_offset += envelope_size;
13875            }
13876
13877            Ok(())
13878        }
13879    }
13880
13881    impl TrustedFlatlandConfig {
13882        #[inline(always)]
13883        fn max_ordinal_present(&self) -> u64 {
13884            if let Some(_) = self.skips_present_credits {
13885                return 3;
13886            }
13887            if let Some(_) = self.pass_acquire_fences {
13888                return 2;
13889            }
13890            if let Some(_) = self.schedule_asap {
13891                return 1;
13892            }
13893            0
13894        }
13895    }
13896
13897    impl fidl::encoding::ResourceTypeMarker for TrustedFlatlandConfig {
13898        type Borrowed<'a> = &'a mut Self;
13899        fn take_or_borrow<'a>(
13900            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13901        ) -> Self::Borrowed<'a> {
13902            value
13903        }
13904    }
13905
13906    unsafe impl fidl::encoding::TypeMarker for TrustedFlatlandConfig {
13907        type Owned = Self;
13908
13909        #[inline(always)]
13910        fn inline_align(_context: fidl::encoding::Context) -> usize {
13911            8
13912        }
13913
13914        #[inline(always)]
13915        fn inline_size(_context: fidl::encoding::Context) -> usize {
13916            16
13917        }
13918    }
13919
13920    unsafe impl
13921        fidl::encoding::Encode<TrustedFlatlandConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
13922        for &mut TrustedFlatlandConfig
13923    {
13924        unsafe fn encode(
13925            self,
13926            encoder: &mut fidl::encoding::Encoder<
13927                '_,
13928                fidl::encoding::DefaultFuchsiaResourceDialect,
13929            >,
13930            offset: usize,
13931            mut depth: fidl::encoding::Depth,
13932        ) -> fidl::Result<()> {
13933            encoder.debug_check_bounds::<TrustedFlatlandConfig>(offset);
13934            // Vector header
13935            let max_ordinal: u64 = self.max_ordinal_present();
13936            encoder.write_num(max_ordinal, offset);
13937            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13938            // Calling encoder.out_of_line_offset(0) is not allowed.
13939            if max_ordinal == 0 {
13940                return Ok(());
13941            }
13942            depth.increment()?;
13943            let envelope_size = 8;
13944            let bytes_len = max_ordinal as usize * envelope_size;
13945            #[allow(unused_variables)]
13946            let offset = encoder.out_of_line_offset(bytes_len);
13947            let mut _prev_end_offset: usize = 0;
13948            if 1 > max_ordinal {
13949                return Ok(());
13950            }
13951
13952            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13953            // are envelope_size bytes.
13954            let cur_offset: usize = (1 - 1) * envelope_size;
13955
13956            // Zero reserved fields.
13957            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13958
13959            // Safety:
13960            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13961            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13962            //   envelope_size bytes, there is always sufficient room.
13963            fidl::encoding::encode_in_envelope_optional::<
13964                bool,
13965                fidl::encoding::DefaultFuchsiaResourceDialect,
13966            >(
13967                self.schedule_asap.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
13968                encoder,
13969                offset + cur_offset,
13970                depth,
13971            )?;
13972
13973            _prev_end_offset = cur_offset + envelope_size;
13974            if 2 > max_ordinal {
13975                return Ok(());
13976            }
13977
13978            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13979            // are envelope_size bytes.
13980            let cur_offset: usize = (2 - 1) * envelope_size;
13981
13982            // Zero reserved fields.
13983            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13984
13985            // Safety:
13986            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13987            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13988            //   envelope_size bytes, there is always sufficient room.
13989            fidl::encoding::encode_in_envelope_optional::<
13990                bool,
13991                fidl::encoding::DefaultFuchsiaResourceDialect,
13992            >(
13993                self.pass_acquire_fences
13994                    .as_ref()
13995                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
13996                encoder,
13997                offset + cur_offset,
13998                depth,
13999            )?;
14000
14001            _prev_end_offset = cur_offset + envelope_size;
14002            if 3 > max_ordinal {
14003                return Ok(());
14004            }
14005
14006            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14007            // are envelope_size bytes.
14008            let cur_offset: usize = (3 - 1) * envelope_size;
14009
14010            // Zero reserved fields.
14011            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14012
14013            // Safety:
14014            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14015            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14016            //   envelope_size bytes, there is always sufficient room.
14017            fidl::encoding::encode_in_envelope_optional::<
14018                bool,
14019                fidl::encoding::DefaultFuchsiaResourceDialect,
14020            >(
14021                self.skips_present_credits
14022                    .as_ref()
14023                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14024                encoder,
14025                offset + cur_offset,
14026                depth,
14027            )?;
14028
14029            _prev_end_offset = cur_offset + envelope_size;
14030
14031            Ok(())
14032        }
14033    }
14034
14035    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14036        for TrustedFlatlandConfig
14037    {
14038        #[inline(always)]
14039        fn new_empty() -> Self {
14040            Self::default()
14041        }
14042
14043        unsafe fn decode(
14044            &mut self,
14045            decoder: &mut fidl::encoding::Decoder<
14046                '_,
14047                fidl::encoding::DefaultFuchsiaResourceDialect,
14048            >,
14049            offset: usize,
14050            mut depth: fidl::encoding::Depth,
14051        ) -> fidl::Result<()> {
14052            decoder.debug_check_bounds::<Self>(offset);
14053            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14054                None => return Err(fidl::Error::NotNullable),
14055                Some(len) => len,
14056            };
14057            // Calling decoder.out_of_line_offset(0) is not allowed.
14058            if len == 0 {
14059                return Ok(());
14060            };
14061            depth.increment()?;
14062            let envelope_size = 8;
14063            let bytes_len = len * envelope_size;
14064            let offset = decoder.out_of_line_offset(bytes_len)?;
14065            // Decode the envelope for each type.
14066            let mut _next_ordinal_to_read = 0;
14067            let mut next_offset = offset;
14068            let end_offset = offset + bytes_len;
14069            _next_ordinal_to_read += 1;
14070            if next_offset >= end_offset {
14071                return Ok(());
14072            }
14073
14074            // Decode unknown envelopes for gaps in ordinals.
14075            while _next_ordinal_to_read < 1 {
14076                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14077                _next_ordinal_to_read += 1;
14078                next_offset += envelope_size;
14079            }
14080
14081            let next_out_of_line = decoder.next_out_of_line();
14082            let handles_before = decoder.remaining_handles();
14083            if let Some((inlined, num_bytes, num_handles)) =
14084                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14085            {
14086                let member_inline_size =
14087                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14088                if inlined != (member_inline_size <= 4) {
14089                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14090                }
14091                let inner_offset;
14092                let mut inner_depth = depth.clone();
14093                if inlined {
14094                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14095                    inner_offset = next_offset;
14096                } else {
14097                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14098                    inner_depth.increment()?;
14099                }
14100                let val_ref = self.schedule_asap.get_or_insert_with(|| {
14101                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
14102                });
14103                fidl::decode!(
14104                    bool,
14105                    fidl::encoding::DefaultFuchsiaResourceDialect,
14106                    val_ref,
14107                    decoder,
14108                    inner_offset,
14109                    inner_depth
14110                )?;
14111                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14112                {
14113                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14114                }
14115                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14116                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14117                }
14118            }
14119
14120            next_offset += envelope_size;
14121            _next_ordinal_to_read += 1;
14122            if next_offset >= end_offset {
14123                return Ok(());
14124            }
14125
14126            // Decode unknown envelopes for gaps in ordinals.
14127            while _next_ordinal_to_read < 2 {
14128                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14129                _next_ordinal_to_read += 1;
14130                next_offset += envelope_size;
14131            }
14132
14133            let next_out_of_line = decoder.next_out_of_line();
14134            let handles_before = decoder.remaining_handles();
14135            if let Some((inlined, num_bytes, num_handles)) =
14136                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14137            {
14138                let member_inline_size =
14139                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14140                if inlined != (member_inline_size <= 4) {
14141                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14142                }
14143                let inner_offset;
14144                let mut inner_depth = depth.clone();
14145                if inlined {
14146                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14147                    inner_offset = next_offset;
14148                } else {
14149                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14150                    inner_depth.increment()?;
14151                }
14152                let val_ref = self.pass_acquire_fences.get_or_insert_with(|| {
14153                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
14154                });
14155                fidl::decode!(
14156                    bool,
14157                    fidl::encoding::DefaultFuchsiaResourceDialect,
14158                    val_ref,
14159                    decoder,
14160                    inner_offset,
14161                    inner_depth
14162                )?;
14163                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14164                {
14165                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14166                }
14167                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14168                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14169                }
14170            }
14171
14172            next_offset += envelope_size;
14173            _next_ordinal_to_read += 1;
14174            if next_offset >= end_offset {
14175                return Ok(());
14176            }
14177
14178            // Decode unknown envelopes for gaps in ordinals.
14179            while _next_ordinal_to_read < 3 {
14180                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14181                _next_ordinal_to_read += 1;
14182                next_offset += envelope_size;
14183            }
14184
14185            let next_out_of_line = decoder.next_out_of_line();
14186            let handles_before = decoder.remaining_handles();
14187            if let Some((inlined, num_bytes, num_handles)) =
14188                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14189            {
14190                let member_inline_size =
14191                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14192                if inlined != (member_inline_size <= 4) {
14193                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14194                }
14195                let inner_offset;
14196                let mut inner_depth = depth.clone();
14197                if inlined {
14198                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14199                    inner_offset = next_offset;
14200                } else {
14201                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14202                    inner_depth.increment()?;
14203                }
14204                let val_ref = self.skips_present_credits.get_or_insert_with(|| {
14205                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
14206                });
14207                fidl::decode!(
14208                    bool,
14209                    fidl::encoding::DefaultFuchsiaResourceDialect,
14210                    val_ref,
14211                    decoder,
14212                    inner_offset,
14213                    inner_depth
14214                )?;
14215                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14216                {
14217                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14218                }
14219                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14220                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14221                }
14222            }
14223
14224            next_offset += envelope_size;
14225
14226            // Decode the remaining unknown envelopes.
14227            while next_offset < end_offset {
14228                _next_ordinal_to_read += 1;
14229                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14230                next_offset += envelope_size;
14231            }
14232
14233            Ok(())
14234        }
14235    }
14236
14237    impl ViewBoundProtocols {
14238        #[inline(always)]
14239        fn max_ordinal_present(&self) -> u64 {
14240            if let Some(_) = self.mouse_source {
14241                return 4;
14242            }
14243            if let Some(_) = self.touch_source {
14244                return 3;
14245            }
14246            if let Some(_) = self.view_focuser {
14247                return 2;
14248            }
14249            if let Some(_) = self.view_ref_focused {
14250                return 1;
14251            }
14252            0
14253        }
14254    }
14255
14256    impl fidl::encoding::ResourceTypeMarker for ViewBoundProtocols {
14257        type Borrowed<'a> = &'a mut Self;
14258        fn take_or_borrow<'a>(
14259            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14260        ) -> Self::Borrowed<'a> {
14261            value
14262        }
14263    }
14264
14265    unsafe impl fidl::encoding::TypeMarker for ViewBoundProtocols {
14266        type Owned = Self;
14267
14268        #[inline(always)]
14269        fn inline_align(_context: fidl::encoding::Context) -> usize {
14270            8
14271        }
14272
14273        #[inline(always)]
14274        fn inline_size(_context: fidl::encoding::Context) -> usize {
14275            16
14276        }
14277    }
14278
14279    unsafe impl
14280        fidl::encoding::Encode<ViewBoundProtocols, fidl::encoding::DefaultFuchsiaResourceDialect>
14281        for &mut ViewBoundProtocols
14282    {
14283        unsafe fn encode(
14284            self,
14285            encoder: &mut fidl::encoding::Encoder<
14286                '_,
14287                fidl::encoding::DefaultFuchsiaResourceDialect,
14288            >,
14289            offset: usize,
14290            mut depth: fidl::encoding::Depth,
14291        ) -> fidl::Result<()> {
14292            encoder.debug_check_bounds::<ViewBoundProtocols>(offset);
14293            // Vector header
14294            let max_ordinal: u64 = self.max_ordinal_present();
14295            encoder.write_num(max_ordinal, offset);
14296            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14297            // Calling encoder.out_of_line_offset(0) is not allowed.
14298            if max_ordinal == 0 {
14299                return Ok(());
14300            }
14301            depth.increment()?;
14302            let envelope_size = 8;
14303            let bytes_len = max_ordinal as usize * envelope_size;
14304            #[allow(unused_variables)]
14305            let offset = encoder.out_of_line_offset(bytes_len);
14306            let mut _prev_end_offset: usize = 0;
14307            if 1 > max_ordinal {
14308                return Ok(());
14309            }
14310
14311            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14312            // are envelope_size bytes.
14313            let cur_offset: usize = (1 - 1) * envelope_size;
14314
14315            // Zero reserved fields.
14316            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14317
14318            // Safety:
14319            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14320            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14321            //   envelope_size bytes, there is always sufficient room.
14322            fidl::encoding::encode_in_envelope_optional::<
14323                fidl::encoding::Endpoint<
14324                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
14325                >,
14326                fidl::encoding::DefaultFuchsiaResourceDialect,
14327            >(
14328                self.view_ref_focused.as_mut().map(
14329                    <fidl::encoding::Endpoint<
14330                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
14331                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14332                ),
14333                encoder,
14334                offset + cur_offset,
14335                depth,
14336            )?;
14337
14338            _prev_end_offset = cur_offset + envelope_size;
14339            if 2 > max_ordinal {
14340                return Ok(());
14341            }
14342
14343            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14344            // are envelope_size bytes.
14345            let cur_offset: usize = (2 - 1) * envelope_size;
14346
14347            // Zero reserved fields.
14348            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14349
14350            // Safety:
14351            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14352            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14353            //   envelope_size bytes, there is always sufficient room.
14354            fidl::encoding::encode_in_envelope_optional::<
14355                fidl::encoding::Endpoint<
14356                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
14357                >,
14358                fidl::encoding::DefaultFuchsiaResourceDialect,
14359            >(
14360                self.view_focuser.as_mut().map(
14361                    <fidl::encoding::Endpoint<
14362                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
14363                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14364                ),
14365                encoder,
14366                offset + cur_offset,
14367                depth,
14368            )?;
14369
14370            _prev_end_offset = cur_offset + envelope_size;
14371            if 3 > max_ordinal {
14372                return Ok(());
14373            }
14374
14375            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14376            // are envelope_size bytes.
14377            let cur_offset: usize = (3 - 1) * envelope_size;
14378
14379            // Zero reserved fields.
14380            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14381
14382            // Safety:
14383            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14384            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14385            //   envelope_size bytes, there is always sufficient room.
14386            fidl::encoding::encode_in_envelope_optional::<
14387                fidl::encoding::Endpoint<
14388                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
14389                >,
14390                fidl::encoding::DefaultFuchsiaResourceDialect,
14391            >(
14392                self.touch_source.as_mut().map(
14393                    <fidl::encoding::Endpoint<
14394                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
14395                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14396                ),
14397                encoder,
14398                offset + cur_offset,
14399                depth,
14400            )?;
14401
14402            _prev_end_offset = cur_offset + envelope_size;
14403            if 4 > max_ordinal {
14404                return Ok(());
14405            }
14406
14407            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14408            // are envelope_size bytes.
14409            let cur_offset: usize = (4 - 1) * envelope_size;
14410
14411            // Zero reserved fields.
14412            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14413
14414            // Safety:
14415            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14416            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14417            //   envelope_size bytes, there is always sufficient room.
14418            fidl::encoding::encode_in_envelope_optional::<
14419                fidl::encoding::Endpoint<
14420                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14421                >,
14422                fidl::encoding::DefaultFuchsiaResourceDialect,
14423            >(
14424                self.mouse_source.as_mut().map(
14425                    <fidl::encoding::Endpoint<
14426                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14427                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14428                ),
14429                encoder,
14430                offset + cur_offset,
14431                depth,
14432            )?;
14433
14434            _prev_end_offset = cur_offset + envelope_size;
14435
14436            Ok(())
14437        }
14438    }
14439
14440    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14441        for ViewBoundProtocols
14442    {
14443        #[inline(always)]
14444        fn new_empty() -> Self {
14445            Self::default()
14446        }
14447
14448        unsafe fn decode(
14449            &mut self,
14450            decoder: &mut fidl::encoding::Decoder<
14451                '_,
14452                fidl::encoding::DefaultFuchsiaResourceDialect,
14453            >,
14454            offset: usize,
14455            mut depth: fidl::encoding::Depth,
14456        ) -> fidl::Result<()> {
14457            decoder.debug_check_bounds::<Self>(offset);
14458            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14459                None => return Err(fidl::Error::NotNullable),
14460                Some(len) => len,
14461            };
14462            // Calling decoder.out_of_line_offset(0) is not allowed.
14463            if len == 0 {
14464                return Ok(());
14465            };
14466            depth.increment()?;
14467            let envelope_size = 8;
14468            let bytes_len = len * envelope_size;
14469            let offset = decoder.out_of_line_offset(bytes_len)?;
14470            // Decode the envelope for each type.
14471            let mut _next_ordinal_to_read = 0;
14472            let mut next_offset = offset;
14473            let end_offset = offset + bytes_len;
14474            _next_ordinal_to_read += 1;
14475            if next_offset >= end_offset {
14476                return Ok(());
14477            }
14478
14479            // Decode unknown envelopes for gaps in ordinals.
14480            while _next_ordinal_to_read < 1 {
14481                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14482                _next_ordinal_to_read += 1;
14483                next_offset += envelope_size;
14484            }
14485
14486            let next_out_of_line = decoder.next_out_of_line();
14487            let handles_before = decoder.remaining_handles();
14488            if let Some((inlined, num_bytes, num_handles)) =
14489                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14490            {
14491                let member_inline_size = <fidl::encoding::Endpoint<
14492                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
14493                > as fidl::encoding::TypeMarker>::inline_size(
14494                    decoder.context
14495                );
14496                if inlined != (member_inline_size <= 4) {
14497                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14498                }
14499                let inner_offset;
14500                let mut inner_depth = depth.clone();
14501                if inlined {
14502                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14503                    inner_offset = next_offset;
14504                } else {
14505                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14506                    inner_depth.increment()?;
14507                }
14508                let val_ref = self.view_ref_focused.get_or_insert_with(|| {
14509                    fidl::new_empty!(
14510                        fidl::encoding::Endpoint<
14511                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
14512                        >,
14513                        fidl::encoding::DefaultFuchsiaResourceDialect
14514                    )
14515                });
14516                fidl::decode!(
14517                    fidl::encoding::Endpoint<
14518                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
14519                    >,
14520                    fidl::encoding::DefaultFuchsiaResourceDialect,
14521                    val_ref,
14522                    decoder,
14523                    inner_offset,
14524                    inner_depth
14525                )?;
14526                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14527                {
14528                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14529                }
14530                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14531                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14532                }
14533            }
14534
14535            next_offset += envelope_size;
14536            _next_ordinal_to_read += 1;
14537            if next_offset >= end_offset {
14538                return Ok(());
14539            }
14540
14541            // Decode unknown envelopes for gaps in ordinals.
14542            while _next_ordinal_to_read < 2 {
14543                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14544                _next_ordinal_to_read += 1;
14545                next_offset += envelope_size;
14546            }
14547
14548            let next_out_of_line = decoder.next_out_of_line();
14549            let handles_before = decoder.remaining_handles();
14550            if let Some((inlined, num_bytes, num_handles)) =
14551                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14552            {
14553                let member_inline_size = <fidl::encoding::Endpoint<
14554                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
14555                > as fidl::encoding::TypeMarker>::inline_size(
14556                    decoder.context
14557                );
14558                if inlined != (member_inline_size <= 4) {
14559                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14560                }
14561                let inner_offset;
14562                let mut inner_depth = depth.clone();
14563                if inlined {
14564                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14565                    inner_offset = next_offset;
14566                } else {
14567                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14568                    inner_depth.increment()?;
14569                }
14570                let val_ref = self.view_focuser.get_or_insert_with(|| {
14571                    fidl::new_empty!(
14572                        fidl::encoding::Endpoint<
14573                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
14574                        >,
14575                        fidl::encoding::DefaultFuchsiaResourceDialect
14576                    )
14577                });
14578                fidl::decode!(
14579                    fidl::encoding::Endpoint<
14580                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
14581                    >,
14582                    fidl::encoding::DefaultFuchsiaResourceDialect,
14583                    val_ref,
14584                    decoder,
14585                    inner_offset,
14586                    inner_depth
14587                )?;
14588                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14589                {
14590                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14591                }
14592                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14593                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14594                }
14595            }
14596
14597            next_offset += envelope_size;
14598            _next_ordinal_to_read += 1;
14599            if next_offset >= end_offset {
14600                return Ok(());
14601            }
14602
14603            // Decode unknown envelopes for gaps in ordinals.
14604            while _next_ordinal_to_read < 3 {
14605                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14606                _next_ordinal_to_read += 1;
14607                next_offset += envelope_size;
14608            }
14609
14610            let next_out_of_line = decoder.next_out_of_line();
14611            let handles_before = decoder.remaining_handles();
14612            if let Some((inlined, num_bytes, num_handles)) =
14613                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14614            {
14615                let member_inline_size = <fidl::encoding::Endpoint<
14616                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
14617                > as fidl::encoding::TypeMarker>::inline_size(
14618                    decoder.context
14619                );
14620                if inlined != (member_inline_size <= 4) {
14621                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14622                }
14623                let inner_offset;
14624                let mut inner_depth = depth.clone();
14625                if inlined {
14626                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14627                    inner_offset = next_offset;
14628                } else {
14629                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14630                    inner_depth.increment()?;
14631                }
14632                let val_ref = self.touch_source.get_or_insert_with(|| {
14633                    fidl::new_empty!(
14634                        fidl::encoding::Endpoint<
14635                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
14636                        >,
14637                        fidl::encoding::DefaultFuchsiaResourceDialect
14638                    )
14639                });
14640                fidl::decode!(
14641                    fidl::encoding::Endpoint<
14642                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
14643                    >,
14644                    fidl::encoding::DefaultFuchsiaResourceDialect,
14645                    val_ref,
14646                    decoder,
14647                    inner_offset,
14648                    inner_depth
14649                )?;
14650                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14651                {
14652                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14653                }
14654                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14655                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14656                }
14657            }
14658
14659            next_offset += envelope_size;
14660            _next_ordinal_to_read += 1;
14661            if next_offset >= end_offset {
14662                return Ok(());
14663            }
14664
14665            // Decode unknown envelopes for gaps in ordinals.
14666            while _next_ordinal_to_read < 4 {
14667                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14668                _next_ordinal_to_read += 1;
14669                next_offset += envelope_size;
14670            }
14671
14672            let next_out_of_line = decoder.next_out_of_line();
14673            let handles_before = decoder.remaining_handles();
14674            if let Some((inlined, num_bytes, num_handles)) =
14675                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14676            {
14677                let member_inline_size = <fidl::encoding::Endpoint<
14678                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14679                > as fidl::encoding::TypeMarker>::inline_size(
14680                    decoder.context
14681                );
14682                if inlined != (member_inline_size <= 4) {
14683                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14684                }
14685                let inner_offset;
14686                let mut inner_depth = depth.clone();
14687                if inlined {
14688                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14689                    inner_offset = next_offset;
14690                } else {
14691                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14692                    inner_depth.increment()?;
14693                }
14694                let val_ref = self.mouse_source.get_or_insert_with(|| {
14695                    fidl::new_empty!(
14696                        fidl::encoding::Endpoint<
14697                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14698                        >,
14699                        fidl::encoding::DefaultFuchsiaResourceDialect
14700                    )
14701                });
14702                fidl::decode!(
14703                    fidl::encoding::Endpoint<
14704                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14705                    >,
14706                    fidl::encoding::DefaultFuchsiaResourceDialect,
14707                    val_ref,
14708                    decoder,
14709                    inner_offset,
14710                    inner_depth
14711                )?;
14712                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14713                {
14714                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14715                }
14716                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14717                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14718                }
14719            }
14720
14721            next_offset += envelope_size;
14722
14723            // Decode the remaining unknown envelopes.
14724            while next_offset < end_offset {
14725                _next_ordinal_to_read += 1;
14726                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14727                next_offset += envelope_size;
14728            }
14729
14730            Ok(())
14731        }
14732    }
14733}