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 and `requested_presentation_time` in [`fuchsia.ui.composition/Flatland.Present`] is
415    /// set to 0 or less than or equal to the nearest presentation time, a frame will be scheduled
416    /// to be presented as soon as all acquire fences are signaled, instead of waiting for other
417    /// clients to present within the same vsync. This allows the caller to decide when to wake up
418    /// for preparing a frame.
419    ///
420    /// If `requested_presentation_time` is set to a value greater than the nearest presentation
421    /// time, this flag will have no effect and the wakeup time decision will be made by the
422    /// scheduler.
423    ///
424    /// If absent, `schedule_asap` is false.
425    pub schedule_asap: Option<bool>,
426    /// If true, Scenic should pass acquire fences to the drivers for composition HW, instead of
427    /// waiting for them on CPU. This can improve performance by reducing CPU overhead.
428    ///
429    /// If absent, `pass_acquire_fences` is false.
430    pub pass_acquire_fences: Option<bool>,
431    /// If true, the client will not utilize Flatland's built in frame-scheduling mechanism and
432    /// will ignore present credits, instead relying on their own flow control system.
433    ///
434    /// If absent, `skips_present_credits` is false.
435    pub skips_present_credits: Option<bool>,
436    #[doc(hidden)]
437    pub __source_breaking: fidl::marker::SourceBreaking,
438}
439
440impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for TrustedFlatlandConfig {}
441
442/// The protocol endpoints bound to a Flatland ViewCreationToken. These protocols operate on the
443/// View that ViewCreationToken created in the Flatland session.
444#[derive(Debug, Default, PartialEq)]
445pub struct ViewBoundProtocols {
446    /// Learn when a View gains focus.
447    ///
448    /// Server-bound ViewRef. The [`view_ref_focused`] client does not specify the ViewRef
449    /// explicitly; instead, the server implementation uses the ViewRef used in View creation for
450    /// reporting focus movement on/off this View.
451    pub view_ref_focused:
452        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>>,
453    /// Enable a View to request focus transfer to a child (target) View.
454    ///
455    /// Server-bound ViewRef. The [`view_focuser`] client does not specify the "requestor" ViewRef
456    /// explicitly, only the "target" ViewRef. Instead, the server implementation uses the ViewRef
457    /// used in View creation as the "requestor" ViewRef.
458    pub view_focuser: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>,
459    /// Receive touch events that are associated with a View.
460    pub touch_source:
461        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>>,
462    /// Receive mouse events that are associated with a View.
463    pub mouse_source:
464        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
465    #[doc(hidden)]
466    pub __source_breaking: fidl::marker::SourceBreaking,
467}
468
469impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewBoundProtocols {}
470
471#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
472pub struct AllocatorMarker;
473
474impl fidl::endpoints::ProtocolMarker for AllocatorMarker {
475    type Proxy = AllocatorProxy;
476    type RequestStream = AllocatorRequestStream;
477    #[cfg(target_os = "fuchsia")]
478    type SynchronousProxy = AllocatorSynchronousProxy;
479
480    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.Allocator";
481}
482impl fidl::endpoints::DiscoverableProtocolMarker for AllocatorMarker {}
483pub type AllocatorRegisterBufferCollectionResult = Result<(), RegisterBufferCollectionError>;
484
485pub trait AllocatorProxyInterface: Send + Sync {
486    type RegisterBufferCollectionResponseFut: std::future::Future<Output = Result<AllocatorRegisterBufferCollectionResult, fidl::Error>>
487        + Send;
488    fn r#register_buffer_collection(
489        &self,
490        args: RegisterBufferCollectionArgs,
491    ) -> Self::RegisterBufferCollectionResponseFut;
492}
493#[derive(Debug)]
494#[cfg(target_os = "fuchsia")]
495pub struct AllocatorSynchronousProxy {
496    client: fidl::client::sync::Client,
497}
498
499#[cfg(target_os = "fuchsia")]
500impl fidl::endpoints::SynchronousProxy for AllocatorSynchronousProxy {
501    type Proxy = AllocatorProxy;
502    type Protocol = AllocatorMarker;
503
504    fn from_channel(inner: fidl::Channel) -> Self {
505        Self::new(inner)
506    }
507
508    fn into_channel(self) -> fidl::Channel {
509        self.client.into_channel()
510    }
511
512    fn as_channel(&self) -> &fidl::Channel {
513        self.client.as_channel()
514    }
515}
516
517#[cfg(target_os = "fuchsia")]
518impl AllocatorSynchronousProxy {
519    pub fn new(channel: fidl::Channel) -> Self {
520        Self { client: fidl::client::sync::Client::new(channel) }
521    }
522
523    pub fn into_channel(self) -> fidl::Channel {
524        self.client.into_channel()
525    }
526
527    /// Waits until an event arrives and returns it. It is safe for other
528    /// threads to make concurrent requests while waiting for an event.
529    pub fn wait_for_event(
530        &self,
531        deadline: zx::MonotonicInstant,
532    ) -> Result<AllocatorEvent, fidl::Error> {
533        AllocatorEvent::decode(self.client.wait_for_event::<AllocatorMarker>(deadline)?)
534    }
535
536    /// A BufferCollection is a set of VMOs created by Sysmem and shared by a number of
537    /// participants, one of which is the Flatland Renderer. Some content, such as Images, use a
538    /// BufferCollection as their backing memory.
539    ///
540    /// See [`RegisterBufferCollectionArgs`] for information on each argument.
541    pub fn r#register_buffer_collection(
542        &self,
543        mut args: RegisterBufferCollectionArgs,
544        ___deadline: zx::MonotonicInstant,
545    ) -> Result<AllocatorRegisterBufferCollectionResult, fidl::Error> {
546        let _response = self
547            .client
548            .send_query::<AllocatorRegisterBufferCollectionRequest, fidl::encoding::ResultType<
549                fidl::encoding::EmptyStruct,
550                RegisterBufferCollectionError,
551            >, AllocatorMarker>(
552                (&mut args,),
553                0x494b7ea578d1061e,
554                fidl::encoding::DynamicFlags::empty(),
555                ___deadline,
556            )?;
557        Ok(_response.map(|x| x))
558    }
559}
560
561#[cfg(target_os = "fuchsia")]
562impl From<AllocatorSynchronousProxy> for zx::NullableHandle {
563    fn from(value: AllocatorSynchronousProxy) -> Self {
564        value.into_channel().into()
565    }
566}
567
568#[cfg(target_os = "fuchsia")]
569impl From<fidl::Channel> for AllocatorSynchronousProxy {
570    fn from(value: fidl::Channel) -> Self {
571        Self::new(value)
572    }
573}
574
575#[cfg(target_os = "fuchsia")]
576impl fidl::endpoints::FromClient for AllocatorSynchronousProxy {
577    type Protocol = AllocatorMarker;
578
579    fn from_client(value: fidl::endpoints::ClientEnd<AllocatorMarker>) -> Self {
580        Self::new(value.into_channel())
581    }
582}
583
584#[derive(Debug, Clone)]
585pub struct AllocatorProxy {
586    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
587}
588
589impl fidl::endpoints::Proxy for AllocatorProxy {
590    type Protocol = AllocatorMarker;
591
592    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
593        Self::new(inner)
594    }
595
596    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
597        self.client.into_channel().map_err(|client| Self { client })
598    }
599
600    fn as_channel(&self) -> &::fidl::AsyncChannel {
601        self.client.as_channel()
602    }
603}
604
605impl AllocatorProxy {
606    /// Create a new Proxy for fuchsia.ui.composition/Allocator.
607    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
608        let protocol_name = <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
609        Self { client: fidl::client::Client::new(channel, protocol_name) }
610    }
611
612    /// Get a Stream of events from the remote end of the protocol.
613    ///
614    /// # Panics
615    ///
616    /// Panics if the event stream was already taken.
617    pub fn take_event_stream(&self) -> AllocatorEventStream {
618        AllocatorEventStream { event_receiver: self.client.take_event_receiver() }
619    }
620
621    /// A BufferCollection is a set of VMOs created by Sysmem and shared by a number of
622    /// participants, one of which is the Flatland Renderer. Some content, such as Images, use a
623    /// BufferCollection as their backing memory.
624    ///
625    /// See [`RegisterBufferCollectionArgs`] for information on each argument.
626    pub fn r#register_buffer_collection(
627        &self,
628        mut args: RegisterBufferCollectionArgs,
629    ) -> fidl::client::QueryResponseFut<
630        AllocatorRegisterBufferCollectionResult,
631        fidl::encoding::DefaultFuchsiaResourceDialect,
632    > {
633        AllocatorProxyInterface::r#register_buffer_collection(self, args)
634    }
635}
636
637impl AllocatorProxyInterface for AllocatorProxy {
638    type RegisterBufferCollectionResponseFut = fidl::client::QueryResponseFut<
639        AllocatorRegisterBufferCollectionResult,
640        fidl::encoding::DefaultFuchsiaResourceDialect,
641    >;
642    fn r#register_buffer_collection(
643        &self,
644        mut args: RegisterBufferCollectionArgs,
645    ) -> Self::RegisterBufferCollectionResponseFut {
646        fn _decode(
647            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
648        ) -> Result<AllocatorRegisterBufferCollectionResult, fidl::Error> {
649            let _response = fidl::client::decode_transaction_body::<
650                fidl::encoding::ResultType<
651                    fidl::encoding::EmptyStruct,
652                    RegisterBufferCollectionError,
653                >,
654                fidl::encoding::DefaultFuchsiaResourceDialect,
655                0x494b7ea578d1061e,
656            >(_buf?)?;
657            Ok(_response.map(|x| x))
658        }
659        self.client.send_query_and_decode::<
660            AllocatorRegisterBufferCollectionRequest,
661            AllocatorRegisterBufferCollectionResult,
662        >(
663            (&mut args,),
664            0x494b7ea578d1061e,
665            fidl::encoding::DynamicFlags::empty(),
666            _decode,
667        )
668    }
669}
670
671pub struct AllocatorEventStream {
672    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
673}
674
675impl std::marker::Unpin for AllocatorEventStream {}
676
677impl futures::stream::FusedStream for AllocatorEventStream {
678    fn is_terminated(&self) -> bool {
679        self.event_receiver.is_terminated()
680    }
681}
682
683impl futures::Stream for AllocatorEventStream {
684    type Item = Result<AllocatorEvent, fidl::Error>;
685
686    fn poll_next(
687        mut self: std::pin::Pin<&mut Self>,
688        cx: &mut std::task::Context<'_>,
689    ) -> std::task::Poll<Option<Self::Item>> {
690        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
691            &mut self.event_receiver,
692            cx
693        )?) {
694            Some(buf) => std::task::Poll::Ready(Some(AllocatorEvent::decode(buf))),
695            None => std::task::Poll::Ready(None),
696        }
697    }
698}
699
700#[derive(Debug)]
701pub enum AllocatorEvent {}
702
703impl AllocatorEvent {
704    /// Decodes a message buffer as a [`AllocatorEvent`].
705    fn decode(
706        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
707    ) -> Result<AllocatorEvent, fidl::Error> {
708        let (bytes, _handles) = buf.split_mut();
709        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
710        debug_assert_eq!(tx_header.tx_id, 0);
711        match tx_header.ordinal {
712            _ => Err(fidl::Error::UnknownOrdinal {
713                ordinal: tx_header.ordinal,
714                protocol_name: <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
715            }),
716        }
717    }
718}
719
720/// A Stream of incoming requests for fuchsia.ui.composition/Allocator.
721pub struct AllocatorRequestStream {
722    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
723    is_terminated: bool,
724}
725
726impl std::marker::Unpin for AllocatorRequestStream {}
727
728impl futures::stream::FusedStream for AllocatorRequestStream {
729    fn is_terminated(&self) -> bool {
730        self.is_terminated
731    }
732}
733
734impl fidl::endpoints::RequestStream for AllocatorRequestStream {
735    type Protocol = AllocatorMarker;
736    type ControlHandle = AllocatorControlHandle;
737
738    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
739        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
740    }
741
742    fn control_handle(&self) -> Self::ControlHandle {
743        AllocatorControlHandle { inner: self.inner.clone() }
744    }
745
746    fn into_inner(
747        self,
748    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
749    {
750        (self.inner, self.is_terminated)
751    }
752
753    fn from_inner(
754        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
755        is_terminated: bool,
756    ) -> Self {
757        Self { inner, is_terminated }
758    }
759}
760
761impl futures::Stream for AllocatorRequestStream {
762    type Item = Result<AllocatorRequest, fidl::Error>;
763
764    fn poll_next(
765        mut self: std::pin::Pin<&mut Self>,
766        cx: &mut std::task::Context<'_>,
767    ) -> std::task::Poll<Option<Self::Item>> {
768        let this = &mut *self;
769        if this.inner.check_shutdown(cx) {
770            this.is_terminated = true;
771            return std::task::Poll::Ready(None);
772        }
773        if this.is_terminated {
774            panic!("polled AllocatorRequestStream after completion");
775        }
776        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
777            |bytes, handles| {
778                match this.inner.channel().read_etc(cx, bytes, handles) {
779                    std::task::Poll::Ready(Ok(())) => {}
780                    std::task::Poll::Pending => return std::task::Poll::Pending,
781                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
782                        this.is_terminated = true;
783                        return std::task::Poll::Ready(None);
784                    }
785                    std::task::Poll::Ready(Err(e)) => {
786                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
787                            e.into(),
788                        ))));
789                    }
790                }
791
792                // A message has been received from the channel
793                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
794
795                std::task::Poll::Ready(Some(match header.ordinal {
796                    0x494b7ea578d1061e => {
797                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
798                        let mut req = fidl::new_empty!(
799                            AllocatorRegisterBufferCollectionRequest,
800                            fidl::encoding::DefaultFuchsiaResourceDialect
801                        );
802                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorRegisterBufferCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
803                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
804                        Ok(AllocatorRequest::RegisterBufferCollection {
805                            args: req.args,
806
807                            responder: AllocatorRegisterBufferCollectionResponder {
808                                control_handle: std::mem::ManuallyDrop::new(control_handle),
809                                tx_id: header.tx_id,
810                            },
811                        })
812                    }
813                    _ => Err(fidl::Error::UnknownOrdinal {
814                        ordinal: header.ordinal,
815                        protocol_name:
816                            <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
817                    }),
818                }))
819            },
820        )
821    }
822}
823
824#[derive(Debug)]
825pub enum AllocatorRequest {
826    /// A BufferCollection is a set of VMOs created by Sysmem and shared by a number of
827    /// participants, one of which is the Flatland Renderer. Some content, such as Images, use a
828    /// BufferCollection as their backing memory.
829    ///
830    /// See [`RegisterBufferCollectionArgs`] for information on each argument.
831    RegisterBufferCollection {
832        args: RegisterBufferCollectionArgs,
833        responder: AllocatorRegisterBufferCollectionResponder,
834    },
835}
836
837impl AllocatorRequest {
838    #[allow(irrefutable_let_patterns)]
839    pub fn into_register_buffer_collection(
840        self,
841    ) -> Option<(RegisterBufferCollectionArgs, AllocatorRegisterBufferCollectionResponder)> {
842        if let AllocatorRequest::RegisterBufferCollection { args, responder } = self {
843            Some((args, responder))
844        } else {
845            None
846        }
847    }
848
849    /// Name of the method defined in FIDL
850    pub fn method_name(&self) -> &'static str {
851        match *self {
852            AllocatorRequest::RegisterBufferCollection { .. } => "register_buffer_collection",
853        }
854    }
855}
856
857#[derive(Debug, Clone)]
858pub struct AllocatorControlHandle {
859    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
860}
861
862impl fidl::endpoints::ControlHandle for AllocatorControlHandle {
863    fn shutdown(&self) {
864        self.inner.shutdown()
865    }
866
867    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
868        self.inner.shutdown_with_epitaph(status)
869    }
870
871    fn is_closed(&self) -> bool {
872        self.inner.channel().is_closed()
873    }
874    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
875        self.inner.channel().on_closed()
876    }
877
878    #[cfg(target_os = "fuchsia")]
879    fn signal_peer(
880        &self,
881        clear_mask: zx::Signals,
882        set_mask: zx::Signals,
883    ) -> Result<(), zx_status::Status> {
884        use fidl::Peered;
885        self.inner.channel().signal_peer(clear_mask, set_mask)
886    }
887}
888
889impl AllocatorControlHandle {}
890
891#[must_use = "FIDL methods require a response to be sent"]
892#[derive(Debug)]
893pub struct AllocatorRegisterBufferCollectionResponder {
894    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
895    tx_id: u32,
896}
897
898/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
899/// if the responder is dropped without sending a response, so that the client
900/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
901impl std::ops::Drop for AllocatorRegisterBufferCollectionResponder {
902    fn drop(&mut self) {
903        self.control_handle.shutdown();
904        // Safety: drops once, never accessed again
905        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
906    }
907}
908
909impl fidl::endpoints::Responder for AllocatorRegisterBufferCollectionResponder {
910    type ControlHandle = AllocatorControlHandle;
911
912    fn control_handle(&self) -> &AllocatorControlHandle {
913        &self.control_handle
914    }
915
916    fn drop_without_shutdown(mut self) {
917        // Safety: drops once, never accessed again due to mem::forget
918        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
919        // Prevent Drop from running (which would shut down the channel)
920        std::mem::forget(self);
921    }
922}
923
924impl AllocatorRegisterBufferCollectionResponder {
925    /// Sends a response to the FIDL transaction.
926    ///
927    /// Sets the channel to shutdown if an error occurs.
928    pub fn send(
929        self,
930        mut result: Result<(), RegisterBufferCollectionError>,
931    ) -> Result<(), fidl::Error> {
932        let _result = self.send_raw(result);
933        if _result.is_err() {
934            self.control_handle.shutdown();
935        }
936        self.drop_without_shutdown();
937        _result
938    }
939
940    /// Similar to "send" but does not shutdown the channel if an error occurs.
941    pub fn send_no_shutdown_on_err(
942        self,
943        mut result: Result<(), RegisterBufferCollectionError>,
944    ) -> Result<(), fidl::Error> {
945        let _result = self.send_raw(result);
946        self.drop_without_shutdown();
947        _result
948    }
949
950    fn send_raw(
951        &self,
952        mut result: Result<(), RegisterBufferCollectionError>,
953    ) -> Result<(), fidl::Error> {
954        self.control_handle.inner.send::<fidl::encoding::ResultType<
955            fidl::encoding::EmptyStruct,
956            RegisterBufferCollectionError,
957        >>(
958            result,
959            self.tx_id,
960            0x494b7ea578d1061e,
961            fidl::encoding::DynamicFlags::empty(),
962        )
963    }
964}
965
966#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
967pub struct ChildViewWatcherMarker;
968
969impl fidl::endpoints::ProtocolMarker for ChildViewWatcherMarker {
970    type Proxy = ChildViewWatcherProxy;
971    type RequestStream = ChildViewWatcherRequestStream;
972    #[cfg(target_os = "fuchsia")]
973    type SynchronousProxy = ChildViewWatcherSynchronousProxy;
974
975    const DEBUG_NAME: &'static str = "(anonymous) ChildViewWatcher";
976}
977
978pub trait ChildViewWatcherProxyInterface: Send + Sync {
979    type GetStatusResponseFut: std::future::Future<Output = Result<ChildViewStatus, fidl::Error>>
980        + Send;
981    fn r#get_status(&self) -> Self::GetStatusResponseFut;
982    type GetViewRefResponseFut: std::future::Future<Output = Result<fidl_fuchsia_ui_views::ViewRef, fidl::Error>>
983        + Send;
984    fn r#get_view_ref(&self) -> Self::GetViewRefResponseFut;
985}
986#[derive(Debug)]
987#[cfg(target_os = "fuchsia")]
988pub struct ChildViewWatcherSynchronousProxy {
989    client: fidl::client::sync::Client,
990}
991
992#[cfg(target_os = "fuchsia")]
993impl fidl::endpoints::SynchronousProxy for ChildViewWatcherSynchronousProxy {
994    type Proxy = ChildViewWatcherProxy;
995    type Protocol = ChildViewWatcherMarker;
996
997    fn from_channel(inner: fidl::Channel) -> Self {
998        Self::new(inner)
999    }
1000
1001    fn into_channel(self) -> fidl::Channel {
1002        self.client.into_channel()
1003    }
1004
1005    fn as_channel(&self) -> &fidl::Channel {
1006        self.client.as_channel()
1007    }
1008}
1009
1010#[cfg(target_os = "fuchsia")]
1011impl ChildViewWatcherSynchronousProxy {
1012    pub fn new(channel: fidl::Channel) -> Self {
1013        Self { client: fidl::client::sync::Client::new(channel) }
1014    }
1015
1016    pub fn into_channel(self) -> fidl::Channel {
1017        self.client.into_channel()
1018    }
1019
1020    /// Waits until an event arrives and returns it. It is safe for other
1021    /// threads to make concurrent requests while waiting for an event.
1022    pub fn wait_for_event(
1023        &self,
1024        deadline: zx::MonotonicInstant,
1025    ) -> Result<ChildViewWatcherEvent, fidl::Error> {
1026        ChildViewWatcherEvent::decode(
1027            self.client.wait_for_event::<ChildViewWatcherMarker>(deadline)?,
1028        )
1029    }
1030
1031    /// A hanging get for receiving the status of a View. This provides information to the parent,
1032    /// such as whether or not the child has successfully presented content through this View.
1033    ///
1034    /// This hanging get will only fire when the ChildViewStatus is different than the previously
1035    /// returned ChildViewStatus.  This can happen immediately, and even if the creator of the
1036    /// Viewport hasn't yet called Present() after calling CreateViewport().  This allows the parent
1037    /// to know that the child has content ready to display before the parent modifies their own
1038    /// local scene graph to incorporate the child content.
1039    ///
1040    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
1041    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1042    /// closed.
1043    pub fn r#get_status(
1044        &self,
1045        ___deadline: zx::MonotonicInstant,
1046    ) -> Result<ChildViewStatus, fidl::Error> {
1047        let _response = self.client.send_query::<
1048            fidl::encoding::EmptyPayload,
1049            ChildViewWatcherGetStatusResponse,
1050            ChildViewWatcherMarker,
1051        >(
1052            (),
1053            0x1d622075f4fc8243,
1054            fidl::encoding::DynamicFlags::empty(),
1055            ___deadline,
1056        )?;
1057        Ok(_response.status)
1058    }
1059
1060    /// Hanging get to receive the ViewRef of the child View. This will only fire when the View ref
1061    /// is different from the previously-returned View ref. Note: currently the View ref will not
1062    /// change after it is first received, but this will change if/when the API changes to allow
1063    /// relinking of views.
1064    ///
1065    /// The ViewRef is not returned until the View is included in the View tree, in other words when
1066    /// there is a chain of ancestor transforms all the way back up to the root of the scene graph,
1067    /// i.e. the display.
1068    ///
1069    /// It is invalid to call `GetViewRef` while a previous call is still pending. Doing so will
1070    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1071    /// closed.
1072    ///
1073    /// A `GetViewRef` call will hang if the View was created using `CreateView`, but returns the
1074    /// View if the View was created using CreateView2. This is because `CreateView` does not mint
1075    /// a ViewRef for that View.
1076    pub fn r#get_view_ref(
1077        &self,
1078        ___deadline: zx::MonotonicInstant,
1079    ) -> Result<fidl_fuchsia_ui_views::ViewRef, fidl::Error> {
1080        let _response = self.client.send_query::<
1081            fidl::encoding::EmptyPayload,
1082            ChildViewWatcherGetViewRefResponse,
1083            ChildViewWatcherMarker,
1084        >(
1085            (),
1086            0x3b2f3ca31e8908b4,
1087            fidl::encoding::DynamicFlags::empty(),
1088            ___deadline,
1089        )?;
1090        Ok(_response.view_ref)
1091    }
1092}
1093
1094#[cfg(target_os = "fuchsia")]
1095impl From<ChildViewWatcherSynchronousProxy> for zx::NullableHandle {
1096    fn from(value: ChildViewWatcherSynchronousProxy) -> Self {
1097        value.into_channel().into()
1098    }
1099}
1100
1101#[cfg(target_os = "fuchsia")]
1102impl From<fidl::Channel> for ChildViewWatcherSynchronousProxy {
1103    fn from(value: fidl::Channel) -> Self {
1104        Self::new(value)
1105    }
1106}
1107
1108#[cfg(target_os = "fuchsia")]
1109impl fidl::endpoints::FromClient for ChildViewWatcherSynchronousProxy {
1110    type Protocol = ChildViewWatcherMarker;
1111
1112    fn from_client(value: fidl::endpoints::ClientEnd<ChildViewWatcherMarker>) -> Self {
1113        Self::new(value.into_channel())
1114    }
1115}
1116
1117#[derive(Debug, Clone)]
1118pub struct ChildViewWatcherProxy {
1119    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1120}
1121
1122impl fidl::endpoints::Proxy for ChildViewWatcherProxy {
1123    type Protocol = ChildViewWatcherMarker;
1124
1125    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1126        Self::new(inner)
1127    }
1128
1129    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1130        self.client.into_channel().map_err(|client| Self { client })
1131    }
1132
1133    fn as_channel(&self) -> &::fidl::AsyncChannel {
1134        self.client.as_channel()
1135    }
1136}
1137
1138impl ChildViewWatcherProxy {
1139    /// Create a new Proxy for fuchsia.ui.composition/ChildViewWatcher.
1140    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1141        let protocol_name = <ChildViewWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1142        Self { client: fidl::client::Client::new(channel, protocol_name) }
1143    }
1144
1145    /// Get a Stream of events from the remote end of the protocol.
1146    ///
1147    /// # Panics
1148    ///
1149    /// Panics if the event stream was already taken.
1150    pub fn take_event_stream(&self) -> ChildViewWatcherEventStream {
1151        ChildViewWatcherEventStream { event_receiver: self.client.take_event_receiver() }
1152    }
1153
1154    /// A hanging get for receiving the status of a View. This provides information to the parent,
1155    /// such as whether or not the child has successfully presented content through this View.
1156    ///
1157    /// This hanging get will only fire when the ChildViewStatus is different than the previously
1158    /// returned ChildViewStatus.  This can happen immediately, and even if the creator of the
1159    /// Viewport hasn't yet called Present() after calling CreateViewport().  This allows the parent
1160    /// to know that the child has content ready to display before the parent modifies their own
1161    /// local scene graph to incorporate the child content.
1162    ///
1163    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
1164    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1165    /// closed.
1166    pub fn r#get_status(
1167        &self,
1168    ) -> fidl::client::QueryResponseFut<
1169        ChildViewStatus,
1170        fidl::encoding::DefaultFuchsiaResourceDialect,
1171    > {
1172        ChildViewWatcherProxyInterface::r#get_status(self)
1173    }
1174
1175    /// Hanging get to receive the ViewRef of the child View. This will only fire when the View ref
1176    /// is different from the previously-returned View ref. Note: currently the View ref will not
1177    /// change after it is first received, but this will change if/when the API changes to allow
1178    /// relinking of views.
1179    ///
1180    /// The ViewRef is not returned until the View is included in the View tree, in other words when
1181    /// there is a chain of ancestor transforms all the way back up to the root of the scene graph,
1182    /// i.e. the display.
1183    ///
1184    /// It is invalid to call `GetViewRef` while a previous call is still pending. Doing so will
1185    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1186    /// closed.
1187    ///
1188    /// A `GetViewRef` call will hang if the View was created using `CreateView`, but returns the
1189    /// View if the View was created using CreateView2. This is because `CreateView` does not mint
1190    /// a ViewRef for that View.
1191    pub fn r#get_view_ref(
1192        &self,
1193    ) -> fidl::client::QueryResponseFut<
1194        fidl_fuchsia_ui_views::ViewRef,
1195        fidl::encoding::DefaultFuchsiaResourceDialect,
1196    > {
1197        ChildViewWatcherProxyInterface::r#get_view_ref(self)
1198    }
1199}
1200
1201impl ChildViewWatcherProxyInterface for ChildViewWatcherProxy {
1202    type GetStatusResponseFut = fidl::client::QueryResponseFut<
1203        ChildViewStatus,
1204        fidl::encoding::DefaultFuchsiaResourceDialect,
1205    >;
1206    fn r#get_status(&self) -> Self::GetStatusResponseFut {
1207        fn _decode(
1208            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1209        ) -> Result<ChildViewStatus, fidl::Error> {
1210            let _response = fidl::client::decode_transaction_body::<
1211                ChildViewWatcherGetStatusResponse,
1212                fidl::encoding::DefaultFuchsiaResourceDialect,
1213                0x1d622075f4fc8243,
1214            >(_buf?)?;
1215            Ok(_response.status)
1216        }
1217        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ChildViewStatus>(
1218            (),
1219            0x1d622075f4fc8243,
1220            fidl::encoding::DynamicFlags::empty(),
1221            _decode,
1222        )
1223    }
1224
1225    type GetViewRefResponseFut = fidl::client::QueryResponseFut<
1226        fidl_fuchsia_ui_views::ViewRef,
1227        fidl::encoding::DefaultFuchsiaResourceDialect,
1228    >;
1229    fn r#get_view_ref(&self) -> Self::GetViewRefResponseFut {
1230        fn _decode(
1231            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1232        ) -> Result<fidl_fuchsia_ui_views::ViewRef, fidl::Error> {
1233            let _response = fidl::client::decode_transaction_body::<
1234                ChildViewWatcherGetViewRefResponse,
1235                fidl::encoding::DefaultFuchsiaResourceDialect,
1236                0x3b2f3ca31e8908b4,
1237            >(_buf?)?;
1238            Ok(_response.view_ref)
1239        }
1240        self.client
1241            .send_query_and_decode::<fidl::encoding::EmptyPayload, fidl_fuchsia_ui_views::ViewRef>(
1242                (),
1243                0x3b2f3ca31e8908b4,
1244                fidl::encoding::DynamicFlags::empty(),
1245                _decode,
1246            )
1247    }
1248}
1249
1250pub struct ChildViewWatcherEventStream {
1251    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1252}
1253
1254impl std::marker::Unpin for ChildViewWatcherEventStream {}
1255
1256impl futures::stream::FusedStream for ChildViewWatcherEventStream {
1257    fn is_terminated(&self) -> bool {
1258        self.event_receiver.is_terminated()
1259    }
1260}
1261
1262impl futures::Stream for ChildViewWatcherEventStream {
1263    type Item = Result<ChildViewWatcherEvent, fidl::Error>;
1264
1265    fn poll_next(
1266        mut self: std::pin::Pin<&mut Self>,
1267        cx: &mut std::task::Context<'_>,
1268    ) -> std::task::Poll<Option<Self::Item>> {
1269        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1270            &mut self.event_receiver,
1271            cx
1272        )?) {
1273            Some(buf) => std::task::Poll::Ready(Some(ChildViewWatcherEvent::decode(buf))),
1274            None => std::task::Poll::Ready(None),
1275        }
1276    }
1277}
1278
1279#[derive(Debug)]
1280pub enum ChildViewWatcherEvent {}
1281
1282impl ChildViewWatcherEvent {
1283    /// Decodes a message buffer as a [`ChildViewWatcherEvent`].
1284    fn decode(
1285        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1286    ) -> Result<ChildViewWatcherEvent, fidl::Error> {
1287        let (bytes, _handles) = buf.split_mut();
1288        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1289        debug_assert_eq!(tx_header.tx_id, 0);
1290        match tx_header.ordinal {
1291            _ => Err(fidl::Error::UnknownOrdinal {
1292                ordinal: tx_header.ordinal,
1293                protocol_name:
1294                    <ChildViewWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1295            }),
1296        }
1297    }
1298}
1299
1300/// A Stream of incoming requests for fuchsia.ui.composition/ChildViewWatcher.
1301pub struct ChildViewWatcherRequestStream {
1302    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1303    is_terminated: bool,
1304}
1305
1306impl std::marker::Unpin for ChildViewWatcherRequestStream {}
1307
1308impl futures::stream::FusedStream for ChildViewWatcherRequestStream {
1309    fn is_terminated(&self) -> bool {
1310        self.is_terminated
1311    }
1312}
1313
1314impl fidl::endpoints::RequestStream for ChildViewWatcherRequestStream {
1315    type Protocol = ChildViewWatcherMarker;
1316    type ControlHandle = ChildViewWatcherControlHandle;
1317
1318    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1319        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1320    }
1321
1322    fn control_handle(&self) -> Self::ControlHandle {
1323        ChildViewWatcherControlHandle { inner: self.inner.clone() }
1324    }
1325
1326    fn into_inner(
1327        self,
1328    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1329    {
1330        (self.inner, self.is_terminated)
1331    }
1332
1333    fn from_inner(
1334        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1335        is_terminated: bool,
1336    ) -> Self {
1337        Self { inner, is_terminated }
1338    }
1339}
1340
1341impl futures::Stream for ChildViewWatcherRequestStream {
1342    type Item = Result<ChildViewWatcherRequest, fidl::Error>;
1343
1344    fn poll_next(
1345        mut self: std::pin::Pin<&mut Self>,
1346        cx: &mut std::task::Context<'_>,
1347    ) -> std::task::Poll<Option<Self::Item>> {
1348        let this = &mut *self;
1349        if this.inner.check_shutdown(cx) {
1350            this.is_terminated = true;
1351            return std::task::Poll::Ready(None);
1352        }
1353        if this.is_terminated {
1354            panic!("polled ChildViewWatcherRequestStream after completion");
1355        }
1356        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1357            |bytes, handles| {
1358                match this.inner.channel().read_etc(cx, bytes, handles) {
1359                    std::task::Poll::Ready(Ok(())) => {}
1360                    std::task::Poll::Pending => return std::task::Poll::Pending,
1361                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1362                        this.is_terminated = true;
1363                        return std::task::Poll::Ready(None);
1364                    }
1365                    std::task::Poll::Ready(Err(e)) => {
1366                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1367                            e.into(),
1368                        ))));
1369                    }
1370                }
1371
1372                // A message has been received from the channel
1373                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1374
1375                std::task::Poll::Ready(Some(match header.ordinal {
1376                    0x1d622075f4fc8243 => {
1377                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1378                        let mut req = fidl::new_empty!(
1379                            fidl::encoding::EmptyPayload,
1380                            fidl::encoding::DefaultFuchsiaResourceDialect
1381                        );
1382                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1383                        let control_handle =
1384                            ChildViewWatcherControlHandle { inner: this.inner.clone() };
1385                        Ok(ChildViewWatcherRequest::GetStatus {
1386                            responder: ChildViewWatcherGetStatusResponder {
1387                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1388                                tx_id: header.tx_id,
1389                            },
1390                        })
1391                    }
1392                    0x3b2f3ca31e8908b4 => {
1393                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1394                        let mut req = fidl::new_empty!(
1395                            fidl::encoding::EmptyPayload,
1396                            fidl::encoding::DefaultFuchsiaResourceDialect
1397                        );
1398                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1399                        let control_handle =
1400                            ChildViewWatcherControlHandle { inner: this.inner.clone() };
1401                        Ok(ChildViewWatcherRequest::GetViewRef {
1402                            responder: ChildViewWatcherGetViewRefResponder {
1403                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1404                                tx_id: header.tx_id,
1405                            },
1406                        })
1407                    }
1408                    _ => Err(fidl::Error::UnknownOrdinal {
1409                        ordinal: header.ordinal,
1410                        protocol_name:
1411                            <ChildViewWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1412                    }),
1413                }))
1414            },
1415        )
1416    }
1417}
1418
1419/// A protocol that provides information about a particular child View which is attached to the
1420/// Viewport owned by the parent client; connections to this protocol are estabished in
1421/// [`CreateViewport`].  Since a Flatland instance may contain any number of Viewports, each of
1422/// which may or may not be attached to a transform, the client can maintain connections to an
1423/// equal number of ChildViewWatcher instances.
1424///
1425/// Each ChildViewWatcher instance will remain connected as long as the corresponding child View
1426/// exists; the connection will also be closed if the child's ViewCreationToken is dropped without
1427/// using it to create a View.
1428#[derive(Debug)]
1429pub enum ChildViewWatcherRequest {
1430    /// A hanging get for receiving the status of a View. This provides information to the parent,
1431    /// such as whether or not the child has successfully presented content through this View.
1432    ///
1433    /// This hanging get will only fire when the ChildViewStatus is different than the previously
1434    /// returned ChildViewStatus.  This can happen immediately, and even if the creator of the
1435    /// Viewport hasn't yet called Present() after calling CreateViewport().  This allows the parent
1436    /// to know that the child has content ready to display before the parent modifies their own
1437    /// local scene graph to incorporate the child content.
1438    ///
1439    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
1440    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1441    /// closed.
1442    GetStatus { responder: ChildViewWatcherGetStatusResponder },
1443    /// Hanging get to receive the ViewRef of the child View. This will only fire when the View ref
1444    /// is different from the previously-returned View ref. Note: currently the View ref will not
1445    /// change after it is first received, but this will change if/when the API changes to allow
1446    /// relinking of views.
1447    ///
1448    /// The ViewRef is not returned until the View is included in the View tree, in other words when
1449    /// there is a chain of ancestor transforms all the way back up to the root of the scene graph,
1450    /// i.e. the display.
1451    ///
1452    /// It is invalid to call `GetViewRef` while a previous call is still pending. Doing so will
1453    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1454    /// closed.
1455    ///
1456    /// A `GetViewRef` call will hang if the View was created using `CreateView`, but returns the
1457    /// View if the View was created using CreateView2. This is because `CreateView` does not mint
1458    /// a ViewRef for that View.
1459    GetViewRef { responder: ChildViewWatcherGetViewRefResponder },
1460}
1461
1462impl ChildViewWatcherRequest {
1463    #[allow(irrefutable_let_patterns)]
1464    pub fn into_get_status(self) -> Option<(ChildViewWatcherGetStatusResponder)> {
1465        if let ChildViewWatcherRequest::GetStatus { responder } = self {
1466            Some((responder))
1467        } else {
1468            None
1469        }
1470    }
1471
1472    #[allow(irrefutable_let_patterns)]
1473    pub fn into_get_view_ref(self) -> Option<(ChildViewWatcherGetViewRefResponder)> {
1474        if let ChildViewWatcherRequest::GetViewRef { responder } = self {
1475            Some((responder))
1476        } else {
1477            None
1478        }
1479    }
1480
1481    /// Name of the method defined in FIDL
1482    pub fn method_name(&self) -> &'static str {
1483        match *self {
1484            ChildViewWatcherRequest::GetStatus { .. } => "get_status",
1485            ChildViewWatcherRequest::GetViewRef { .. } => "get_view_ref",
1486        }
1487    }
1488}
1489
1490#[derive(Debug, Clone)]
1491pub struct ChildViewWatcherControlHandle {
1492    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1493}
1494
1495impl fidl::endpoints::ControlHandle for ChildViewWatcherControlHandle {
1496    fn shutdown(&self) {
1497        self.inner.shutdown()
1498    }
1499
1500    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1501        self.inner.shutdown_with_epitaph(status)
1502    }
1503
1504    fn is_closed(&self) -> bool {
1505        self.inner.channel().is_closed()
1506    }
1507    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1508        self.inner.channel().on_closed()
1509    }
1510
1511    #[cfg(target_os = "fuchsia")]
1512    fn signal_peer(
1513        &self,
1514        clear_mask: zx::Signals,
1515        set_mask: zx::Signals,
1516    ) -> Result<(), zx_status::Status> {
1517        use fidl::Peered;
1518        self.inner.channel().signal_peer(clear_mask, set_mask)
1519    }
1520}
1521
1522impl ChildViewWatcherControlHandle {}
1523
1524#[must_use = "FIDL methods require a response to be sent"]
1525#[derive(Debug)]
1526pub struct ChildViewWatcherGetStatusResponder {
1527    control_handle: std::mem::ManuallyDrop<ChildViewWatcherControlHandle>,
1528    tx_id: u32,
1529}
1530
1531/// Set the the channel to be shutdown (see [`ChildViewWatcherControlHandle::shutdown`])
1532/// if the responder is dropped without sending a response, so that the client
1533/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1534impl std::ops::Drop for ChildViewWatcherGetStatusResponder {
1535    fn drop(&mut self) {
1536        self.control_handle.shutdown();
1537        // Safety: drops once, never accessed again
1538        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1539    }
1540}
1541
1542impl fidl::endpoints::Responder for ChildViewWatcherGetStatusResponder {
1543    type ControlHandle = ChildViewWatcherControlHandle;
1544
1545    fn control_handle(&self) -> &ChildViewWatcherControlHandle {
1546        &self.control_handle
1547    }
1548
1549    fn drop_without_shutdown(mut self) {
1550        // Safety: drops once, never accessed again due to mem::forget
1551        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1552        // Prevent Drop from running (which would shut down the channel)
1553        std::mem::forget(self);
1554    }
1555}
1556
1557impl ChildViewWatcherGetStatusResponder {
1558    /// Sends a response to the FIDL transaction.
1559    ///
1560    /// Sets the channel to shutdown if an error occurs.
1561    pub fn send(self, mut status: ChildViewStatus) -> Result<(), fidl::Error> {
1562        let _result = self.send_raw(status);
1563        if _result.is_err() {
1564            self.control_handle.shutdown();
1565        }
1566        self.drop_without_shutdown();
1567        _result
1568    }
1569
1570    /// Similar to "send" but does not shutdown the channel if an error occurs.
1571    pub fn send_no_shutdown_on_err(self, mut status: ChildViewStatus) -> Result<(), fidl::Error> {
1572        let _result = self.send_raw(status);
1573        self.drop_without_shutdown();
1574        _result
1575    }
1576
1577    fn send_raw(&self, mut status: ChildViewStatus) -> Result<(), fidl::Error> {
1578        self.control_handle.inner.send::<ChildViewWatcherGetStatusResponse>(
1579            (status,),
1580            self.tx_id,
1581            0x1d622075f4fc8243,
1582            fidl::encoding::DynamicFlags::empty(),
1583        )
1584    }
1585}
1586
1587#[must_use = "FIDL methods require a response to be sent"]
1588#[derive(Debug)]
1589pub struct ChildViewWatcherGetViewRefResponder {
1590    control_handle: std::mem::ManuallyDrop<ChildViewWatcherControlHandle>,
1591    tx_id: u32,
1592}
1593
1594/// Set the the channel to be shutdown (see [`ChildViewWatcherControlHandle::shutdown`])
1595/// if the responder is dropped without sending a response, so that the client
1596/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1597impl std::ops::Drop for ChildViewWatcherGetViewRefResponder {
1598    fn drop(&mut self) {
1599        self.control_handle.shutdown();
1600        // Safety: drops once, never accessed again
1601        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1602    }
1603}
1604
1605impl fidl::endpoints::Responder for ChildViewWatcherGetViewRefResponder {
1606    type ControlHandle = ChildViewWatcherControlHandle;
1607
1608    fn control_handle(&self) -> &ChildViewWatcherControlHandle {
1609        &self.control_handle
1610    }
1611
1612    fn drop_without_shutdown(mut self) {
1613        // Safety: drops once, never accessed again due to mem::forget
1614        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1615        // Prevent Drop from running (which would shut down the channel)
1616        std::mem::forget(self);
1617    }
1618}
1619
1620impl ChildViewWatcherGetViewRefResponder {
1621    /// Sends a response to the FIDL transaction.
1622    ///
1623    /// Sets the channel to shutdown if an error occurs.
1624    pub fn send(self, mut view_ref: fidl_fuchsia_ui_views::ViewRef) -> Result<(), fidl::Error> {
1625        let _result = self.send_raw(view_ref);
1626        if _result.is_err() {
1627            self.control_handle.shutdown();
1628        }
1629        self.drop_without_shutdown();
1630        _result
1631    }
1632
1633    /// Similar to "send" but does not shutdown the channel if an error occurs.
1634    pub fn send_no_shutdown_on_err(
1635        self,
1636        mut view_ref: fidl_fuchsia_ui_views::ViewRef,
1637    ) -> Result<(), fidl::Error> {
1638        let _result = self.send_raw(view_ref);
1639        self.drop_without_shutdown();
1640        _result
1641    }
1642
1643    fn send_raw(&self, mut view_ref: fidl_fuchsia_ui_views::ViewRef) -> Result<(), fidl::Error> {
1644        self.control_handle.inner.send::<ChildViewWatcherGetViewRefResponse>(
1645            (&mut view_ref,),
1646            self.tx_id,
1647            0x3b2f3ca31e8908b4,
1648            fidl::encoding::DynamicFlags::empty(),
1649        )
1650    }
1651}
1652
1653#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1654pub struct FlatlandMarker;
1655
1656impl fidl::endpoints::ProtocolMarker for FlatlandMarker {
1657    type Proxy = FlatlandProxy;
1658    type RequestStream = FlatlandRequestStream;
1659    #[cfg(target_os = "fuchsia")]
1660    type SynchronousProxy = FlatlandSynchronousProxy;
1661
1662    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.Flatland";
1663}
1664impl fidl::endpoints::DiscoverableProtocolMarker for FlatlandMarker {}
1665
1666pub trait FlatlandProxyInterface: Send + Sync {
1667    fn r#release_image_immediately(&self, image_id: &ContentId) -> Result<(), fidl::Error>;
1668    fn r#present(&self, args: PresentArgs) -> Result<(), fidl::Error>;
1669    fn r#create_view(
1670        &self,
1671        token: fidl_fuchsia_ui_views::ViewCreationToken,
1672        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1673    ) -> Result<(), fidl::Error>;
1674    fn r#create_view2(
1675        &self,
1676        token: fidl_fuchsia_ui_views::ViewCreationToken,
1677        view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
1678        protocols: ViewBoundProtocols,
1679        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1680    ) -> Result<(), fidl::Error>;
1681    fn r#create_transform(&self, transform_id: &TransformId) -> Result<(), fidl::Error>;
1682    fn r#set_translation(
1683        &self,
1684        transform_id: &TransformId,
1685        translation: &fidl_fuchsia_math::Vec_,
1686    ) -> Result<(), fidl::Error>;
1687    fn r#set_orientation(
1688        &self,
1689        transform_id: &TransformId,
1690        orientation: Orientation,
1691    ) -> Result<(), fidl::Error>;
1692    fn r#set_scale(
1693        &self,
1694        transform_id: &TransformId,
1695        scale: &fidl_fuchsia_math::VecF,
1696    ) -> Result<(), fidl::Error>;
1697    fn r#set_opacity(&self, transform_id: &TransformId, value: f32) -> Result<(), fidl::Error>;
1698    fn r#set_clip_boundary(
1699        &self,
1700        transform_id: &TransformId,
1701        rect: Option<&fidl_fuchsia_math::Rect>,
1702    ) -> Result<(), fidl::Error>;
1703    fn r#add_child(
1704        &self,
1705        parent_transform_id: &TransformId,
1706        child_transform_id: &TransformId,
1707    ) -> Result<(), fidl::Error>;
1708    fn r#remove_child(
1709        &self,
1710        parent_transform_id: &TransformId,
1711        child_transform_id: &TransformId,
1712    ) -> Result<(), fidl::Error>;
1713    fn r#replace_children(
1714        &self,
1715        parent_transform_id: &TransformId,
1716        new_child_transform_ids: &[TransformId],
1717    ) -> Result<(), fidl::Error>;
1718    fn r#set_root_transform(&self, transform_id: &TransformId) -> Result<(), fidl::Error>;
1719    fn r#set_hit_regions(
1720        &self,
1721        transform_id: &TransformId,
1722        regions: &[HitRegion],
1723    ) -> Result<(), fidl::Error>;
1724    fn r#set_infinite_hit_region(
1725        &self,
1726        transform_id: &TransformId,
1727        hit_test: HitTestInteraction,
1728    ) -> Result<(), fidl::Error>;
1729    fn r#create_viewport(
1730        &self,
1731        viewport_id: &ContentId,
1732        token: fidl_fuchsia_ui_views::ViewportCreationToken,
1733        properties: &ViewportProperties,
1734        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
1735    ) -> Result<(), fidl::Error>;
1736    fn r#create_image(
1737        &self,
1738        image_id: &ContentId,
1739        import_token: BufferCollectionImportToken,
1740        vmo_index: u32,
1741        properties: &ImageProperties,
1742    ) -> Result<(), fidl::Error>;
1743    fn r#set_image_sample_region(
1744        &self,
1745        image_id: &ContentId,
1746        rect: &fidl_fuchsia_math::RectF,
1747    ) -> Result<(), fidl::Error>;
1748    fn r#set_image_destination_size(
1749        &self,
1750        image_id: &ContentId,
1751        size: &fidl_fuchsia_math::SizeU,
1752    ) -> Result<(), fidl::Error>;
1753    fn r#set_image_blending_function(
1754        &self,
1755        image_id: &ContentId,
1756        blend_mode: BlendMode,
1757    ) -> Result<(), fidl::Error>;
1758    fn r#set_image_blend_mode(
1759        &self,
1760        image_id: &ContentId,
1761        blend_mode: BlendMode2,
1762    ) -> Result<(), fidl::Error>;
1763    fn r#set_image_opacity(&self, image_id: &ContentId, val: f32) -> Result<(), fidl::Error>;
1764    fn r#set_image_flip(&self, image_id: &ContentId, flip: ImageFlip) -> Result<(), fidl::Error>;
1765    fn r#create_filled_rect(&self, rect_id: &ContentId) -> Result<(), fidl::Error>;
1766    fn r#set_solid_fill(
1767        &self,
1768        rect_id: &ContentId,
1769        color: &ColorRgba,
1770        size: &fidl_fuchsia_math::SizeU,
1771    ) -> Result<(), fidl::Error>;
1772    fn r#release_filled_rect(&self, rect_id: &ContentId) -> Result<(), fidl::Error>;
1773    fn r#set_content(
1774        &self,
1775        transform_id: &TransformId,
1776        content_id: &ContentId,
1777    ) -> Result<(), fidl::Error>;
1778    fn r#set_viewport_properties(
1779        &self,
1780        viewport_id: &ContentId,
1781        properties: &ViewportProperties,
1782    ) -> Result<(), fidl::Error>;
1783    fn r#release_transform(&self, transform_id: &TransformId) -> Result<(), fidl::Error>;
1784    fn r#release_view(&self) -> Result<(), fidl::Error>;
1785    type ReleaseViewportResponseFut: std::future::Future<
1786            Output = Result<fidl_fuchsia_ui_views::ViewportCreationToken, fidl::Error>,
1787        > + Send;
1788    fn r#release_viewport(&self, viewport_id: &ContentId) -> Self::ReleaseViewportResponseFut;
1789    fn r#release_image(&self, image_id: &ContentId) -> Result<(), fidl::Error>;
1790    fn r#clear(&self) -> Result<(), fidl::Error>;
1791    fn r#set_debug_name(&self, name: &str) -> Result<(), fidl::Error>;
1792}
1793#[derive(Debug)]
1794#[cfg(target_os = "fuchsia")]
1795pub struct FlatlandSynchronousProxy {
1796    client: fidl::client::sync::Client,
1797}
1798
1799#[cfg(target_os = "fuchsia")]
1800impl fidl::endpoints::SynchronousProxy for FlatlandSynchronousProxy {
1801    type Proxy = FlatlandProxy;
1802    type Protocol = FlatlandMarker;
1803
1804    fn from_channel(inner: fidl::Channel) -> Self {
1805        Self::new(inner)
1806    }
1807
1808    fn into_channel(self) -> fidl::Channel {
1809        self.client.into_channel()
1810    }
1811
1812    fn as_channel(&self) -> &fidl::Channel {
1813        self.client.as_channel()
1814    }
1815}
1816
1817#[cfg(target_os = "fuchsia")]
1818impl FlatlandSynchronousProxy {
1819    pub fn new(channel: fidl::Channel) -> Self {
1820        Self { client: fidl::client::sync::Client::new(channel) }
1821    }
1822
1823    pub fn into_channel(self) -> fidl::Channel {
1824        self.client.into_channel()
1825    }
1826
1827    /// Waits until an event arrives and returns it. It is safe for other
1828    /// threads to make concurrent requests while waiting for an event.
1829    pub fn wait_for_event(
1830        &self,
1831        deadline: zx::MonotonicInstant,
1832    ) -> Result<FlatlandEvent, fidl::Error> {
1833        FlatlandEvent::decode(self.client.wait_for_event::<FlatlandMarker>(deadline)?)
1834    }
1835
1836    /// Releases an image immediately, without waiting for the next present.
1837    pub fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
1838        self.client.send::<TrustedFlatlandReleaseImageImmediatelyRequest>(
1839            (image_id,),
1840            0x245e1ac080772c8,
1841            fidl::encoding::DynamicFlags::empty(),
1842        )
1843    }
1844
1845    /// Complete execution of all feed-forward operations.
1846    ///
1847    /// If executing an operation produces an error (e.g., CreateTransform(0)), an [`OnError`] event
1848    /// is emitted. Operations that produce errors are ignored and the channel is closed.
1849    ///
1850    /// If the execution is completed successfully, [`OnNextFrameBegin`] emits NO_ERROR along
1851    /// with other valid fields.
1852    ///
1853    /// The client may only call [`Present`] when they have a non-zero number of present credits,
1854    /// which are tracked by the server. The server may increment the number of credits when it
1855    /// fires the [`OnNextFrameBegin`] event, which informs the client when it receives additional
1856    /// present credits. Each [`Present`] call uses one present credit and decrements the server
1857    /// count by one. If the client calls [`Present`] with no present credits, the server will
1858    /// return a `NO_PRESENTS_REMAINING` error.
1859    ///
1860    /// The client should assume that prior to receiving any [`OnNextFrameBegin`] events, they have
1861    /// one present credit.
1862    ///
1863    /// Every [`Present`] call results in one [`OnNextFrameBegin`] event, and one
1864    /// [`OnFramePresented`] event, typically in that order.
1865    ///
1866    /// When the commands flushed by [`Present`] make it to display, an [`OnFramePresented`] event
1867    /// is fired. This event includes information pertaining to all [`Present`]s that had content
1868    /// that were part of that frame.
1869    ///
1870    /// See [`fuchsia.ui.composition/PresentArgs`] documentation above for more detailed information
1871    /// on what arguments are passed in and their role.
1872    pub fn r#present(&self, mut args: PresentArgs) -> Result<(), fidl::Error> {
1873        self.client.send::<FlatlandPresentRequest>(
1874            (&mut args,),
1875            0x50acc2aa1f0acec7,
1876            fidl::encoding::DynamicFlags::empty(),
1877        )
1878    }
1879
1880    /// Two Flatland instances may be connected in a parent-child relationship. The parent endpoint
1881    /// is held in a Viewport, and the child endpoint is held in a View. The parent Flatland
1882    /// instance that creates a Viewport has control over how the child's View is integrated into
1883    /// its own View.
1884    ///
1885    /// The lifecycle of a parent-child connection starts with two endpoints of a channel object:
1886    /// a ViewportCreationToken and a ViewCreationToken. Out-of-band protocols pass the
1887    /// ViewportCreationToken to the parent, which calls [`CreateViewport`], and the
1888    /// ViewCreationToken to the child, which calls [`CreateView`].
1889    ///
1890    /// Only nodes connected to the Root Transform in this Flatland instance will be rendered into
1891    /// the parent's Viewport.
1892    ///
1893    /// Calling [`CreateView`] a second time will disconnect the Root Transform from the existing
1894    /// parent's Viewport, and attach it to a new parent's Viewport. In other words, each View can
1895    /// only have one parent.
1896    ///
1897    /// This function is queued, meaning that the Root Transform will not be attached to the
1898    /// parent Viewport until [`Present`] is called. However, clients will receive information
1899    /// through their ParentViewportWatcher (e.g., LayoutInfo) immediately after calling this
1900    /// function, even if they have not called [`Present`] or [`SetRootTransform`]. This allows
1901    /// clients to wait for layout information from their parent before calling [`Present`].
1902    ///
1903    /// Any illegal operations on ParentViewportWatcher will cause both ParentViewportWatcher
1904    /// channel and this Flatland channel to be torn down.
1905    ///
1906    /// Lifecycle note. The lifetime of the ParentViewportWatcher channel is bound by the peer
1907    /// ViewportCreationToken. When the ViewportCreationToken dies, this ParentViewportWatcher
1908    /// channel is destroyed.
1909    ///
1910    /// Views and subgraphs of Views created using `CreateView` will not be represented in the
1911    /// ViewTree, and hence will not be able to participate in any ViewTree-dependent interactions
1912    /// such as touch, mouse or focus.
1913    /// The Flatland protocol provides no way for Views in the subgraph of a View created with
1914    /// `CreateView` to know that they are excluded from the ViewTree.
1915    pub fn r#create_view(
1916        &self,
1917        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
1918        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1919    ) -> Result<(), fidl::Error> {
1920        self.client.send::<FlatlandCreateViewRequest>(
1921            (&mut token, parent_viewport_watcher),
1922            0x504686eb25864780,
1923            fidl::encoding::DynamicFlags::empty(),
1924        )
1925    }
1926
1927    /// Identical to [`CreateView`], except it allows association of View identity (ViewRef) and
1928    /// view-bound protocols.
1929    pub fn r#create_view2(
1930        &self,
1931        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
1932        mut view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
1933        mut protocols: ViewBoundProtocols,
1934        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1935    ) -> Result<(), fidl::Error> {
1936        self.client.send::<FlatlandCreateView2Request>(
1937            (&mut token, &mut view_identity, &mut protocols, parent_viewport_watcher),
1938            0x340a3a40c2fdbd5e,
1939            fidl::encoding::DynamicFlags::empty(),
1940        )
1941    }
1942
1943    /// Creates a new Transform node. Transforms are a hierarchical piece of a Flatland graph. They
1944    /// can have children, and can reference Content. A sub-graph represented by a Transform and its
1945    /// descendants can be rendered to a display.
1946    ///
1947    /// Transforms are kept alive, even when released, as long as they are children of either an
1948    /// unreleased Transform, or the Root Transform.
1949    ///
1950    /// Each Transform can have a single piece of attached Content. Common types of Content include
1951    /// bitmaps, asynchronous streams of images, and Viewports to Views hosted in other Flatland
1952    /// instances.
1953    ///
1954    /// Transforms have attributes. Child Transforms inherit the combined attributes of their
1955    /// parents. Content attached to a Transform is also affected by that Transform's attributes.
1956    ///
1957    /// When a sub-graph of Transforms is rendered, Content will be rendered back-to-front, starting
1958    /// with the Content on the root transform, and continuing recursively through all of its child
1959    /// Transforms in the order the children were added. See [`AddChild`] for more information.
1960    ///
1961    /// Zero is not a valid transform id. All other values are valid, assuming they are not already
1962    /// in use (see [`ReleaseTransform`] for more details).
1963    pub fn r#create_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
1964        self.client.send::<FlatlandCreateTransformRequest>(
1965            (transform_id,),
1966            0x5e042a4d3de3efb0,
1967            fidl::encoding::DynamicFlags::empty(),
1968        )
1969    }
1970
1971    /// All Transform objects support all attributes.
1972    ///
1973    /// Geometric attributes are applied in the following order:
1974    /// 1. Scale (relative to the parent transform's coordinate space)
1975    /// 2. Orientation (relative to the parent transform's coordinate space)
1976    /// 3. Translation (relative to the parent transforms's coordinate space,
1977    ///    unaffected by scale applied to the current transform).
1978    /// 4. Clipping (relative to the current transform's coordinate space)
1979    ///
1980    /// The effects of each of these attributes are cumulative. This means the transform's position
1981    /// in the view space, and its clip boundary, will be calculated based on that chain of
1982    /// geometric attributes going up to the root transform.
1983    ///
1984    /// For instance, in a nested hierarchy such as the following:
1985    ///     [Root-Transform -> Transform1 -> Transform2 -> CurrentTransform]
1986    /// If Transform1 is translated by [2,0] and Transform2 is translated by [0,1] then the
1987    /// view-space position of CurrentTransform will be [2,1].
1988    ///
1989    /// Sets the translation on a Transform. The order of geometric attribute application is
1990    /// addressed above.
1991    pub fn r#set_translation(
1992        &self,
1993        mut transform_id: &TransformId,
1994        mut translation: &fidl_fuchsia_math::Vec_,
1995    ) -> Result<(), fidl::Error> {
1996        self.client.send::<FlatlandSetTranslationRequest>(
1997            (transform_id, translation),
1998            0x7863398291fba346,
1999            fidl::encoding::DynamicFlags::empty(),
2000        )
2001    }
2002
2003    /// Sets the orientation on a Transform. The order of geometric attribute application is
2004    /// addressed in the documentation for [`SetTranslation`]. In Flatland, the +X axis is
2005    /// to the right and the +Y axis is down. There is no notion of a Z axis. CCW is defined
2006    /// from the POV of the user, as if a skeuomorphoic clock is displayed on the screen.
2007    pub fn r#set_orientation(
2008        &self,
2009        mut transform_id: &TransformId,
2010        mut orientation: Orientation,
2011    ) -> Result<(), fidl::Error> {
2012        self.client.send::<FlatlandSetOrientationRequest>(
2013            (transform_id, orientation),
2014            0x4915310bc4928edc,
2015            fidl::encoding::DynamicFlags::empty(),
2016        )
2017    }
2018
2019    /// Sets the scale on a transform. The order of geometric attribute application is
2020    /// addressed above. The (x,y) values in the VecF |scale| refer to the scale factor in the
2021    /// x-axis (width) and y-axis (height) respectively. Scale values must be normal 32-bit
2022    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29
2023    pub fn r#set_scale(
2024        &self,
2025        mut transform_id: &TransformId,
2026        mut scale: &fidl_fuchsia_math::VecF,
2027    ) -> Result<(), fidl::Error> {
2028        self.client.send::<FlatlandSetScaleRequest>(
2029            (transform_id, scale),
2030            0x1ea1766fd8996bb4,
2031            fidl::encoding::DynamicFlags::empty(),
2032        )
2033    }
2034
2035    /// Sets an opacity in linear space to be applied to a transform and its descendents,
2036    /// which include other transforms and content. Opacity values must be in the range
2037    /// of [0.0, 1.0], where 0.0 is completely transparent and 1.0 is completely opaque.
2038    /// Attempting to call this function with values outside that range will result in
2039    /// an error. A transform's opacity value is multiplied with that of its parent. This
2040    /// effect works differently from group opacity. Using group opacity, child nodes are
2041    /// rendered together first, and then have the parent's opacity applied as a post-effect.
2042    /// Here, opacity is applied to each child individually. This may result in a very
2043    /// different effect.
2044    pub fn r#set_opacity(
2045        &self,
2046        mut transform_id: &TransformId,
2047        mut value: f32,
2048    ) -> Result<(), fidl::Error> {
2049        self.client.send::<FlatlandSetOpacityRequest>(
2050            (transform_id, value),
2051            0x3775fc2c00b432fa,
2052            fidl::encoding::DynamicFlags::empty(),
2053        )
2054    }
2055
2056    /// Sets the bounds, expressed in the local coordinate space of the transform, that
2057    /// constrains the region that content attached to this transform can be rendered to.
2058    /// If the content's area exceeds the clip bounds, the area outside the bounds will
2059    /// not be rendered. These bounds are valid for all children of this transform node as
2060    /// well, which includes nested Flatland instances and their node hierarchies.
2061    /// If a child transform attempts to set clip bounds larger than that of its parent,
2062    /// it will be clipped to the parent's clip bounds. The default state is for a transform
2063    /// to be unclipped, meaning it will not have any bounds placed on its render region.
2064    /// The clip width/height must be positive. Negative values will result in an error.
2065    /// Passing in an empty box to the |rect| parameter will remove the clip bounds.
2066    pub fn r#set_clip_boundary(
2067        &self,
2068        mut transform_id: &TransformId,
2069        mut rect: Option<&fidl_fuchsia_math::Rect>,
2070    ) -> Result<(), fidl::Error> {
2071        self.client.send::<FlatlandSetClipBoundaryRequest>(
2072            (transform_id, rect),
2073            0x6507843df12222d2,
2074            fidl::encoding::DynamicFlags::empty(),
2075        )
2076    }
2077
2078    /// Adds a child Transform to a parent Transform. The new child Transform,
2079    /// and any Content attached to it or its children, will be rendered on top
2080    /// of the parent's Content, as well as any previously added children.
2081    ///
2082    /// The caller must ensure that `child_transform_id` is valid and that there
2083    /// are no repetitions.  Sending a repeated `child_transform_id` over
2084    /// multiple calls will result in session closure.
2085    pub fn r#add_child(
2086        &self,
2087        mut parent_transform_id: &TransformId,
2088        mut child_transform_id: &TransformId,
2089    ) -> Result<(), fidl::Error> {
2090        self.client.send::<FlatlandAddChildRequest>(
2091            (parent_transform_id, child_transform_id),
2092            0x67a8abd2f19b1a74,
2093            fidl::encoding::DynamicFlags::empty(),
2094        )
2095    }
2096
2097    /// Removes a child Transform from a parent Transform.
2098    pub fn r#remove_child(
2099        &self,
2100        mut parent_transform_id: &TransformId,
2101        mut child_transform_id: &TransformId,
2102    ) -> Result<(), fidl::Error> {
2103        self.client.send::<FlatlandRemoveChildRequest>(
2104            (parent_transform_id, child_transform_id),
2105            0x41d6cd90b298b67a,
2106            fidl::encoding::DynamicFlags::empty(),
2107        )
2108    }
2109
2110    /// Removes all child Transforms from a parent Transform and replaces them
2111    /// with the new child transforms in `new_child_transform_ids`.  The caller
2112    /// must ensure that all `TransformId` values in `new_child_transform_ids`
2113    /// are valid and that there are no repetitions.  Sending a repeated
2114    /// `TransformId` in `new_child_transform_ids` will result in session
2115    /// closure.
2116    pub fn r#replace_children(
2117        &self,
2118        mut parent_transform_id: &TransformId,
2119        mut new_child_transform_ids: &[TransformId],
2120    ) -> Result<(), fidl::Error> {
2121        self.client.send::<FlatlandReplaceChildrenRequest>(
2122            (parent_transform_id, new_child_transform_ids),
2123            0x5b6d86cbbff81316,
2124            fidl::encoding::DynamicFlags::empty(),
2125        )
2126    }
2127
2128    /// Sets the Root Transform for the graph.
2129    ///
2130    /// The sub-graph defined by the Root Transform and its children will be rendered as View
2131    /// in the connected parent's Viewport (see [`CreateView`]). Any parents of the Root Transform
2132    /// in this Graph will be ignored.
2133    ///
2134    /// The Root Transform, and all children of the Root Transform, are kept alive if they are
2135    /// released (see [`ReleaseTransform`] for more details).
2136    ///
2137    /// There is only ever one Root. Since 0 is not a valid transform id (see [`CreateTransform`]),
2138    /// calling SetRootTransform(0) clears the current Root, destroying any previously released
2139    /// objects that are not referenced by the new root.
2140    ///
2141    /// Note that every View has a clip boundary equivalent to its logical size. Anything outside
2142    /// that clip boundary will not be rendered. Hence, the Root Transform has a useful coordinate
2143    /// space of (0, 0) to (logical_size.width, logical_size.height), where (0, 0) is the upper left
2144    /// corner.
2145    ///
2146    /// Setting the root transform installs a full screen hit region on the root transform. Clients
2147    /// may remove this hit region if they don't want users to be able to interact with the root
2148    /// transform's content. For additional details on hit regions, see the [`SetHitRegions`]
2149    /// documentation.
2150    ///
2151    /// Default hit region rules
2152    ///
2153    ///   A default hit region follows these rules:
2154    ///   - When [`SetRootTransform`](T) is called, T receives a maximal hit region, covering the
2155    ///   entire view.
2156    ///   - If [`SetHitRegions`] is called on T, either before or after [`SetRootTransform`](T),
2157    ///   then no default hit region is active and the client specified hit regions are used.
2158    ///   - If a transform is no longer the root transform, i.e., [`SetRootTransform`](U) is
2159    ///   called, then the original transform no longer has its default hit region.
2160    ///   - Clients can remove or modify the root transform's hit regions the same way they would
2161    ///   reset any other transform's hit regions, by calling [`SetHitRegions`] with the appropriate
2162    ///   vector.
2163    pub fn r#set_root_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2164        self.client.send::<FlatlandSetRootTransformRequest>(
2165            (transform_id,),
2166            0x6e80ca5bcc566cd8,
2167            fidl::encoding::DynamicFlags::empty(),
2168        )
2169    }
2170
2171    /// Sets the interactive areas for a Transform. By default, Content is not interactive; hit
2172    /// regions must be placed for a user to interact with the Content in a View. Because hit
2173    /// regions are described in the Flatland protocol, a Flatland instance can synchronize Content
2174    /// and hit regions.
2175    ///
2176    /// Each hit region is placed in the coordinate space of the owning Transform, and may or may
2177    /// not interact with different types of hit testing, depending on its [`HitTestInteraction`]
2178    /// type. When there are multiple hit regions that intersect with a hit test, the precedence
2179    /// rules given below dictate which hit region has interacted with the hit test. Only Transforms
2180    /// that transitively connect to the root Transform have their hit regions interact with a hit
2181    /// test.
2182    ///
2183    /// Calling this function replaces any previous values set on this Transform. To reset a
2184    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2185    ///
2186    /// Note that root transforms get a default hit region installed by Flatland. For more details,
2187    /// see the [`SetRootTransform`] documentation.
2188    ///
2189    /// Precedence rules
2190    ///   Within a Transform, if multiple hit regions overlap, the hit test examines each
2191    ///   intersecting hit region for a possible interaction. Thus, for a regular hit test R and an
2192    ///   accessibility hit test A, where R and A both intersect two hit regions D ([`DEFAULT`]) and
2193    ///   S ([`SEMANTICALLY_INVISIBLE`]) on the same Transform, (1) R interacts with both D and S,
2194    ///   and (2) A only interacts with D. Generally, hit regions that overlap in a single Transform
2195    ///   can cause confusing behavior.
2196    ///
2197    ///   Within a View, for a given hit test, the front-most Transform's hit regions take
2198    ///   precedence over those behind. This follows the expected reverse "render order" of
2199    ///   Transforms (described in [`CreateTransform`]), where a user expects to interact with
2200    ///   Content that is visible, or front-most.
2201    ///
2202    ///   Across Flatland instances, for a given hit test, the front-most instance's front-most
2203    ///   Transform's hit regions take precedence over those behind. This follows the expected
2204    ///   reverse "render order" of views, where a user expects to interact with the View that is
2205    ///   visible, or front-most. For example, if a child View owns Content that is rendered over
2206    ///   the parent View, the user expects to interact with the child's Content.
2207    pub fn r#set_hit_regions(
2208        &self,
2209        mut transform_id: &TransformId,
2210        mut regions: &[HitRegion],
2211    ) -> Result<(), fidl::Error> {
2212        self.client.send::<FlatlandSetHitRegionsRequest>(
2213            (transform_id, regions),
2214            0x31c9d17b07c37ce4,
2215            fidl::encoding::DynamicFlags::empty(),
2216        )
2217    }
2218
2219    /// Identical to [`SetHitRegions`], except the hit region associated with [`transform_id`]
2220    /// covers an infinite region. The hit region is invariant against translation, scaling, and
2221    /// orientation of the Transform.
2222    ///
2223    /// An infinite hit region is still limited in extent by the View's clip boundary, just like a
2224    /// finite hit region.
2225    ///
2226    /// Calling this function replaces any previous values set on this Transform. To reset a
2227    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2228    pub fn r#set_infinite_hit_region(
2229        &self,
2230        mut transform_id: &TransformId,
2231        mut hit_test: HitTestInteraction,
2232    ) -> Result<(), fidl::Error> {
2233        self.client.send::<FlatlandSetInfiniteHitRegionRequest>(
2234            (transform_id, hit_test),
2235            0x26d81af852d29562,
2236            fidl::encoding::DynamicFlags::empty(),
2237        )
2238    }
2239
2240    /// The Viewport and View pair, together, represent the connection between two Flatland
2241    /// instances. The Viewport is created in the parent, and the View is created in the child. The
2242    /// parent has control over how the child's View is integrated into its own View.
2243    ///
2244    /// Any illegal operations on ChildViewWatcher will cause both ChildViewWatcher channel and this
2245    /// Flatland channel to be torn down.
2246    ///
2247    /// `ViewportProperties` must have logical_size set. This is the initial size that will drive
2248    /// the layout of the child. The logical_size is also used as the default Content size, but
2249    /// subsequent changes to the logical_size will have no effect on the Content size.
2250    ///
2251    /// `ViewportProperties` may have inset field not set. In that case, the default value of
2252    /// (0, 0, 0, 0) is used.
2253    ///
2254    /// The logical_size must have positive X and Y components.
2255    ///
2256    /// Zero is not a valid ContentId. All other values are valid, assuming they are not already
2257    /// in use for another piece of Content (see [`ReleaseViewport`] for more details).
2258    ///
2259    /// Lifecycle note. The lifetime of the ChildViewWatcher channel is bound by the peer
2260    /// ViewCreationToken. When the ViewCreationToken dies, this ChildViewWatcher channel is
2261    /// destroyed.
2262    pub fn r#create_viewport(
2263        &self,
2264        mut viewport_id: &ContentId,
2265        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
2266        mut properties: &ViewportProperties,
2267        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
2268    ) -> Result<(), fidl::Error> {
2269        self.client.send::<FlatlandCreateViewportRequest>(
2270            (viewport_id, &mut token, properties, child_view_watcher),
2271            0x2485fbcab7f943c,
2272            fidl::encoding::DynamicFlags::empty(),
2273        )
2274    }
2275
2276    /// An Image is a bitmap backed by a specific VMO in a BufferCollection.
2277    ///
2278    /// Image creation requires an allocated BufferCollection registered with Allocator. This
2279    /// function will fail unless all clients of the specified BufferCollection have set their
2280    /// constraints.
2281    ///
2282    /// The Image must reference a valid VMO index and must have ImageProperties that fall within
2283    /// the constraints specified by the backing BufferCollection (i.e. width and height within a
2284    /// valid range, etc.)
2285    ///
2286    /// Zero is not a valid Image id. All other values are valid, assuming they are not already in
2287    /// use for another piece of Content (see [`ReleaseImage`] for more details).
2288    pub fn r#create_image(
2289        &self,
2290        mut image_id: &ContentId,
2291        mut import_token: BufferCollectionImportToken,
2292        mut vmo_index: u32,
2293        mut properties: &ImageProperties,
2294    ) -> Result<(), fidl::Error> {
2295        self.client.send::<FlatlandCreateImageRequest>(
2296            (image_id, &mut import_token, vmo_index, properties),
2297            0x26fae823c4ebedad,
2298            fidl::encoding::DynamicFlags::empty(),
2299        )
2300    }
2301
2302    /// This function is used to determine the region (in texel space) of an image that will be used
2303    /// by Flatland when rendering. The image to be sampled is referenced by [`image_id`] and the
2304    /// sample region is specified by [`rect`] which itself is comprised of an origin point (x,y) as
2305    /// well as a width and height, in unnormalized coordinates. It is illegal to call this function
2306    /// on non-image content, or to sample a region outside of the texel space of the image. In
2307    /// other words, the region specifed by [`rect`] must not exceed the ranges (0, image_width) and
2308    /// (0, image_height). If (rect.x + rect.width > image_width) or (rect.y + rect.height >
2309    /// image_height) or if any of the values are negative, this will result in an error.
2310    ///
2311    /// If this method is not called, the default sample region is the rectangle with origin at
2312    /// (0, 0) and width and height set at ImageProperties from [`CreateImage`].
2313    pub fn r#set_image_sample_region(
2314        &self,
2315        mut image_id: &ContentId,
2316        mut rect: &fidl_fuchsia_math::RectF,
2317    ) -> Result<(), fidl::Error> {
2318        self.client.send::<FlatlandSetImageSampleRegionRequest>(
2319            (image_id, rect),
2320            0x8039391d715eb28,
2321            fidl::encoding::DynamicFlags::empty(),
2322        )
2323    }
2324
2325    /// The content size for an Image is the size of the rectangle in the parent's logical
2326    /// coordinate space that the image occupies. This combined with the global translation of the
2327    /// transform it is attached to determines the size and location of where the content is
2328    /// rendered on the display.
2329    ///
2330    /// If this method is not called, the default image destination size is the width and height set
2331    /// at ImageProperties from [`CreateImage`]. The destination size will be affected by scaling if
2332    /// [`SetScale`] is used on the attached Transform or its parents.
2333    pub fn r#set_image_destination_size(
2334        &self,
2335        mut image_id: &ContentId,
2336        mut size: &fidl_fuchsia_math::SizeU,
2337    ) -> Result<(), fidl::Error> {
2338        self.client.send::<FlatlandSetImageDestinationSizeRequest>(
2339            (image_id, size),
2340            0x766cf99a2ec58446,
2341            fidl::encoding::DynamicFlags::empty(),
2342        )
2343    }
2344
2345    /// Determines the blend function to use when rendering the content specified by
2346    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
2347    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
2348    /// that are available, please refer to the BlendMode enum. If this function is not called, then
2349    /// the default blendmode is BlendMode::SRC.
2350    pub fn r#set_image_blending_function(
2351        &self,
2352        mut image_id: &ContentId,
2353        mut blend_mode: BlendMode,
2354    ) -> Result<(), fidl::Error> {
2355        self.client.send::<FlatlandSetImageBlendingFunctionRequest>(
2356            (image_id, blend_mode),
2357            0x10f5da1356275b7b,
2358            fidl::encoding::DynamicFlags::empty(),
2359        )
2360    }
2361
2362    /// Determines the blend function to use when rendering the content specified by
2363    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
2364    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
2365    /// that are available, please refer to the BlendMode2 enum. If this function is not called,
2366    /// the default blendmode is BlendMode2::REPLACE.
2367    pub fn r#set_image_blend_mode(
2368        &self,
2369        mut image_id: &ContentId,
2370        mut blend_mode: BlendMode2,
2371    ) -> Result<(), fidl::Error> {
2372        self.client.send::<FlatlandSetImageBlendModeRequest>(
2373            (image_id, blend_mode),
2374            0x5b1667f130c3de67,
2375            fidl::encoding::DynamicFlags::empty(),
2376        )
2377    }
2378
2379    /// Sets an opacity in linear space to be applied to a flatland image. Opacity values must
2380    /// be in the range [0.0, 1.0].
2381    pub fn r#set_image_opacity(
2382        &self,
2383        mut image_id: &ContentId,
2384        mut val: f32,
2385    ) -> Result<(), fidl::Error> {
2386        self.client.send::<FlatlandSetImageOpacityRequest>(
2387            (image_id, val),
2388            0x2da9e4ef4c2cff6f,
2389            fidl::encoding::DynamicFlags::empty(),
2390        )
2391    }
2392
2393    /// Sets the image flip to be applied to a flatland image. This call must be performed after a
2394    /// successful |CreateImage| call. If an invalid |image_id| is supplied, the channel will be
2395    /// closed due to FlatlandError::BAD_OPERATION. This flip will be applied to the Image before
2396    /// parent Transform Orientations. If this function is not called, then the default flip value
2397    /// is ImageFlip::NONE.
2398    pub fn r#set_image_flip(
2399        &self,
2400        mut image_id: &ContentId,
2401        mut flip: ImageFlip,
2402    ) -> Result<(), fidl::Error> {
2403        self.client.send::<FlatlandSetImageFlipRequest>(
2404            (image_id, flip),
2405            0x21b20f2c14aae6bc,
2406            fidl::encoding::DynamicFlags::empty(),
2407        )
2408    }
2409
2410    /// Creates a solid-color rectangle. By default a filled-rect does not have a defined
2411    /// color or size. It is necessary to call |SetSolidFill| to specify a color and size
2412    /// before a filled rect can be used for rendering. Not doing so will result the
2413    pub fn r#create_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
2414        self.client.send::<FlatlandCreateFilledRectRequest>(
2415            (rect_id,),
2416            0x5e62355abc1c4c5d,
2417            fidl::encoding::DynamicFlags::empty(),
2418        )
2419    }
2420
2421    /// Defines the color and size of a filled rect. |rect_id| must refer to content that
2422    /// was created via a call to CreateFilledRect. The color is not premultiplied. Color values
2423    /// must be within the range [0,1] inclusive, and normal 32-bit
2424    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29. Values
2425    /// that do not conform to these specifications will cause the channel to close.
2426    /// The rectangle's top left corner will be at (0, 0) in its transform's coordinate space.
2427    /// Hence, its bottom right corner will be at (size.width, size.height).
2428    pub fn r#set_solid_fill(
2429        &self,
2430        mut rect_id: &ContentId,
2431        mut color: &ColorRgba,
2432        mut size: &fidl_fuchsia_math::SizeU,
2433    ) -> Result<(), fidl::Error> {
2434        self.client.send::<FlatlandSetSolidFillRequest>(
2435            (rect_id, color, size),
2436            0x32d6ef41e182dfa5,
2437            fidl::encoding::DynamicFlags::empty(),
2438        )
2439    }
2440
2441    /// Automatically garbage collects the rectangle when it is no longer needed for
2442    /// rendering. |rect_id| must have been instantiated with a call to
2443    /// |CreateFilledRect|. Once released, the ID immediately goes out of scope and is free
2444    /// to be used again.
2445    pub fn r#release_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
2446        self.client.send::<FlatlandReleaseFilledRectRequest>(
2447            (rect_id,),
2448            0x7392cabe45618f9b,
2449            fidl::encoding::DynamicFlags::empty(),
2450        )
2451    }
2452
2453    /// Setting a piece of Content on a Transform makes that Content visible in the render tree as
2454    /// long as the Transform is visible from the root Transform. The Content will be rendered
2455    /// before, and therefore "behind", any Content attached to the descendants of the Transform.
2456    ///
2457    /// Because each Transform can have, at most, a single piece of Content on it, calling this
2458    /// function on a Transform that already has Content will replace that Content.
2459    ///
2460    /// A Content may be set on more than one Transform.
2461    ///
2462    /// Calling this function with a Content id of 0 will remove any Content currently on the
2463    /// Transform.
2464    pub fn r#set_content(
2465        &self,
2466        mut transform_id: &TransformId,
2467        mut content_id: &ContentId,
2468    ) -> Result<(), fidl::Error> {
2469        self.client.send::<FlatlandSetContentRequest>(
2470            (transform_id, content_id),
2471            0x4ed2cfc0ce130862,
2472            fidl::encoding::DynamicFlags::empty(),
2473        )
2474    }
2475
2476    /// Transforms are usually sufficient to change how Content is presented. Viewports, however,
2477    /// have special properties that are not part of the Transform hierarchy. Those properties can
2478    /// be set using this function.
2479    pub fn r#set_viewport_properties(
2480        &self,
2481        mut viewport_id: &ContentId,
2482        mut properties: &ViewportProperties,
2483    ) -> Result<(), fidl::Error> {
2484        self.client.send::<FlatlandSetViewportPropertiesRequest>(
2485            (viewport_id, properties),
2486            0x66ab67e9608ddb9f,
2487            fidl::encoding::DynamicFlags::empty(),
2488        )
2489    }
2490
2491    /// Released Transforms will be garbage collected by the system once they are no longer
2492    /// necessary for rendering. For Transforms, this means there is no path from any unreleased
2493    /// Transform to the newly-released Transform.
2494    ///
2495    /// Once released, the id immediately goes out of scope for future function calls and can be
2496    /// reused when creating new Transforms.
2497    ///
2498    /// It is an error to call functions with a released id (unless that id has been reused to
2499    /// construct a new Transform).
2500    pub fn r#release_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2501        self.client.send::<FlatlandReleaseTransformRequest>(
2502            (transform_id,),
2503            0xab9328419451c22,
2504            fidl::encoding::DynamicFlags::empty(),
2505        )
2506    }
2507
2508    pub fn r#release_view(&self) -> Result<(), fidl::Error> {
2509        self.client.send::<fidl::encoding::EmptyPayload>(
2510            (),
2511            0x5b35aab9baffecae,
2512            fidl::encoding::DynamicFlags::empty(),
2513        )
2514    }
2515
2516    /// Releases a Viewport from the scene, even if the Viewport is still connected to a Transform.
2517    /// Unlike other resources, Viewports are garbage collected by the system during the next
2518    /// [`Present`] because a removed Viewport is guaranteed to provide no renderable content.
2519    ///
2520    /// Use SetContent(transform_id, 0) to clean up references to released Viewports.
2521    ///
2522    /// Despite having a return type, this function is still feed-forward like [`CreateView`] and
2523    /// requires a call to [`Present`] to be executed. The ViewportCreationToken will be returned
2524    /// after the presented operations have been executed.
2525    pub fn r#release_viewport(
2526        &self,
2527        mut viewport_id: &ContentId,
2528        ___deadline: zx::MonotonicInstant,
2529    ) -> Result<fidl_fuchsia_ui_views::ViewportCreationToken, fidl::Error> {
2530        let _response = self.client.send_query::<
2531            FlatlandReleaseViewportRequest,
2532            FlatlandReleaseViewportResponse,
2533            FlatlandMarker,
2534        >(
2535            (viewport_id,),
2536            0xbad474aeb5293f9,
2537            fidl::encoding::DynamicFlags::empty(),
2538            ___deadline,
2539        )?;
2540        Ok(_response.token)
2541    }
2542
2543    /// Released Images will be garbage collected by the system once they are no longer necessary
2544    /// for rendering. For Images, this means the Image is no longer attached to any Transform and
2545    /// any pending rendering that references the Image is complete.
2546    ///
2547    /// Use SetContent(transform_id, 0) to clean up references to released Images.
2548    ///
2549    /// Once released, the id immediately goes out of scope for future function calls and can be
2550    /// reused when creating new Images.
2551    ///
2552    /// It is an error to call functions with a released id (unless that id has been reused to
2553    /// construct a new Image).
2554    pub fn r#release_image(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
2555        self.client.send::<FlatlandReleaseImageRequest>(
2556            (image_id,),
2557            0xb884ffdbc72c111,
2558            fidl::encoding::DynamicFlags::empty(),
2559        )
2560    }
2561
2562    /// This function will reset all state on this interface. This includes destroying all existing
2563    /// View and Viewports without returning the associated Token to the caller.
2564    pub fn r#clear(&self) -> Result<(), fidl::Error> {
2565        self.client.send::<fidl::encoding::EmptyPayload>(
2566            (),
2567            0x4ec8817c02828c3e,
2568            fidl::encoding::DynamicFlags::empty(),
2569        )
2570    }
2571
2572    /// Set debug name of the current client that can be used by Flatland to print as a prefix to
2573    /// logs to help client distinguish what is theirs. [`name`] can be an arbitrary string, but the
2574    /// current process name (see fsl::GetCurrentProcessName()) is a good default.
2575    pub fn r#set_debug_name(&self, mut name: &str) -> Result<(), fidl::Error> {
2576        self.client.send::<FlatlandSetDebugNameRequest>(
2577            (name,),
2578            0x46a8b397e68a8888,
2579            fidl::encoding::DynamicFlags::empty(),
2580        )
2581    }
2582}
2583
2584#[cfg(target_os = "fuchsia")]
2585impl From<FlatlandSynchronousProxy> for zx::NullableHandle {
2586    fn from(value: FlatlandSynchronousProxy) -> Self {
2587        value.into_channel().into()
2588    }
2589}
2590
2591#[cfg(target_os = "fuchsia")]
2592impl From<fidl::Channel> for FlatlandSynchronousProxy {
2593    fn from(value: fidl::Channel) -> Self {
2594        Self::new(value)
2595    }
2596}
2597
2598#[cfg(target_os = "fuchsia")]
2599impl fidl::endpoints::FromClient for FlatlandSynchronousProxy {
2600    type Protocol = FlatlandMarker;
2601
2602    fn from_client(value: fidl::endpoints::ClientEnd<FlatlandMarker>) -> Self {
2603        Self::new(value.into_channel())
2604    }
2605}
2606
2607#[derive(Debug, Clone)]
2608pub struct FlatlandProxy {
2609    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2610}
2611
2612impl fidl::endpoints::Proxy for FlatlandProxy {
2613    type Protocol = FlatlandMarker;
2614
2615    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2616        Self::new(inner)
2617    }
2618
2619    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2620        self.client.into_channel().map_err(|client| Self { client })
2621    }
2622
2623    fn as_channel(&self) -> &::fidl::AsyncChannel {
2624        self.client.as_channel()
2625    }
2626}
2627
2628impl FlatlandProxy {
2629    /// Create a new Proxy for fuchsia.ui.composition/Flatland.
2630    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2631        let protocol_name = <FlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2632        Self { client: fidl::client::Client::new(channel, protocol_name) }
2633    }
2634
2635    /// Get a Stream of events from the remote end of the protocol.
2636    ///
2637    /// # Panics
2638    ///
2639    /// Panics if the event stream was already taken.
2640    pub fn take_event_stream(&self) -> FlatlandEventStream {
2641        FlatlandEventStream { event_receiver: self.client.take_event_receiver() }
2642    }
2643
2644    /// Releases an image immediately, without waiting for the next present.
2645    pub fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
2646        FlatlandProxyInterface::r#release_image_immediately(self, image_id)
2647    }
2648
2649    /// Complete execution of all feed-forward operations.
2650    ///
2651    /// If executing an operation produces an error (e.g., CreateTransform(0)), an [`OnError`] event
2652    /// is emitted. Operations that produce errors are ignored and the channel is closed.
2653    ///
2654    /// If the execution is completed successfully, [`OnNextFrameBegin`] emits NO_ERROR along
2655    /// with other valid fields.
2656    ///
2657    /// The client may only call [`Present`] when they have a non-zero number of present credits,
2658    /// which are tracked by the server. The server may increment the number of credits when it
2659    /// fires the [`OnNextFrameBegin`] event, which informs the client when it receives additional
2660    /// present credits. Each [`Present`] call uses one present credit and decrements the server
2661    /// count by one. If the client calls [`Present`] with no present credits, the server will
2662    /// return a `NO_PRESENTS_REMAINING` error.
2663    ///
2664    /// The client should assume that prior to receiving any [`OnNextFrameBegin`] events, they have
2665    /// one present credit.
2666    ///
2667    /// Every [`Present`] call results in one [`OnNextFrameBegin`] event, and one
2668    /// [`OnFramePresented`] event, typically in that order.
2669    ///
2670    /// When the commands flushed by [`Present`] make it to display, an [`OnFramePresented`] event
2671    /// is fired. This event includes information pertaining to all [`Present`]s that had content
2672    /// that were part of that frame.
2673    ///
2674    /// See [`fuchsia.ui.composition/PresentArgs`] documentation above for more detailed information
2675    /// on what arguments are passed in and their role.
2676    pub fn r#present(&self, mut args: PresentArgs) -> Result<(), fidl::Error> {
2677        FlatlandProxyInterface::r#present(self, args)
2678    }
2679
2680    /// Two Flatland instances may be connected in a parent-child relationship. The parent endpoint
2681    /// is held in a Viewport, and the child endpoint is held in a View. The parent Flatland
2682    /// instance that creates a Viewport has control over how the child's View is integrated into
2683    /// its own View.
2684    ///
2685    /// The lifecycle of a parent-child connection starts with two endpoints of a channel object:
2686    /// a ViewportCreationToken and a ViewCreationToken. Out-of-band protocols pass the
2687    /// ViewportCreationToken to the parent, which calls [`CreateViewport`], and the
2688    /// ViewCreationToken to the child, which calls [`CreateView`].
2689    ///
2690    /// Only nodes connected to the Root Transform in this Flatland instance will be rendered into
2691    /// the parent's Viewport.
2692    ///
2693    /// Calling [`CreateView`] a second time will disconnect the Root Transform from the existing
2694    /// parent's Viewport, and attach it to a new parent's Viewport. In other words, each View can
2695    /// only have one parent.
2696    ///
2697    /// This function is queued, meaning that the Root Transform will not be attached to the
2698    /// parent Viewport until [`Present`] is called. However, clients will receive information
2699    /// through their ParentViewportWatcher (e.g., LayoutInfo) immediately after calling this
2700    /// function, even if they have not called [`Present`] or [`SetRootTransform`]. This allows
2701    /// clients to wait for layout information from their parent before calling [`Present`].
2702    ///
2703    /// Any illegal operations on ParentViewportWatcher will cause both ParentViewportWatcher
2704    /// channel and this Flatland channel to be torn down.
2705    ///
2706    /// Lifecycle note. The lifetime of the ParentViewportWatcher channel is bound by the peer
2707    /// ViewportCreationToken. When the ViewportCreationToken dies, this ParentViewportWatcher
2708    /// channel is destroyed.
2709    ///
2710    /// Views and subgraphs of Views created using `CreateView` will not be represented in the
2711    /// ViewTree, and hence will not be able to participate in any ViewTree-dependent interactions
2712    /// such as touch, mouse or focus.
2713    /// The Flatland protocol provides no way for Views in the subgraph of a View created with
2714    /// `CreateView` to know that they are excluded from the ViewTree.
2715    pub fn r#create_view(
2716        &self,
2717        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
2718        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
2719    ) -> Result<(), fidl::Error> {
2720        FlatlandProxyInterface::r#create_view(self, token, parent_viewport_watcher)
2721    }
2722
2723    /// Identical to [`CreateView`], except it allows association of View identity (ViewRef) and
2724    /// view-bound protocols.
2725    pub fn r#create_view2(
2726        &self,
2727        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
2728        mut view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
2729        mut protocols: ViewBoundProtocols,
2730        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
2731    ) -> Result<(), fidl::Error> {
2732        FlatlandProxyInterface::r#create_view2(
2733            self,
2734            token,
2735            view_identity,
2736            protocols,
2737            parent_viewport_watcher,
2738        )
2739    }
2740
2741    /// Creates a new Transform node. Transforms are a hierarchical piece of a Flatland graph. They
2742    /// can have children, and can reference Content. A sub-graph represented by a Transform and its
2743    /// descendants can be rendered to a display.
2744    ///
2745    /// Transforms are kept alive, even when released, as long as they are children of either an
2746    /// unreleased Transform, or the Root Transform.
2747    ///
2748    /// Each Transform can have a single piece of attached Content. Common types of Content include
2749    /// bitmaps, asynchronous streams of images, and Viewports to Views hosted in other Flatland
2750    /// instances.
2751    ///
2752    /// Transforms have attributes. Child Transforms inherit the combined attributes of their
2753    /// parents. Content attached to a Transform is also affected by that Transform's attributes.
2754    ///
2755    /// When a sub-graph of Transforms is rendered, Content will be rendered back-to-front, starting
2756    /// with the Content on the root transform, and continuing recursively through all of its child
2757    /// Transforms in the order the children were added. See [`AddChild`] for more information.
2758    ///
2759    /// Zero is not a valid transform id. All other values are valid, assuming they are not already
2760    /// in use (see [`ReleaseTransform`] for more details).
2761    pub fn r#create_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2762        FlatlandProxyInterface::r#create_transform(self, transform_id)
2763    }
2764
2765    /// All Transform objects support all attributes.
2766    ///
2767    /// Geometric attributes are applied in the following order:
2768    /// 1. Scale (relative to the parent transform's coordinate space)
2769    /// 2. Orientation (relative to the parent transform's coordinate space)
2770    /// 3. Translation (relative to the parent transforms's coordinate space,
2771    ///    unaffected by scale applied to the current transform).
2772    /// 4. Clipping (relative to the current transform's coordinate space)
2773    ///
2774    /// The effects of each of these attributes are cumulative. This means the transform's position
2775    /// in the view space, and its clip boundary, will be calculated based on that chain of
2776    /// geometric attributes going up to the root transform.
2777    ///
2778    /// For instance, in a nested hierarchy such as the following:
2779    ///     [Root-Transform -> Transform1 -> Transform2 -> CurrentTransform]
2780    /// If Transform1 is translated by [2,0] and Transform2 is translated by [0,1] then the
2781    /// view-space position of CurrentTransform will be [2,1].
2782    ///
2783    /// Sets the translation on a Transform. The order of geometric attribute application is
2784    /// addressed above.
2785    pub fn r#set_translation(
2786        &self,
2787        mut transform_id: &TransformId,
2788        mut translation: &fidl_fuchsia_math::Vec_,
2789    ) -> Result<(), fidl::Error> {
2790        FlatlandProxyInterface::r#set_translation(self, transform_id, translation)
2791    }
2792
2793    /// Sets the orientation on a Transform. The order of geometric attribute application is
2794    /// addressed in the documentation for [`SetTranslation`]. In Flatland, the +X axis is
2795    /// to the right and the +Y axis is down. There is no notion of a Z axis. CCW is defined
2796    /// from the POV of the user, as if a skeuomorphoic clock is displayed on the screen.
2797    pub fn r#set_orientation(
2798        &self,
2799        mut transform_id: &TransformId,
2800        mut orientation: Orientation,
2801    ) -> Result<(), fidl::Error> {
2802        FlatlandProxyInterface::r#set_orientation(self, transform_id, orientation)
2803    }
2804
2805    /// Sets the scale on a transform. The order of geometric attribute application is
2806    /// addressed above. The (x,y) values in the VecF |scale| refer to the scale factor in the
2807    /// x-axis (width) and y-axis (height) respectively. Scale values must be normal 32-bit
2808    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29
2809    pub fn r#set_scale(
2810        &self,
2811        mut transform_id: &TransformId,
2812        mut scale: &fidl_fuchsia_math::VecF,
2813    ) -> Result<(), fidl::Error> {
2814        FlatlandProxyInterface::r#set_scale(self, transform_id, scale)
2815    }
2816
2817    /// Sets an opacity in linear space to be applied to a transform and its descendents,
2818    /// which include other transforms and content. Opacity values must be in the range
2819    /// of [0.0, 1.0], where 0.0 is completely transparent and 1.0 is completely opaque.
2820    /// Attempting to call this function with values outside that range will result in
2821    /// an error. A transform's opacity value is multiplied with that of its parent. This
2822    /// effect works differently from group opacity. Using group opacity, child nodes are
2823    /// rendered together first, and then have the parent's opacity applied as a post-effect.
2824    /// Here, opacity is applied to each child individually. This may result in a very
2825    /// different effect.
2826    pub fn r#set_opacity(
2827        &self,
2828        mut transform_id: &TransformId,
2829        mut value: f32,
2830    ) -> Result<(), fidl::Error> {
2831        FlatlandProxyInterface::r#set_opacity(self, transform_id, value)
2832    }
2833
2834    /// Sets the bounds, expressed in the local coordinate space of the transform, that
2835    /// constrains the region that content attached to this transform can be rendered to.
2836    /// If the content's area exceeds the clip bounds, the area outside the bounds will
2837    /// not be rendered. These bounds are valid for all children of this transform node as
2838    /// well, which includes nested Flatland instances and their node hierarchies.
2839    /// If a child transform attempts to set clip bounds larger than that of its parent,
2840    /// it will be clipped to the parent's clip bounds. The default state is for a transform
2841    /// to be unclipped, meaning it will not have any bounds placed on its render region.
2842    /// The clip width/height must be positive. Negative values will result in an error.
2843    /// Passing in an empty box to the |rect| parameter will remove the clip bounds.
2844    pub fn r#set_clip_boundary(
2845        &self,
2846        mut transform_id: &TransformId,
2847        mut rect: Option<&fidl_fuchsia_math::Rect>,
2848    ) -> Result<(), fidl::Error> {
2849        FlatlandProxyInterface::r#set_clip_boundary(self, transform_id, rect)
2850    }
2851
2852    /// Adds a child Transform to a parent Transform. The new child Transform,
2853    /// and any Content attached to it or its children, will be rendered on top
2854    /// of the parent's Content, as well as any previously added children.
2855    ///
2856    /// The caller must ensure that `child_transform_id` is valid and that there
2857    /// are no repetitions.  Sending a repeated `child_transform_id` over
2858    /// multiple calls will result in session closure.
2859    pub fn r#add_child(
2860        &self,
2861        mut parent_transform_id: &TransformId,
2862        mut child_transform_id: &TransformId,
2863    ) -> Result<(), fidl::Error> {
2864        FlatlandProxyInterface::r#add_child(self, parent_transform_id, child_transform_id)
2865    }
2866
2867    /// Removes a child Transform from a parent Transform.
2868    pub fn r#remove_child(
2869        &self,
2870        mut parent_transform_id: &TransformId,
2871        mut child_transform_id: &TransformId,
2872    ) -> Result<(), fidl::Error> {
2873        FlatlandProxyInterface::r#remove_child(self, parent_transform_id, child_transform_id)
2874    }
2875
2876    /// Removes all child Transforms from a parent Transform and replaces them
2877    /// with the new child transforms in `new_child_transform_ids`.  The caller
2878    /// must ensure that all `TransformId` values in `new_child_transform_ids`
2879    /// are valid and that there are no repetitions.  Sending a repeated
2880    /// `TransformId` in `new_child_transform_ids` will result in session
2881    /// closure.
2882    pub fn r#replace_children(
2883        &self,
2884        mut parent_transform_id: &TransformId,
2885        mut new_child_transform_ids: &[TransformId],
2886    ) -> Result<(), fidl::Error> {
2887        FlatlandProxyInterface::r#replace_children(
2888            self,
2889            parent_transform_id,
2890            new_child_transform_ids,
2891        )
2892    }
2893
2894    /// Sets the Root Transform for the graph.
2895    ///
2896    /// The sub-graph defined by the Root Transform and its children will be rendered as View
2897    /// in the connected parent's Viewport (see [`CreateView`]). Any parents of the Root Transform
2898    /// in this Graph will be ignored.
2899    ///
2900    /// The Root Transform, and all children of the Root Transform, are kept alive if they are
2901    /// released (see [`ReleaseTransform`] for more details).
2902    ///
2903    /// There is only ever one Root. Since 0 is not a valid transform id (see [`CreateTransform`]),
2904    /// calling SetRootTransform(0) clears the current Root, destroying any previously released
2905    /// objects that are not referenced by the new root.
2906    ///
2907    /// Note that every View has a clip boundary equivalent to its logical size. Anything outside
2908    /// that clip boundary will not be rendered. Hence, the Root Transform has a useful coordinate
2909    /// space of (0, 0) to (logical_size.width, logical_size.height), where (0, 0) is the upper left
2910    /// corner.
2911    ///
2912    /// Setting the root transform installs a full screen hit region on the root transform. Clients
2913    /// may remove this hit region if they don't want users to be able to interact with the root
2914    /// transform's content. For additional details on hit regions, see the [`SetHitRegions`]
2915    /// documentation.
2916    ///
2917    /// Default hit region rules
2918    ///
2919    ///   A default hit region follows these rules:
2920    ///   - When [`SetRootTransform`](T) is called, T receives a maximal hit region, covering the
2921    ///   entire view.
2922    ///   - If [`SetHitRegions`] is called on T, either before or after [`SetRootTransform`](T),
2923    ///   then no default hit region is active and the client specified hit regions are used.
2924    ///   - If a transform is no longer the root transform, i.e., [`SetRootTransform`](U) is
2925    ///   called, then the original transform no longer has its default hit region.
2926    ///   - Clients can remove or modify the root transform's hit regions the same way they would
2927    ///   reset any other transform's hit regions, by calling [`SetHitRegions`] with the appropriate
2928    ///   vector.
2929    pub fn r#set_root_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2930        FlatlandProxyInterface::r#set_root_transform(self, transform_id)
2931    }
2932
2933    /// Sets the interactive areas for a Transform. By default, Content is not interactive; hit
2934    /// regions must be placed for a user to interact with the Content in a View. Because hit
2935    /// regions are described in the Flatland protocol, a Flatland instance can synchronize Content
2936    /// and hit regions.
2937    ///
2938    /// Each hit region is placed in the coordinate space of the owning Transform, and may or may
2939    /// not interact with different types of hit testing, depending on its [`HitTestInteraction`]
2940    /// type. When there are multiple hit regions that intersect with a hit test, the precedence
2941    /// rules given below dictate which hit region has interacted with the hit test. Only Transforms
2942    /// that transitively connect to the root Transform have their hit regions interact with a hit
2943    /// test.
2944    ///
2945    /// Calling this function replaces any previous values set on this Transform. To reset a
2946    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2947    ///
2948    /// Note that root transforms get a default hit region installed by Flatland. For more details,
2949    /// see the [`SetRootTransform`] documentation.
2950    ///
2951    /// Precedence rules
2952    ///   Within a Transform, if multiple hit regions overlap, the hit test examines each
2953    ///   intersecting hit region for a possible interaction. Thus, for a regular hit test R and an
2954    ///   accessibility hit test A, where R and A both intersect two hit regions D ([`DEFAULT`]) and
2955    ///   S ([`SEMANTICALLY_INVISIBLE`]) on the same Transform, (1) R interacts with both D and S,
2956    ///   and (2) A only interacts with D. Generally, hit regions that overlap in a single Transform
2957    ///   can cause confusing behavior.
2958    ///
2959    ///   Within a View, for a given hit test, the front-most Transform's hit regions take
2960    ///   precedence over those behind. This follows the expected reverse "render order" of
2961    ///   Transforms (described in [`CreateTransform`]), where a user expects to interact with
2962    ///   Content that is visible, or front-most.
2963    ///
2964    ///   Across Flatland instances, for a given hit test, the front-most instance's front-most
2965    ///   Transform's hit regions take precedence over those behind. This follows the expected
2966    ///   reverse "render order" of views, where a user expects to interact with the View that is
2967    ///   visible, or front-most. For example, if a child View owns Content that is rendered over
2968    ///   the parent View, the user expects to interact with the child's Content.
2969    pub fn r#set_hit_regions(
2970        &self,
2971        mut transform_id: &TransformId,
2972        mut regions: &[HitRegion],
2973    ) -> Result<(), fidl::Error> {
2974        FlatlandProxyInterface::r#set_hit_regions(self, transform_id, regions)
2975    }
2976
2977    /// Identical to [`SetHitRegions`], except the hit region associated with [`transform_id`]
2978    /// covers an infinite region. The hit region is invariant against translation, scaling, and
2979    /// orientation of the Transform.
2980    ///
2981    /// An infinite hit region is still limited in extent by the View's clip boundary, just like a
2982    /// finite hit region.
2983    ///
2984    /// Calling this function replaces any previous values set on this Transform. To reset a
2985    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2986    pub fn r#set_infinite_hit_region(
2987        &self,
2988        mut transform_id: &TransformId,
2989        mut hit_test: HitTestInteraction,
2990    ) -> Result<(), fidl::Error> {
2991        FlatlandProxyInterface::r#set_infinite_hit_region(self, transform_id, hit_test)
2992    }
2993
2994    /// The Viewport and View pair, together, represent the connection between two Flatland
2995    /// instances. The Viewport is created in the parent, and the View is created in the child. The
2996    /// parent has control over how the child's View is integrated into its own View.
2997    ///
2998    /// Any illegal operations on ChildViewWatcher will cause both ChildViewWatcher channel and this
2999    /// Flatland channel to be torn down.
3000    ///
3001    /// `ViewportProperties` must have logical_size set. This is the initial size that will drive
3002    /// the layout of the child. The logical_size is also used as the default Content size, but
3003    /// subsequent changes to the logical_size will have no effect on the Content size.
3004    ///
3005    /// `ViewportProperties` may have inset field not set. In that case, the default value of
3006    /// (0, 0, 0, 0) is used.
3007    ///
3008    /// The logical_size must have positive X and Y components.
3009    ///
3010    /// Zero is not a valid ContentId. All other values are valid, assuming they are not already
3011    /// in use for another piece of Content (see [`ReleaseViewport`] for more details).
3012    ///
3013    /// Lifecycle note. The lifetime of the ChildViewWatcher channel is bound by the peer
3014    /// ViewCreationToken. When the ViewCreationToken dies, this ChildViewWatcher channel is
3015    /// destroyed.
3016    pub fn r#create_viewport(
3017        &self,
3018        mut viewport_id: &ContentId,
3019        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
3020        mut properties: &ViewportProperties,
3021        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
3022    ) -> Result<(), fidl::Error> {
3023        FlatlandProxyInterface::r#create_viewport(
3024            self,
3025            viewport_id,
3026            token,
3027            properties,
3028            child_view_watcher,
3029        )
3030    }
3031
3032    /// An Image is a bitmap backed by a specific VMO in a BufferCollection.
3033    ///
3034    /// Image creation requires an allocated BufferCollection registered with Allocator. This
3035    /// function will fail unless all clients of the specified BufferCollection have set their
3036    /// constraints.
3037    ///
3038    /// The Image must reference a valid VMO index and must have ImageProperties that fall within
3039    /// the constraints specified by the backing BufferCollection (i.e. width and height within a
3040    /// valid range, etc.)
3041    ///
3042    /// Zero is not a valid Image id. All other values are valid, assuming they are not already in
3043    /// use for another piece of Content (see [`ReleaseImage`] for more details).
3044    pub fn r#create_image(
3045        &self,
3046        mut image_id: &ContentId,
3047        mut import_token: BufferCollectionImportToken,
3048        mut vmo_index: u32,
3049        mut properties: &ImageProperties,
3050    ) -> Result<(), fidl::Error> {
3051        FlatlandProxyInterface::r#create_image(self, image_id, import_token, vmo_index, properties)
3052    }
3053
3054    /// This function is used to determine the region (in texel space) of an image that will be used
3055    /// by Flatland when rendering. The image to be sampled is referenced by [`image_id`] and the
3056    /// sample region is specified by [`rect`] which itself is comprised of an origin point (x,y) as
3057    /// well as a width and height, in unnormalized coordinates. It is illegal to call this function
3058    /// on non-image content, or to sample a region outside of the texel space of the image. In
3059    /// other words, the region specifed by [`rect`] must not exceed the ranges (0, image_width) and
3060    /// (0, image_height). If (rect.x + rect.width > image_width) or (rect.y + rect.height >
3061    /// image_height) or if any of the values are negative, this will result in an error.
3062    ///
3063    /// If this method is not called, the default sample region is the rectangle with origin at
3064    /// (0, 0) and width and height set at ImageProperties from [`CreateImage`].
3065    pub fn r#set_image_sample_region(
3066        &self,
3067        mut image_id: &ContentId,
3068        mut rect: &fidl_fuchsia_math::RectF,
3069    ) -> Result<(), fidl::Error> {
3070        FlatlandProxyInterface::r#set_image_sample_region(self, image_id, rect)
3071    }
3072
3073    /// The content size for an Image is the size of the rectangle in the parent's logical
3074    /// coordinate space that the image occupies. This combined with the global translation of the
3075    /// transform it is attached to determines the size and location of where the content is
3076    /// rendered on the display.
3077    ///
3078    /// If this method is not called, the default image destination size is the width and height set
3079    /// at ImageProperties from [`CreateImage`]. The destination size will be affected by scaling if
3080    /// [`SetScale`] is used on the attached Transform or its parents.
3081    pub fn r#set_image_destination_size(
3082        &self,
3083        mut image_id: &ContentId,
3084        mut size: &fidl_fuchsia_math::SizeU,
3085    ) -> Result<(), fidl::Error> {
3086        FlatlandProxyInterface::r#set_image_destination_size(self, image_id, size)
3087    }
3088
3089    /// Determines the blend function to use when rendering the content specified by
3090    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
3091    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
3092    /// that are available, please refer to the BlendMode enum. If this function is not called, then
3093    /// the default blendmode is BlendMode::SRC.
3094    pub fn r#set_image_blending_function(
3095        &self,
3096        mut image_id: &ContentId,
3097        mut blend_mode: BlendMode,
3098    ) -> Result<(), fidl::Error> {
3099        FlatlandProxyInterface::r#set_image_blending_function(self, image_id, blend_mode)
3100    }
3101
3102    /// Determines the blend function to use when rendering the content specified by
3103    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
3104    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
3105    /// that are available, please refer to the BlendMode2 enum. If this function is not called,
3106    /// the default blendmode is BlendMode2::REPLACE.
3107    pub fn r#set_image_blend_mode(
3108        &self,
3109        mut image_id: &ContentId,
3110        mut blend_mode: BlendMode2,
3111    ) -> Result<(), fidl::Error> {
3112        FlatlandProxyInterface::r#set_image_blend_mode(self, image_id, blend_mode)
3113    }
3114
3115    /// Sets an opacity in linear space to be applied to a flatland image. Opacity values must
3116    /// be in the range [0.0, 1.0].
3117    pub fn r#set_image_opacity(
3118        &self,
3119        mut image_id: &ContentId,
3120        mut val: f32,
3121    ) -> Result<(), fidl::Error> {
3122        FlatlandProxyInterface::r#set_image_opacity(self, image_id, val)
3123    }
3124
3125    /// Sets the image flip to be applied to a flatland image. This call must be performed after a
3126    /// successful |CreateImage| call. If an invalid |image_id| is supplied, the channel will be
3127    /// closed due to FlatlandError::BAD_OPERATION. This flip will be applied to the Image before
3128    /// parent Transform Orientations. If this function is not called, then the default flip value
3129    /// is ImageFlip::NONE.
3130    pub fn r#set_image_flip(
3131        &self,
3132        mut image_id: &ContentId,
3133        mut flip: ImageFlip,
3134    ) -> Result<(), fidl::Error> {
3135        FlatlandProxyInterface::r#set_image_flip(self, image_id, flip)
3136    }
3137
3138    /// Creates a solid-color rectangle. By default a filled-rect does not have a defined
3139    /// color or size. It is necessary to call |SetSolidFill| to specify a color and size
3140    /// before a filled rect can be used for rendering. Not doing so will result the
3141    pub fn r#create_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3142        FlatlandProxyInterface::r#create_filled_rect(self, rect_id)
3143    }
3144
3145    /// Defines the color and size of a filled rect. |rect_id| must refer to content that
3146    /// was created via a call to CreateFilledRect. The color is not premultiplied. Color values
3147    /// must be within the range [0,1] inclusive, and normal 32-bit
3148    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29. Values
3149    /// that do not conform to these specifications will cause the channel to close.
3150    /// The rectangle's top left corner will be at (0, 0) in its transform's coordinate space.
3151    /// Hence, its bottom right corner will be at (size.width, size.height).
3152    pub fn r#set_solid_fill(
3153        &self,
3154        mut rect_id: &ContentId,
3155        mut color: &ColorRgba,
3156        mut size: &fidl_fuchsia_math::SizeU,
3157    ) -> Result<(), fidl::Error> {
3158        FlatlandProxyInterface::r#set_solid_fill(self, rect_id, color, size)
3159    }
3160
3161    /// Automatically garbage collects the rectangle when it is no longer needed for
3162    /// rendering. |rect_id| must have been instantiated with a call to
3163    /// |CreateFilledRect|. Once released, the ID immediately goes out of scope and is free
3164    /// to be used again.
3165    pub fn r#release_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3166        FlatlandProxyInterface::r#release_filled_rect(self, rect_id)
3167    }
3168
3169    /// Setting a piece of Content on a Transform makes that Content visible in the render tree as
3170    /// long as the Transform is visible from the root Transform. The Content will be rendered
3171    /// before, and therefore "behind", any Content attached to the descendants of the Transform.
3172    ///
3173    /// Because each Transform can have, at most, a single piece of Content on it, calling this
3174    /// function on a Transform that already has Content will replace that Content.
3175    ///
3176    /// A Content may be set on more than one Transform.
3177    ///
3178    /// Calling this function with a Content id of 0 will remove any Content currently on the
3179    /// Transform.
3180    pub fn r#set_content(
3181        &self,
3182        mut transform_id: &TransformId,
3183        mut content_id: &ContentId,
3184    ) -> Result<(), fidl::Error> {
3185        FlatlandProxyInterface::r#set_content(self, transform_id, content_id)
3186    }
3187
3188    /// Transforms are usually sufficient to change how Content is presented. Viewports, however,
3189    /// have special properties that are not part of the Transform hierarchy. Those properties can
3190    /// be set using this function.
3191    pub fn r#set_viewport_properties(
3192        &self,
3193        mut viewport_id: &ContentId,
3194        mut properties: &ViewportProperties,
3195    ) -> Result<(), fidl::Error> {
3196        FlatlandProxyInterface::r#set_viewport_properties(self, viewport_id, properties)
3197    }
3198
3199    /// Released Transforms will be garbage collected by the system once they are no longer
3200    /// necessary for rendering. For Transforms, this means there is no path from any unreleased
3201    /// Transform to the newly-released Transform.
3202    ///
3203    /// Once released, the id immediately goes out of scope for future function calls and can be
3204    /// reused when creating new Transforms.
3205    ///
3206    /// It is an error to call functions with a released id (unless that id has been reused to
3207    /// construct a new Transform).
3208    pub fn r#release_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3209        FlatlandProxyInterface::r#release_transform(self, transform_id)
3210    }
3211
3212    pub fn r#release_view(&self) -> Result<(), fidl::Error> {
3213        FlatlandProxyInterface::r#release_view(self)
3214    }
3215
3216    /// Releases a Viewport from the scene, even if the Viewport is still connected to a Transform.
3217    /// Unlike other resources, Viewports are garbage collected by the system during the next
3218    /// [`Present`] because a removed Viewport is guaranteed to provide no renderable content.
3219    ///
3220    /// Use SetContent(transform_id, 0) to clean up references to released Viewports.
3221    ///
3222    /// Despite having a return type, this function is still feed-forward like [`CreateView`] and
3223    /// requires a call to [`Present`] to be executed. The ViewportCreationToken will be returned
3224    /// after the presented operations have been executed.
3225    pub fn r#release_viewport(
3226        &self,
3227        mut viewport_id: &ContentId,
3228    ) -> fidl::client::QueryResponseFut<
3229        fidl_fuchsia_ui_views::ViewportCreationToken,
3230        fidl::encoding::DefaultFuchsiaResourceDialect,
3231    > {
3232        FlatlandProxyInterface::r#release_viewport(self, viewport_id)
3233    }
3234
3235    /// Released Images will be garbage collected by the system once they are no longer necessary
3236    /// for rendering. For Images, this means the Image is no longer attached to any Transform and
3237    /// any pending rendering that references the Image is complete.
3238    ///
3239    /// Use SetContent(transform_id, 0) to clean up references to released Images.
3240    ///
3241    /// Once released, the id immediately goes out of scope for future function calls and can be
3242    /// reused when creating new Images.
3243    ///
3244    /// It is an error to call functions with a released id (unless that id has been reused to
3245    /// construct a new Image).
3246    pub fn r#release_image(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
3247        FlatlandProxyInterface::r#release_image(self, image_id)
3248    }
3249
3250    /// This function will reset all state on this interface. This includes destroying all existing
3251    /// View and Viewports without returning the associated Token to the caller.
3252    pub fn r#clear(&self) -> Result<(), fidl::Error> {
3253        FlatlandProxyInterface::r#clear(self)
3254    }
3255
3256    /// Set debug name of the current client that can be used by Flatland to print as a prefix to
3257    /// logs to help client distinguish what is theirs. [`name`] can be an arbitrary string, but the
3258    /// current process name (see fsl::GetCurrentProcessName()) is a good default.
3259    pub fn r#set_debug_name(&self, mut name: &str) -> Result<(), fidl::Error> {
3260        FlatlandProxyInterface::r#set_debug_name(self, name)
3261    }
3262}
3263
3264impl FlatlandProxyInterface for FlatlandProxy {
3265    fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
3266        self.client.send::<TrustedFlatlandReleaseImageImmediatelyRequest>(
3267            (image_id,),
3268            0x245e1ac080772c8,
3269            fidl::encoding::DynamicFlags::empty(),
3270        )
3271    }
3272
3273    fn r#present(&self, mut args: PresentArgs) -> Result<(), fidl::Error> {
3274        self.client.send::<FlatlandPresentRequest>(
3275            (&mut args,),
3276            0x50acc2aa1f0acec7,
3277            fidl::encoding::DynamicFlags::empty(),
3278        )
3279    }
3280
3281    fn r#create_view(
3282        &self,
3283        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
3284        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
3285    ) -> Result<(), fidl::Error> {
3286        self.client.send::<FlatlandCreateViewRequest>(
3287            (&mut token, parent_viewport_watcher),
3288            0x504686eb25864780,
3289            fidl::encoding::DynamicFlags::empty(),
3290        )
3291    }
3292
3293    fn r#create_view2(
3294        &self,
3295        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
3296        mut view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
3297        mut protocols: ViewBoundProtocols,
3298        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
3299    ) -> Result<(), fidl::Error> {
3300        self.client.send::<FlatlandCreateView2Request>(
3301            (&mut token, &mut view_identity, &mut protocols, parent_viewport_watcher),
3302            0x340a3a40c2fdbd5e,
3303            fidl::encoding::DynamicFlags::empty(),
3304        )
3305    }
3306
3307    fn r#create_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3308        self.client.send::<FlatlandCreateTransformRequest>(
3309            (transform_id,),
3310            0x5e042a4d3de3efb0,
3311            fidl::encoding::DynamicFlags::empty(),
3312        )
3313    }
3314
3315    fn r#set_translation(
3316        &self,
3317        mut transform_id: &TransformId,
3318        mut translation: &fidl_fuchsia_math::Vec_,
3319    ) -> Result<(), fidl::Error> {
3320        self.client.send::<FlatlandSetTranslationRequest>(
3321            (transform_id, translation),
3322            0x7863398291fba346,
3323            fidl::encoding::DynamicFlags::empty(),
3324        )
3325    }
3326
3327    fn r#set_orientation(
3328        &self,
3329        mut transform_id: &TransformId,
3330        mut orientation: Orientation,
3331    ) -> Result<(), fidl::Error> {
3332        self.client.send::<FlatlandSetOrientationRequest>(
3333            (transform_id, orientation),
3334            0x4915310bc4928edc,
3335            fidl::encoding::DynamicFlags::empty(),
3336        )
3337    }
3338
3339    fn r#set_scale(
3340        &self,
3341        mut transform_id: &TransformId,
3342        mut scale: &fidl_fuchsia_math::VecF,
3343    ) -> Result<(), fidl::Error> {
3344        self.client.send::<FlatlandSetScaleRequest>(
3345            (transform_id, scale),
3346            0x1ea1766fd8996bb4,
3347            fidl::encoding::DynamicFlags::empty(),
3348        )
3349    }
3350
3351    fn r#set_opacity(
3352        &self,
3353        mut transform_id: &TransformId,
3354        mut value: f32,
3355    ) -> Result<(), fidl::Error> {
3356        self.client.send::<FlatlandSetOpacityRequest>(
3357            (transform_id, value),
3358            0x3775fc2c00b432fa,
3359            fidl::encoding::DynamicFlags::empty(),
3360        )
3361    }
3362
3363    fn r#set_clip_boundary(
3364        &self,
3365        mut transform_id: &TransformId,
3366        mut rect: Option<&fidl_fuchsia_math::Rect>,
3367    ) -> Result<(), fidl::Error> {
3368        self.client.send::<FlatlandSetClipBoundaryRequest>(
3369            (transform_id, rect),
3370            0x6507843df12222d2,
3371            fidl::encoding::DynamicFlags::empty(),
3372        )
3373    }
3374
3375    fn r#add_child(
3376        &self,
3377        mut parent_transform_id: &TransformId,
3378        mut child_transform_id: &TransformId,
3379    ) -> Result<(), fidl::Error> {
3380        self.client.send::<FlatlandAddChildRequest>(
3381            (parent_transform_id, child_transform_id),
3382            0x67a8abd2f19b1a74,
3383            fidl::encoding::DynamicFlags::empty(),
3384        )
3385    }
3386
3387    fn r#remove_child(
3388        &self,
3389        mut parent_transform_id: &TransformId,
3390        mut child_transform_id: &TransformId,
3391    ) -> Result<(), fidl::Error> {
3392        self.client.send::<FlatlandRemoveChildRequest>(
3393            (parent_transform_id, child_transform_id),
3394            0x41d6cd90b298b67a,
3395            fidl::encoding::DynamicFlags::empty(),
3396        )
3397    }
3398
3399    fn r#replace_children(
3400        &self,
3401        mut parent_transform_id: &TransformId,
3402        mut new_child_transform_ids: &[TransformId],
3403    ) -> Result<(), fidl::Error> {
3404        self.client.send::<FlatlandReplaceChildrenRequest>(
3405            (parent_transform_id, new_child_transform_ids),
3406            0x5b6d86cbbff81316,
3407            fidl::encoding::DynamicFlags::empty(),
3408        )
3409    }
3410
3411    fn r#set_root_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3412        self.client.send::<FlatlandSetRootTransformRequest>(
3413            (transform_id,),
3414            0x6e80ca5bcc566cd8,
3415            fidl::encoding::DynamicFlags::empty(),
3416        )
3417    }
3418
3419    fn r#set_hit_regions(
3420        &self,
3421        mut transform_id: &TransformId,
3422        mut regions: &[HitRegion],
3423    ) -> Result<(), fidl::Error> {
3424        self.client.send::<FlatlandSetHitRegionsRequest>(
3425            (transform_id, regions),
3426            0x31c9d17b07c37ce4,
3427            fidl::encoding::DynamicFlags::empty(),
3428        )
3429    }
3430
3431    fn r#set_infinite_hit_region(
3432        &self,
3433        mut transform_id: &TransformId,
3434        mut hit_test: HitTestInteraction,
3435    ) -> Result<(), fidl::Error> {
3436        self.client.send::<FlatlandSetInfiniteHitRegionRequest>(
3437            (transform_id, hit_test),
3438            0x26d81af852d29562,
3439            fidl::encoding::DynamicFlags::empty(),
3440        )
3441    }
3442
3443    fn r#create_viewport(
3444        &self,
3445        mut viewport_id: &ContentId,
3446        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
3447        mut properties: &ViewportProperties,
3448        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
3449    ) -> Result<(), fidl::Error> {
3450        self.client.send::<FlatlandCreateViewportRequest>(
3451            (viewport_id, &mut token, properties, child_view_watcher),
3452            0x2485fbcab7f943c,
3453            fidl::encoding::DynamicFlags::empty(),
3454        )
3455    }
3456
3457    fn r#create_image(
3458        &self,
3459        mut image_id: &ContentId,
3460        mut import_token: BufferCollectionImportToken,
3461        mut vmo_index: u32,
3462        mut properties: &ImageProperties,
3463    ) -> Result<(), fidl::Error> {
3464        self.client.send::<FlatlandCreateImageRequest>(
3465            (image_id, &mut import_token, vmo_index, properties),
3466            0x26fae823c4ebedad,
3467            fidl::encoding::DynamicFlags::empty(),
3468        )
3469    }
3470
3471    fn r#set_image_sample_region(
3472        &self,
3473        mut image_id: &ContentId,
3474        mut rect: &fidl_fuchsia_math::RectF,
3475    ) -> Result<(), fidl::Error> {
3476        self.client.send::<FlatlandSetImageSampleRegionRequest>(
3477            (image_id, rect),
3478            0x8039391d715eb28,
3479            fidl::encoding::DynamicFlags::empty(),
3480        )
3481    }
3482
3483    fn r#set_image_destination_size(
3484        &self,
3485        mut image_id: &ContentId,
3486        mut size: &fidl_fuchsia_math::SizeU,
3487    ) -> Result<(), fidl::Error> {
3488        self.client.send::<FlatlandSetImageDestinationSizeRequest>(
3489            (image_id, size),
3490            0x766cf99a2ec58446,
3491            fidl::encoding::DynamicFlags::empty(),
3492        )
3493    }
3494
3495    fn r#set_image_blending_function(
3496        &self,
3497        mut image_id: &ContentId,
3498        mut blend_mode: BlendMode,
3499    ) -> Result<(), fidl::Error> {
3500        self.client.send::<FlatlandSetImageBlendingFunctionRequest>(
3501            (image_id, blend_mode),
3502            0x10f5da1356275b7b,
3503            fidl::encoding::DynamicFlags::empty(),
3504        )
3505    }
3506
3507    fn r#set_image_blend_mode(
3508        &self,
3509        mut image_id: &ContentId,
3510        mut blend_mode: BlendMode2,
3511    ) -> Result<(), fidl::Error> {
3512        self.client.send::<FlatlandSetImageBlendModeRequest>(
3513            (image_id, blend_mode),
3514            0x5b1667f130c3de67,
3515            fidl::encoding::DynamicFlags::empty(),
3516        )
3517    }
3518
3519    fn r#set_image_opacity(
3520        &self,
3521        mut image_id: &ContentId,
3522        mut val: f32,
3523    ) -> Result<(), fidl::Error> {
3524        self.client.send::<FlatlandSetImageOpacityRequest>(
3525            (image_id, val),
3526            0x2da9e4ef4c2cff6f,
3527            fidl::encoding::DynamicFlags::empty(),
3528        )
3529    }
3530
3531    fn r#set_image_flip(
3532        &self,
3533        mut image_id: &ContentId,
3534        mut flip: ImageFlip,
3535    ) -> Result<(), fidl::Error> {
3536        self.client.send::<FlatlandSetImageFlipRequest>(
3537            (image_id, flip),
3538            0x21b20f2c14aae6bc,
3539            fidl::encoding::DynamicFlags::empty(),
3540        )
3541    }
3542
3543    fn r#create_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3544        self.client.send::<FlatlandCreateFilledRectRequest>(
3545            (rect_id,),
3546            0x5e62355abc1c4c5d,
3547            fidl::encoding::DynamicFlags::empty(),
3548        )
3549    }
3550
3551    fn r#set_solid_fill(
3552        &self,
3553        mut rect_id: &ContentId,
3554        mut color: &ColorRgba,
3555        mut size: &fidl_fuchsia_math::SizeU,
3556    ) -> Result<(), fidl::Error> {
3557        self.client.send::<FlatlandSetSolidFillRequest>(
3558            (rect_id, color, size),
3559            0x32d6ef41e182dfa5,
3560            fidl::encoding::DynamicFlags::empty(),
3561        )
3562    }
3563
3564    fn r#release_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3565        self.client.send::<FlatlandReleaseFilledRectRequest>(
3566            (rect_id,),
3567            0x7392cabe45618f9b,
3568            fidl::encoding::DynamicFlags::empty(),
3569        )
3570    }
3571
3572    fn r#set_content(
3573        &self,
3574        mut transform_id: &TransformId,
3575        mut content_id: &ContentId,
3576    ) -> Result<(), fidl::Error> {
3577        self.client.send::<FlatlandSetContentRequest>(
3578            (transform_id, content_id),
3579            0x4ed2cfc0ce130862,
3580            fidl::encoding::DynamicFlags::empty(),
3581        )
3582    }
3583
3584    fn r#set_viewport_properties(
3585        &self,
3586        mut viewport_id: &ContentId,
3587        mut properties: &ViewportProperties,
3588    ) -> Result<(), fidl::Error> {
3589        self.client.send::<FlatlandSetViewportPropertiesRequest>(
3590            (viewport_id, properties),
3591            0x66ab67e9608ddb9f,
3592            fidl::encoding::DynamicFlags::empty(),
3593        )
3594    }
3595
3596    fn r#release_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3597        self.client.send::<FlatlandReleaseTransformRequest>(
3598            (transform_id,),
3599            0xab9328419451c22,
3600            fidl::encoding::DynamicFlags::empty(),
3601        )
3602    }
3603
3604    fn r#release_view(&self) -> Result<(), fidl::Error> {
3605        self.client.send::<fidl::encoding::EmptyPayload>(
3606            (),
3607            0x5b35aab9baffecae,
3608            fidl::encoding::DynamicFlags::empty(),
3609        )
3610    }
3611
3612    type ReleaseViewportResponseFut = fidl::client::QueryResponseFut<
3613        fidl_fuchsia_ui_views::ViewportCreationToken,
3614        fidl::encoding::DefaultFuchsiaResourceDialect,
3615    >;
3616    fn r#release_viewport(&self, mut viewport_id: &ContentId) -> Self::ReleaseViewportResponseFut {
3617        fn _decode(
3618            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3619        ) -> Result<fidl_fuchsia_ui_views::ViewportCreationToken, fidl::Error> {
3620            let _response = fidl::client::decode_transaction_body::<
3621                FlatlandReleaseViewportResponse,
3622                fidl::encoding::DefaultFuchsiaResourceDialect,
3623                0xbad474aeb5293f9,
3624            >(_buf?)?;
3625            Ok(_response.token)
3626        }
3627        self.client.send_query_and_decode::<
3628            FlatlandReleaseViewportRequest,
3629            fidl_fuchsia_ui_views::ViewportCreationToken,
3630        >(
3631            (viewport_id,),
3632            0xbad474aeb5293f9,
3633            fidl::encoding::DynamicFlags::empty(),
3634            _decode,
3635        )
3636    }
3637
3638    fn r#release_image(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
3639        self.client.send::<FlatlandReleaseImageRequest>(
3640            (image_id,),
3641            0xb884ffdbc72c111,
3642            fidl::encoding::DynamicFlags::empty(),
3643        )
3644    }
3645
3646    fn r#clear(&self) -> Result<(), fidl::Error> {
3647        self.client.send::<fidl::encoding::EmptyPayload>(
3648            (),
3649            0x4ec8817c02828c3e,
3650            fidl::encoding::DynamicFlags::empty(),
3651        )
3652    }
3653
3654    fn r#set_debug_name(&self, mut name: &str) -> Result<(), fidl::Error> {
3655        self.client.send::<FlatlandSetDebugNameRequest>(
3656            (name,),
3657            0x46a8b397e68a8888,
3658            fidl::encoding::DynamicFlags::empty(),
3659        )
3660    }
3661}
3662
3663pub struct FlatlandEventStream {
3664    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3665}
3666
3667impl std::marker::Unpin for FlatlandEventStream {}
3668
3669impl futures::stream::FusedStream for FlatlandEventStream {
3670    fn is_terminated(&self) -> bool {
3671        self.event_receiver.is_terminated()
3672    }
3673}
3674
3675impl futures::Stream for FlatlandEventStream {
3676    type Item = Result<FlatlandEvent, fidl::Error>;
3677
3678    fn poll_next(
3679        mut self: std::pin::Pin<&mut Self>,
3680        cx: &mut std::task::Context<'_>,
3681    ) -> std::task::Poll<Option<Self::Item>> {
3682        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3683            &mut self.event_receiver,
3684            cx
3685        )?) {
3686            Some(buf) => std::task::Poll::Ready(Some(FlatlandEvent::decode(buf))),
3687            None => std::task::Poll::Ready(None),
3688        }
3689    }
3690}
3691
3692#[derive(Debug)]
3693pub enum FlatlandEvent {
3694    OnNextFrameBegin { values: OnNextFrameBeginValues },
3695    OnFramePresented { frame_presented_info: fidl_fuchsia_scenic_scheduling::FramePresentedInfo },
3696    OnError { error: FlatlandError },
3697}
3698
3699impl FlatlandEvent {
3700    #[allow(irrefutable_let_patterns)]
3701    pub fn into_on_next_frame_begin(self) -> Option<OnNextFrameBeginValues> {
3702        if let FlatlandEvent::OnNextFrameBegin { values } = self { Some((values)) } else { None }
3703    }
3704    #[allow(irrefutable_let_patterns)]
3705    pub fn into_on_frame_presented(
3706        self,
3707    ) -> Option<fidl_fuchsia_scenic_scheduling::FramePresentedInfo> {
3708        if let FlatlandEvent::OnFramePresented { frame_presented_info } = self {
3709            Some((frame_presented_info))
3710        } else {
3711            None
3712        }
3713    }
3714    #[allow(irrefutable_let_patterns)]
3715    pub fn into_on_error(self) -> Option<FlatlandError> {
3716        if let FlatlandEvent::OnError { error } = self { Some((error)) } else { None }
3717    }
3718
3719    /// Decodes a message buffer as a [`FlatlandEvent`].
3720    fn decode(
3721        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3722    ) -> Result<FlatlandEvent, fidl::Error> {
3723        let (bytes, _handles) = buf.split_mut();
3724        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3725        debug_assert_eq!(tx_header.tx_id, 0);
3726        match tx_header.ordinal {
3727            0x10f69a5cdeece84a => {
3728                let mut out = fidl::new_empty!(
3729                    FlatlandOnNextFrameBeginRequest,
3730                    fidl::encoding::DefaultFuchsiaResourceDialect
3731                );
3732                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandOnNextFrameBeginRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3733                Ok((FlatlandEvent::OnNextFrameBegin { values: out.values }))
3734            }
3735            0x56e43e1a5f30216d => {
3736                let mut out = fidl::new_empty!(
3737                    FlatlandOnFramePresentedRequest,
3738                    fidl::encoding::DefaultFuchsiaResourceDialect
3739                );
3740                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandOnFramePresentedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3741                Ok((FlatlandEvent::OnFramePresented {
3742                    frame_presented_info: out.frame_presented_info,
3743                }))
3744            }
3745            0x1ebf39e90cd8b8d => {
3746                let mut out = fidl::new_empty!(
3747                    FlatlandOnErrorRequest,
3748                    fidl::encoding::DefaultFuchsiaResourceDialect
3749                );
3750                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandOnErrorRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3751                Ok((FlatlandEvent::OnError { error: out.error }))
3752            }
3753            _ => Err(fidl::Error::UnknownOrdinal {
3754                ordinal: tx_header.ordinal,
3755                protocol_name: <FlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3756            }),
3757        }
3758    }
3759}
3760
3761/// A Stream of incoming requests for fuchsia.ui.composition/Flatland.
3762pub struct FlatlandRequestStream {
3763    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3764    is_terminated: bool,
3765}
3766
3767impl std::marker::Unpin for FlatlandRequestStream {}
3768
3769impl futures::stream::FusedStream for FlatlandRequestStream {
3770    fn is_terminated(&self) -> bool {
3771        self.is_terminated
3772    }
3773}
3774
3775impl fidl::endpoints::RequestStream for FlatlandRequestStream {
3776    type Protocol = FlatlandMarker;
3777    type ControlHandle = FlatlandControlHandle;
3778
3779    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3780        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3781    }
3782
3783    fn control_handle(&self) -> Self::ControlHandle {
3784        FlatlandControlHandle { inner: self.inner.clone() }
3785    }
3786
3787    fn into_inner(
3788        self,
3789    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3790    {
3791        (self.inner, self.is_terminated)
3792    }
3793
3794    fn from_inner(
3795        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3796        is_terminated: bool,
3797    ) -> Self {
3798        Self { inner, is_terminated }
3799    }
3800}
3801
3802impl futures::Stream for FlatlandRequestStream {
3803    type Item = Result<FlatlandRequest, fidl::Error>;
3804
3805    fn poll_next(
3806        mut self: std::pin::Pin<&mut Self>,
3807        cx: &mut std::task::Context<'_>,
3808    ) -> std::task::Poll<Option<Self::Item>> {
3809        let this = &mut *self;
3810        if this.inner.check_shutdown(cx) {
3811            this.is_terminated = true;
3812            return std::task::Poll::Ready(None);
3813        }
3814        if this.is_terminated {
3815            panic!("polled FlatlandRequestStream after completion");
3816        }
3817        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3818            |bytes, handles| {
3819                match this.inner.channel().read_etc(cx, bytes, handles) {
3820                    std::task::Poll::Ready(Ok(())) => {}
3821                    std::task::Poll::Pending => return std::task::Poll::Pending,
3822                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3823                        this.is_terminated = true;
3824                        return std::task::Poll::Ready(None);
3825                    }
3826                    std::task::Poll::Ready(Err(e)) => {
3827                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3828                            e.into(),
3829                        ))));
3830                    }
3831                }
3832
3833                // A message has been received from the channel
3834                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3835
3836                std::task::Poll::Ready(Some(match header.ordinal {
3837                    0x245e1ac080772c8 => {
3838                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3839                        let mut req = fidl::new_empty!(
3840                            TrustedFlatlandReleaseImageImmediatelyRequest,
3841                            fidl::encoding::DefaultFuchsiaResourceDialect
3842                        );
3843                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TrustedFlatlandReleaseImageImmediatelyRequest>(&header, _body_bytes, handles, &mut req)?;
3844                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3845                        Ok(FlatlandRequest::ReleaseImageImmediately {
3846                            image_id: req.image_id,
3847
3848                            control_handle,
3849                        })
3850                    }
3851                    0x50acc2aa1f0acec7 => {
3852                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3853                        let mut req = fidl::new_empty!(
3854                            FlatlandPresentRequest,
3855                            fidl::encoding::DefaultFuchsiaResourceDialect
3856                        );
3857                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandPresentRequest>(&header, _body_bytes, handles, &mut req)?;
3858                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3859                        Ok(FlatlandRequest::Present { args: req.args, control_handle })
3860                    }
3861                    0x504686eb25864780 => {
3862                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3863                        let mut req = fidl::new_empty!(
3864                            FlatlandCreateViewRequest,
3865                            fidl::encoding::DefaultFuchsiaResourceDialect
3866                        );
3867                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateViewRequest>(&header, _body_bytes, handles, &mut req)?;
3868                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3869                        Ok(FlatlandRequest::CreateView {
3870                            token: req.token,
3871                            parent_viewport_watcher: req.parent_viewport_watcher,
3872
3873                            control_handle,
3874                        })
3875                    }
3876                    0x340a3a40c2fdbd5e => {
3877                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3878                        let mut req = fidl::new_empty!(
3879                            FlatlandCreateView2Request,
3880                            fidl::encoding::DefaultFuchsiaResourceDialect
3881                        );
3882                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateView2Request>(&header, _body_bytes, handles, &mut req)?;
3883                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3884                        Ok(FlatlandRequest::CreateView2 {
3885                            token: req.token,
3886                            view_identity: req.view_identity,
3887                            protocols: req.protocols,
3888                            parent_viewport_watcher: req.parent_viewport_watcher,
3889
3890                            control_handle,
3891                        })
3892                    }
3893                    0x5e042a4d3de3efb0 => {
3894                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3895                        let mut req = fidl::new_empty!(
3896                            FlatlandCreateTransformRequest,
3897                            fidl::encoding::DefaultFuchsiaResourceDialect
3898                        );
3899                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateTransformRequest>(&header, _body_bytes, handles, &mut req)?;
3900                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3901                        Ok(FlatlandRequest::CreateTransform {
3902                            transform_id: req.transform_id,
3903
3904                            control_handle,
3905                        })
3906                    }
3907                    0x7863398291fba346 => {
3908                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3909                        let mut req = fidl::new_empty!(
3910                            FlatlandSetTranslationRequest,
3911                            fidl::encoding::DefaultFuchsiaResourceDialect
3912                        );
3913                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetTranslationRequest>(&header, _body_bytes, handles, &mut req)?;
3914                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3915                        Ok(FlatlandRequest::SetTranslation {
3916                            transform_id: req.transform_id,
3917                            translation: req.translation,
3918
3919                            control_handle,
3920                        })
3921                    }
3922                    0x4915310bc4928edc => {
3923                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3924                        let mut req = fidl::new_empty!(
3925                            FlatlandSetOrientationRequest,
3926                            fidl::encoding::DefaultFuchsiaResourceDialect
3927                        );
3928                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetOrientationRequest>(&header, _body_bytes, handles, &mut req)?;
3929                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3930                        Ok(FlatlandRequest::SetOrientation {
3931                            transform_id: req.transform_id,
3932                            orientation: req.orientation,
3933
3934                            control_handle,
3935                        })
3936                    }
3937                    0x1ea1766fd8996bb4 => {
3938                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3939                        let mut req = fidl::new_empty!(
3940                            FlatlandSetScaleRequest,
3941                            fidl::encoding::DefaultFuchsiaResourceDialect
3942                        );
3943                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetScaleRequest>(&header, _body_bytes, handles, &mut req)?;
3944                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3945                        Ok(FlatlandRequest::SetScale {
3946                            transform_id: req.transform_id,
3947                            scale: req.scale,
3948
3949                            control_handle,
3950                        })
3951                    }
3952                    0x3775fc2c00b432fa => {
3953                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3954                        let mut req = fidl::new_empty!(
3955                            FlatlandSetOpacityRequest,
3956                            fidl::encoding::DefaultFuchsiaResourceDialect
3957                        );
3958                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetOpacityRequest>(&header, _body_bytes, handles, &mut req)?;
3959                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3960                        Ok(FlatlandRequest::SetOpacity {
3961                            transform_id: req.transform_id,
3962                            value: req.value,
3963
3964                            control_handle,
3965                        })
3966                    }
3967                    0x6507843df12222d2 => {
3968                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3969                        let mut req = fidl::new_empty!(
3970                            FlatlandSetClipBoundaryRequest,
3971                            fidl::encoding::DefaultFuchsiaResourceDialect
3972                        );
3973                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetClipBoundaryRequest>(&header, _body_bytes, handles, &mut req)?;
3974                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3975                        Ok(FlatlandRequest::SetClipBoundary {
3976                            transform_id: req.transform_id,
3977                            rect: req.rect,
3978
3979                            control_handle,
3980                        })
3981                    }
3982                    0x67a8abd2f19b1a74 => {
3983                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3984                        let mut req = fidl::new_empty!(
3985                            FlatlandAddChildRequest,
3986                            fidl::encoding::DefaultFuchsiaResourceDialect
3987                        );
3988                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandAddChildRequest>(&header, _body_bytes, handles, &mut req)?;
3989                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3990                        Ok(FlatlandRequest::AddChild {
3991                            parent_transform_id: req.parent_transform_id,
3992                            child_transform_id: req.child_transform_id,
3993
3994                            control_handle,
3995                        })
3996                    }
3997                    0x41d6cd90b298b67a => {
3998                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3999                        let mut req = fidl::new_empty!(
4000                            FlatlandRemoveChildRequest,
4001                            fidl::encoding::DefaultFuchsiaResourceDialect
4002                        );
4003                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandRemoveChildRequest>(&header, _body_bytes, handles, &mut req)?;
4004                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4005                        Ok(FlatlandRequest::RemoveChild {
4006                            parent_transform_id: req.parent_transform_id,
4007                            child_transform_id: req.child_transform_id,
4008
4009                            control_handle,
4010                        })
4011                    }
4012                    0x5b6d86cbbff81316 => {
4013                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4014                        let mut req = fidl::new_empty!(
4015                            FlatlandReplaceChildrenRequest,
4016                            fidl::encoding::DefaultFuchsiaResourceDialect
4017                        );
4018                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReplaceChildrenRequest>(&header, _body_bytes, handles, &mut req)?;
4019                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4020                        Ok(FlatlandRequest::ReplaceChildren {
4021                            parent_transform_id: req.parent_transform_id,
4022                            new_child_transform_ids: req.new_child_transform_ids,
4023
4024                            control_handle,
4025                        })
4026                    }
4027                    0x6e80ca5bcc566cd8 => {
4028                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4029                        let mut req = fidl::new_empty!(
4030                            FlatlandSetRootTransformRequest,
4031                            fidl::encoding::DefaultFuchsiaResourceDialect
4032                        );
4033                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetRootTransformRequest>(&header, _body_bytes, handles, &mut req)?;
4034                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4035                        Ok(FlatlandRequest::SetRootTransform {
4036                            transform_id: req.transform_id,
4037
4038                            control_handle,
4039                        })
4040                    }
4041                    0x31c9d17b07c37ce4 => {
4042                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4043                        let mut req = fidl::new_empty!(
4044                            FlatlandSetHitRegionsRequest,
4045                            fidl::encoding::DefaultFuchsiaResourceDialect
4046                        );
4047                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetHitRegionsRequest>(&header, _body_bytes, handles, &mut req)?;
4048                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4049                        Ok(FlatlandRequest::SetHitRegions {
4050                            transform_id: req.transform_id,
4051                            regions: req.regions,
4052
4053                            control_handle,
4054                        })
4055                    }
4056                    0x26d81af852d29562 => {
4057                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4058                        let mut req = fidl::new_empty!(
4059                            FlatlandSetInfiniteHitRegionRequest,
4060                            fidl::encoding::DefaultFuchsiaResourceDialect
4061                        );
4062                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetInfiniteHitRegionRequest>(&header, _body_bytes, handles, &mut req)?;
4063                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4064                        Ok(FlatlandRequest::SetInfiniteHitRegion {
4065                            transform_id: req.transform_id,
4066                            hit_test: req.hit_test,
4067
4068                            control_handle,
4069                        })
4070                    }
4071                    0x2485fbcab7f943c => {
4072                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4073                        let mut req = fidl::new_empty!(
4074                            FlatlandCreateViewportRequest,
4075                            fidl::encoding::DefaultFuchsiaResourceDialect
4076                        );
4077                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateViewportRequest>(&header, _body_bytes, handles, &mut req)?;
4078                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4079                        Ok(FlatlandRequest::CreateViewport {
4080                            viewport_id: req.viewport_id,
4081                            token: req.token,
4082                            properties: req.properties,
4083                            child_view_watcher: req.child_view_watcher,
4084
4085                            control_handle,
4086                        })
4087                    }
4088                    0x26fae823c4ebedad => {
4089                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4090                        let mut req = fidl::new_empty!(
4091                            FlatlandCreateImageRequest,
4092                            fidl::encoding::DefaultFuchsiaResourceDialect
4093                        );
4094                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateImageRequest>(&header, _body_bytes, handles, &mut req)?;
4095                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4096                        Ok(FlatlandRequest::CreateImage {
4097                            image_id: req.image_id,
4098                            import_token: req.import_token,
4099                            vmo_index: req.vmo_index,
4100                            properties: req.properties,
4101
4102                            control_handle,
4103                        })
4104                    }
4105                    0x8039391d715eb28 => {
4106                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4107                        let mut req = fidl::new_empty!(
4108                            FlatlandSetImageSampleRegionRequest,
4109                            fidl::encoding::DefaultFuchsiaResourceDialect
4110                        );
4111                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageSampleRegionRequest>(&header, _body_bytes, handles, &mut req)?;
4112                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4113                        Ok(FlatlandRequest::SetImageSampleRegion {
4114                            image_id: req.image_id,
4115                            rect: req.rect,
4116
4117                            control_handle,
4118                        })
4119                    }
4120                    0x766cf99a2ec58446 => {
4121                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4122                        let mut req = fidl::new_empty!(
4123                            FlatlandSetImageDestinationSizeRequest,
4124                            fidl::encoding::DefaultFuchsiaResourceDialect
4125                        );
4126                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageDestinationSizeRequest>(&header, _body_bytes, handles, &mut req)?;
4127                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4128                        Ok(FlatlandRequest::SetImageDestinationSize {
4129                            image_id: req.image_id,
4130                            size: req.size,
4131
4132                            control_handle,
4133                        })
4134                    }
4135                    0x10f5da1356275b7b => {
4136                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4137                        let mut req = fidl::new_empty!(
4138                            FlatlandSetImageBlendingFunctionRequest,
4139                            fidl::encoding::DefaultFuchsiaResourceDialect
4140                        );
4141                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageBlendingFunctionRequest>(&header, _body_bytes, handles, &mut req)?;
4142                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4143                        Ok(FlatlandRequest::SetImageBlendingFunction {
4144                            image_id: req.image_id,
4145                            blend_mode: req.blend_mode,
4146
4147                            control_handle,
4148                        })
4149                    }
4150                    0x5b1667f130c3de67 => {
4151                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4152                        let mut req = fidl::new_empty!(
4153                            FlatlandSetImageBlendModeRequest,
4154                            fidl::encoding::DefaultFuchsiaResourceDialect
4155                        );
4156                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageBlendModeRequest>(&header, _body_bytes, handles, &mut req)?;
4157                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4158                        Ok(FlatlandRequest::SetImageBlendMode {
4159                            image_id: req.image_id,
4160                            blend_mode: req.blend_mode,
4161
4162                            control_handle,
4163                        })
4164                    }
4165                    0x2da9e4ef4c2cff6f => {
4166                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4167                        let mut req = fidl::new_empty!(
4168                            FlatlandSetImageOpacityRequest,
4169                            fidl::encoding::DefaultFuchsiaResourceDialect
4170                        );
4171                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageOpacityRequest>(&header, _body_bytes, handles, &mut req)?;
4172                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4173                        Ok(FlatlandRequest::SetImageOpacity {
4174                            image_id: req.image_id,
4175                            val: req.val,
4176
4177                            control_handle,
4178                        })
4179                    }
4180                    0x21b20f2c14aae6bc => {
4181                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4182                        let mut req = fidl::new_empty!(
4183                            FlatlandSetImageFlipRequest,
4184                            fidl::encoding::DefaultFuchsiaResourceDialect
4185                        );
4186                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageFlipRequest>(&header, _body_bytes, handles, &mut req)?;
4187                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4188                        Ok(FlatlandRequest::SetImageFlip {
4189                            image_id: req.image_id,
4190                            flip: req.flip,
4191
4192                            control_handle,
4193                        })
4194                    }
4195                    0x5e62355abc1c4c5d => {
4196                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4197                        let mut req = fidl::new_empty!(
4198                            FlatlandCreateFilledRectRequest,
4199                            fidl::encoding::DefaultFuchsiaResourceDialect
4200                        );
4201                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateFilledRectRequest>(&header, _body_bytes, handles, &mut req)?;
4202                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4203                        Ok(FlatlandRequest::CreateFilledRect {
4204                            rect_id: req.rect_id,
4205
4206                            control_handle,
4207                        })
4208                    }
4209                    0x32d6ef41e182dfa5 => {
4210                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4211                        let mut req = fidl::new_empty!(
4212                            FlatlandSetSolidFillRequest,
4213                            fidl::encoding::DefaultFuchsiaResourceDialect
4214                        );
4215                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetSolidFillRequest>(&header, _body_bytes, handles, &mut req)?;
4216                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4217                        Ok(FlatlandRequest::SetSolidFill {
4218                            rect_id: req.rect_id,
4219                            color: req.color,
4220                            size: req.size,
4221
4222                            control_handle,
4223                        })
4224                    }
4225                    0x7392cabe45618f9b => {
4226                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4227                        let mut req = fidl::new_empty!(
4228                            FlatlandReleaseFilledRectRequest,
4229                            fidl::encoding::DefaultFuchsiaResourceDialect
4230                        );
4231                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseFilledRectRequest>(&header, _body_bytes, handles, &mut req)?;
4232                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4233                        Ok(FlatlandRequest::ReleaseFilledRect {
4234                            rect_id: req.rect_id,
4235
4236                            control_handle,
4237                        })
4238                    }
4239                    0x4ed2cfc0ce130862 => {
4240                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4241                        let mut req = fidl::new_empty!(
4242                            FlatlandSetContentRequest,
4243                            fidl::encoding::DefaultFuchsiaResourceDialect
4244                        );
4245                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetContentRequest>(&header, _body_bytes, handles, &mut req)?;
4246                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4247                        Ok(FlatlandRequest::SetContent {
4248                            transform_id: req.transform_id,
4249                            content_id: req.content_id,
4250
4251                            control_handle,
4252                        })
4253                    }
4254                    0x66ab67e9608ddb9f => {
4255                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4256                        let mut req = fidl::new_empty!(
4257                            FlatlandSetViewportPropertiesRequest,
4258                            fidl::encoding::DefaultFuchsiaResourceDialect
4259                        );
4260                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetViewportPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
4261                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4262                        Ok(FlatlandRequest::SetViewportProperties {
4263                            viewport_id: req.viewport_id,
4264                            properties: req.properties,
4265
4266                            control_handle,
4267                        })
4268                    }
4269                    0xab9328419451c22 => {
4270                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4271                        let mut req = fidl::new_empty!(
4272                            FlatlandReleaseTransformRequest,
4273                            fidl::encoding::DefaultFuchsiaResourceDialect
4274                        );
4275                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseTransformRequest>(&header, _body_bytes, handles, &mut req)?;
4276                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4277                        Ok(FlatlandRequest::ReleaseTransform {
4278                            transform_id: req.transform_id,
4279
4280                            control_handle,
4281                        })
4282                    }
4283                    0x5b35aab9baffecae => {
4284                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4285                        let mut req = fidl::new_empty!(
4286                            fidl::encoding::EmptyPayload,
4287                            fidl::encoding::DefaultFuchsiaResourceDialect
4288                        );
4289                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4290                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4291                        Ok(FlatlandRequest::ReleaseView { control_handle })
4292                    }
4293                    0xbad474aeb5293f9 => {
4294                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4295                        let mut req = fidl::new_empty!(
4296                            FlatlandReleaseViewportRequest,
4297                            fidl::encoding::DefaultFuchsiaResourceDialect
4298                        );
4299                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseViewportRequest>(&header, _body_bytes, handles, &mut req)?;
4300                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4301                        Ok(FlatlandRequest::ReleaseViewport {
4302                            viewport_id: req.viewport_id,
4303
4304                            responder: FlatlandReleaseViewportResponder {
4305                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4306                                tx_id: header.tx_id,
4307                            },
4308                        })
4309                    }
4310                    0xb884ffdbc72c111 => {
4311                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4312                        let mut req = fidl::new_empty!(
4313                            FlatlandReleaseImageRequest,
4314                            fidl::encoding::DefaultFuchsiaResourceDialect
4315                        );
4316                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseImageRequest>(&header, _body_bytes, handles, &mut req)?;
4317                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4318                        Ok(FlatlandRequest::ReleaseImage { image_id: req.image_id, control_handle })
4319                    }
4320                    0x4ec8817c02828c3e => {
4321                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4322                        let mut req = fidl::new_empty!(
4323                            fidl::encoding::EmptyPayload,
4324                            fidl::encoding::DefaultFuchsiaResourceDialect
4325                        );
4326                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4327                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4328                        Ok(FlatlandRequest::Clear { control_handle })
4329                    }
4330                    0x46a8b397e68a8888 => {
4331                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4332                        let mut req = fidl::new_empty!(
4333                            FlatlandSetDebugNameRequest,
4334                            fidl::encoding::DefaultFuchsiaResourceDialect
4335                        );
4336                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetDebugNameRequest>(&header, _body_bytes, handles, &mut req)?;
4337                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4338                        Ok(FlatlandRequest::SetDebugName { name: req.name, control_handle })
4339                    }
4340                    _ => Err(fidl::Error::UnknownOrdinal {
4341                        ordinal: header.ordinal,
4342                        protocol_name:
4343                            <FlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4344                    }),
4345                }))
4346            },
4347        )
4348    }
4349}
4350
4351/// Each Flatland instance contains a Graph, which consists of a set of objects, and the
4352/// relationships between those objects. The client can specify a subset of those objects
4353/// (specifically, the directed acyclic graph starting at the root transform) to be presented as
4354/// content to some kind of output -- usually, a display.
4355///
4356/// Flatland Graphs are both hierarchical, and distributed. Graphs from different Flatland instances
4357/// may be connected together, allowing multiple processes to be involved in authoring content for a
4358/// particular output.
4359///
4360/// All functions in this protocol are feed-forward. The operations they represent are not fully
4361/// executed until [`Present`] is called.
4362#[derive(Debug)]
4363pub enum FlatlandRequest {
4364    /// Releases an image immediately, without waiting for the next present.
4365    ReleaseImageImmediately {
4366        image_id: ContentId,
4367        control_handle: FlatlandControlHandle,
4368    },
4369    /// Complete execution of all feed-forward operations.
4370    ///
4371    /// If executing an operation produces an error (e.g., CreateTransform(0)), an [`OnError`] event
4372    /// is emitted. Operations that produce errors are ignored and the channel is closed.
4373    ///
4374    /// If the execution is completed successfully, [`OnNextFrameBegin`] emits NO_ERROR along
4375    /// with other valid fields.
4376    ///
4377    /// The client may only call [`Present`] when they have a non-zero number of present credits,
4378    /// which are tracked by the server. The server may increment the number of credits when it
4379    /// fires the [`OnNextFrameBegin`] event, which informs the client when it receives additional
4380    /// present credits. Each [`Present`] call uses one present credit and decrements the server
4381    /// count by one. If the client calls [`Present`] with no present credits, the server will
4382    /// return a `NO_PRESENTS_REMAINING` error.
4383    ///
4384    /// The client should assume that prior to receiving any [`OnNextFrameBegin`] events, they have
4385    /// one present credit.
4386    ///
4387    /// Every [`Present`] call results in one [`OnNextFrameBegin`] event, and one
4388    /// [`OnFramePresented`] event, typically in that order.
4389    ///
4390    /// When the commands flushed by [`Present`] make it to display, an [`OnFramePresented`] event
4391    /// is fired. This event includes information pertaining to all [`Present`]s that had content
4392    /// that were part of that frame.
4393    ///
4394    /// See [`fuchsia.ui.composition/PresentArgs`] documentation above for more detailed information
4395    /// on what arguments are passed in and their role.
4396    Present {
4397        args: PresentArgs,
4398        control_handle: FlatlandControlHandle,
4399    },
4400    /// Two Flatland instances may be connected in a parent-child relationship. The parent endpoint
4401    /// is held in a Viewport, and the child endpoint is held in a View. The parent Flatland
4402    /// instance that creates a Viewport has control over how the child's View is integrated into
4403    /// its own View.
4404    ///
4405    /// The lifecycle of a parent-child connection starts with two endpoints of a channel object:
4406    /// a ViewportCreationToken and a ViewCreationToken. Out-of-band protocols pass the
4407    /// ViewportCreationToken to the parent, which calls [`CreateViewport`], and the
4408    /// ViewCreationToken to the child, which calls [`CreateView`].
4409    ///
4410    /// Only nodes connected to the Root Transform in this Flatland instance will be rendered into
4411    /// the parent's Viewport.
4412    ///
4413    /// Calling [`CreateView`] a second time will disconnect the Root Transform from the existing
4414    /// parent's Viewport, and attach it to a new parent's Viewport. In other words, each View can
4415    /// only have one parent.
4416    ///
4417    /// This function is queued, meaning that the Root Transform will not be attached to the
4418    /// parent Viewport until [`Present`] is called. However, clients will receive information
4419    /// through their ParentViewportWatcher (e.g., LayoutInfo) immediately after calling this
4420    /// function, even if they have not called [`Present`] or [`SetRootTransform`]. This allows
4421    /// clients to wait for layout information from their parent before calling [`Present`].
4422    ///
4423    /// Any illegal operations on ParentViewportWatcher will cause both ParentViewportWatcher
4424    /// channel and this Flatland channel to be torn down.
4425    ///
4426    /// Lifecycle note. The lifetime of the ParentViewportWatcher channel is bound by the peer
4427    /// ViewportCreationToken. When the ViewportCreationToken dies, this ParentViewportWatcher
4428    /// channel is destroyed.
4429    ///
4430    /// Views and subgraphs of Views created using `CreateView` will not be represented in the
4431    /// ViewTree, and hence will not be able to participate in any ViewTree-dependent interactions
4432    /// such as touch, mouse or focus.
4433    /// The Flatland protocol provides no way for Views in the subgraph of a View created with
4434    /// `CreateView` to know that they are excluded from the ViewTree.
4435    CreateView {
4436        token: fidl_fuchsia_ui_views::ViewCreationToken,
4437        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4438        control_handle: FlatlandControlHandle,
4439    },
4440    /// Identical to [`CreateView`], except it allows association of View identity (ViewRef) and
4441    /// view-bound protocols.
4442    CreateView2 {
4443        token: fidl_fuchsia_ui_views::ViewCreationToken,
4444        view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
4445        protocols: ViewBoundProtocols,
4446        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4447        control_handle: FlatlandControlHandle,
4448    },
4449    /// Creates a new Transform node. Transforms are a hierarchical piece of a Flatland graph. They
4450    /// can have children, and can reference Content. A sub-graph represented by a Transform and its
4451    /// descendants can be rendered to a display.
4452    ///
4453    /// Transforms are kept alive, even when released, as long as they are children of either an
4454    /// unreleased Transform, or the Root Transform.
4455    ///
4456    /// Each Transform can have a single piece of attached Content. Common types of Content include
4457    /// bitmaps, asynchronous streams of images, and Viewports to Views hosted in other Flatland
4458    /// instances.
4459    ///
4460    /// Transforms have attributes. Child Transforms inherit the combined attributes of their
4461    /// parents. Content attached to a Transform is also affected by that Transform's attributes.
4462    ///
4463    /// When a sub-graph of Transforms is rendered, Content will be rendered back-to-front, starting
4464    /// with the Content on the root transform, and continuing recursively through all of its child
4465    /// Transforms in the order the children were added. See [`AddChild`] for more information.
4466    ///
4467    /// Zero is not a valid transform id. All other values are valid, assuming they are not already
4468    /// in use (see [`ReleaseTransform`] for more details).
4469    CreateTransform {
4470        transform_id: TransformId,
4471        control_handle: FlatlandControlHandle,
4472    },
4473    /// All Transform objects support all attributes.
4474    ///
4475    /// Geometric attributes are applied in the following order:
4476    /// 1. Scale (relative to the parent transform's coordinate space)
4477    /// 2. Orientation (relative to the parent transform's coordinate space)
4478    /// 3. Translation (relative to the parent transforms's coordinate space,
4479    ///    unaffected by scale applied to the current transform).
4480    /// 4. Clipping (relative to the current transform's coordinate space)
4481    ///
4482    /// The effects of each of these attributes are cumulative. This means the transform's position
4483    /// in the view space, and its clip boundary, will be calculated based on that chain of
4484    /// geometric attributes going up to the root transform.
4485    ///
4486    /// For instance, in a nested hierarchy such as the following:
4487    ///     [Root-Transform -> Transform1 -> Transform2 -> CurrentTransform]
4488    /// If Transform1 is translated by [2,0] and Transform2 is translated by [0,1] then the
4489    /// view-space position of CurrentTransform will be [2,1].
4490    ///
4491    /// Sets the translation on a Transform. The order of geometric attribute application is
4492    /// addressed above.
4493    SetTranslation {
4494        transform_id: TransformId,
4495        translation: fidl_fuchsia_math::Vec_,
4496        control_handle: FlatlandControlHandle,
4497    },
4498    /// Sets the orientation on a Transform. The order of geometric attribute application is
4499    /// addressed in the documentation for [`SetTranslation`]. In Flatland, the +X axis is
4500    /// to the right and the +Y axis is down. There is no notion of a Z axis. CCW is defined
4501    /// from the POV of the user, as if a skeuomorphoic clock is displayed on the screen.
4502    SetOrientation {
4503        transform_id: TransformId,
4504        orientation: Orientation,
4505        control_handle: FlatlandControlHandle,
4506    },
4507    /// Sets the scale on a transform. The order of geometric attribute application is
4508    /// addressed above. The (x,y) values in the VecF |scale| refer to the scale factor in the
4509    /// x-axis (width) and y-axis (height) respectively. Scale values must be normal 32-bit
4510    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29
4511    SetScale {
4512        transform_id: TransformId,
4513        scale: fidl_fuchsia_math::VecF,
4514        control_handle: FlatlandControlHandle,
4515    },
4516    /// Sets an opacity in linear space to be applied to a transform and its descendents,
4517    /// which include other transforms and content. Opacity values must be in the range
4518    /// of [0.0, 1.0], where 0.0 is completely transparent and 1.0 is completely opaque.
4519    /// Attempting to call this function with values outside that range will result in
4520    /// an error. A transform's opacity value is multiplied with that of its parent. This
4521    /// effect works differently from group opacity. Using group opacity, child nodes are
4522    /// rendered together first, and then have the parent's opacity applied as a post-effect.
4523    /// Here, opacity is applied to each child individually. This may result in a very
4524    /// different effect.
4525    SetOpacity {
4526        transform_id: TransformId,
4527        value: f32,
4528        control_handle: FlatlandControlHandle,
4529    },
4530    /// Sets the bounds, expressed in the local coordinate space of the transform, that
4531    /// constrains the region that content attached to this transform can be rendered to.
4532    /// If the content's area exceeds the clip bounds, the area outside the bounds will
4533    /// not be rendered. These bounds are valid for all children of this transform node as
4534    /// well, which includes nested Flatland instances and their node hierarchies.
4535    /// If a child transform attempts to set clip bounds larger than that of its parent,
4536    /// it will be clipped to the parent's clip bounds. The default state is for a transform
4537    /// to be unclipped, meaning it will not have any bounds placed on its render region.
4538    /// The clip width/height must be positive. Negative values will result in an error.
4539    /// Passing in an empty box to the |rect| parameter will remove the clip bounds.
4540    SetClipBoundary {
4541        transform_id: TransformId,
4542        rect: Option<Box<fidl_fuchsia_math::Rect>>,
4543        control_handle: FlatlandControlHandle,
4544    },
4545    /// Adds a child Transform to a parent Transform. The new child Transform,
4546    /// and any Content attached to it or its children, will be rendered on top
4547    /// of the parent's Content, as well as any previously added children.
4548    ///
4549    /// The caller must ensure that `child_transform_id` is valid and that there
4550    /// are no repetitions.  Sending a repeated `child_transform_id` over
4551    /// multiple calls will result in session closure.
4552    AddChild {
4553        parent_transform_id: TransformId,
4554        child_transform_id: TransformId,
4555        control_handle: FlatlandControlHandle,
4556    },
4557    /// Removes a child Transform from a parent Transform.
4558    RemoveChild {
4559        parent_transform_id: TransformId,
4560        child_transform_id: TransformId,
4561        control_handle: FlatlandControlHandle,
4562    },
4563    /// Removes all child Transforms from a parent Transform and replaces them
4564    /// with the new child transforms in `new_child_transform_ids`.  The caller
4565    /// must ensure that all `TransformId` values in `new_child_transform_ids`
4566    /// are valid and that there are no repetitions.  Sending a repeated
4567    /// `TransformId` in `new_child_transform_ids` will result in session
4568    /// closure.
4569    ReplaceChildren {
4570        parent_transform_id: TransformId,
4571        new_child_transform_ids: Vec<TransformId>,
4572        control_handle: FlatlandControlHandle,
4573    },
4574    /// Sets the Root Transform for the graph.
4575    ///
4576    /// The sub-graph defined by the Root Transform and its children will be rendered as View
4577    /// in the connected parent's Viewport (see [`CreateView`]). Any parents of the Root Transform
4578    /// in this Graph will be ignored.
4579    ///
4580    /// The Root Transform, and all children of the Root Transform, are kept alive if they are
4581    /// released (see [`ReleaseTransform`] for more details).
4582    ///
4583    /// There is only ever one Root. Since 0 is not a valid transform id (see [`CreateTransform`]),
4584    /// calling SetRootTransform(0) clears the current Root, destroying any previously released
4585    /// objects that are not referenced by the new root.
4586    ///
4587    /// Note that every View has a clip boundary equivalent to its logical size. Anything outside
4588    /// that clip boundary will not be rendered. Hence, the Root Transform has a useful coordinate
4589    /// space of (0, 0) to (logical_size.width, logical_size.height), where (0, 0) is the upper left
4590    /// corner.
4591    ///
4592    /// Setting the root transform installs a full screen hit region on the root transform. Clients
4593    /// may remove this hit region if they don't want users to be able to interact with the root
4594    /// transform's content. For additional details on hit regions, see the [`SetHitRegions`]
4595    /// documentation.
4596    ///
4597    /// Default hit region rules
4598    ///
4599    ///   A default hit region follows these rules:
4600    ///   - When [`SetRootTransform`](T) is called, T receives a maximal hit region, covering the
4601    ///   entire view.
4602    ///   - If [`SetHitRegions`] is called on T, either before or after [`SetRootTransform`](T),
4603    ///   then no default hit region is active and the client specified hit regions are used.
4604    ///   - If a transform is no longer the root transform, i.e., [`SetRootTransform`](U) is
4605    ///   called, then the original transform no longer has its default hit region.
4606    ///   - Clients can remove or modify the root transform's hit regions the same way they would
4607    ///   reset any other transform's hit regions, by calling [`SetHitRegions`] with the appropriate
4608    ///   vector.
4609    SetRootTransform {
4610        transform_id: TransformId,
4611        control_handle: FlatlandControlHandle,
4612    },
4613    /// Sets the interactive areas for a Transform. By default, Content is not interactive; hit
4614    /// regions must be placed for a user to interact with the Content in a View. Because hit
4615    /// regions are described in the Flatland protocol, a Flatland instance can synchronize Content
4616    /// and hit regions.
4617    ///
4618    /// Each hit region is placed in the coordinate space of the owning Transform, and may or may
4619    /// not interact with different types of hit testing, depending on its [`HitTestInteraction`]
4620    /// type. When there are multiple hit regions that intersect with a hit test, the precedence
4621    /// rules given below dictate which hit region has interacted with the hit test. Only Transforms
4622    /// that transitively connect to the root Transform have their hit regions interact with a hit
4623    /// test.
4624    ///
4625    /// Calling this function replaces any previous values set on this Transform. To reset a
4626    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
4627    ///
4628    /// Note that root transforms get a default hit region installed by Flatland. For more details,
4629    /// see the [`SetRootTransform`] documentation.
4630    ///
4631    /// Precedence rules
4632    ///   Within a Transform, if multiple hit regions overlap, the hit test examines each
4633    ///   intersecting hit region for a possible interaction. Thus, for a regular hit test R and an
4634    ///   accessibility hit test A, where R and A both intersect two hit regions D ([`DEFAULT`]) and
4635    ///   S ([`SEMANTICALLY_INVISIBLE`]) on the same Transform, (1) R interacts with both D and S,
4636    ///   and (2) A only interacts with D. Generally, hit regions that overlap in a single Transform
4637    ///   can cause confusing behavior.
4638    ///
4639    ///   Within a View, for a given hit test, the front-most Transform's hit regions take
4640    ///   precedence over those behind. This follows the expected reverse "render order" of
4641    ///   Transforms (described in [`CreateTransform`]), where a user expects to interact with
4642    ///   Content that is visible, or front-most.
4643    ///
4644    ///   Across Flatland instances, for a given hit test, the front-most instance's front-most
4645    ///   Transform's hit regions take precedence over those behind. This follows the expected
4646    ///   reverse "render order" of views, where a user expects to interact with the View that is
4647    ///   visible, or front-most. For example, if a child View owns Content that is rendered over
4648    ///   the parent View, the user expects to interact with the child's Content.
4649    SetHitRegions {
4650        transform_id: TransformId,
4651        regions: Vec<HitRegion>,
4652        control_handle: FlatlandControlHandle,
4653    },
4654    /// Identical to [`SetHitRegions`], except the hit region associated with [`transform_id`]
4655    /// covers an infinite region. The hit region is invariant against translation, scaling, and
4656    /// orientation of the Transform.
4657    ///
4658    /// An infinite hit region is still limited in extent by the View's clip boundary, just like a
4659    /// finite hit region.
4660    ///
4661    /// Calling this function replaces any previous values set on this Transform. To reset a
4662    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
4663    SetInfiniteHitRegion {
4664        transform_id: TransformId,
4665        hit_test: HitTestInteraction,
4666        control_handle: FlatlandControlHandle,
4667    },
4668    /// The Viewport and View pair, together, represent the connection between two Flatland
4669    /// instances. The Viewport is created in the parent, and the View is created in the child. The
4670    /// parent has control over how the child's View is integrated into its own View.
4671    ///
4672    /// Any illegal operations on ChildViewWatcher will cause both ChildViewWatcher channel and this
4673    /// Flatland channel to be torn down.
4674    ///
4675    /// `ViewportProperties` must have logical_size set. This is the initial size that will drive
4676    /// the layout of the child. The logical_size is also used as the default Content size, but
4677    /// subsequent changes to the logical_size will have no effect on the Content size.
4678    ///
4679    /// `ViewportProperties` may have inset field not set. In that case, the default value of
4680    /// (0, 0, 0, 0) is used.
4681    ///
4682    /// The logical_size must have positive X and Y components.
4683    ///
4684    /// Zero is not a valid ContentId. All other values are valid, assuming they are not already
4685    /// in use for another piece of Content (see [`ReleaseViewport`] for more details).
4686    ///
4687    /// Lifecycle note. The lifetime of the ChildViewWatcher channel is bound by the peer
4688    /// ViewCreationToken. When the ViewCreationToken dies, this ChildViewWatcher channel is
4689    /// destroyed.
4690    CreateViewport {
4691        viewport_id: ContentId,
4692        token: fidl_fuchsia_ui_views::ViewportCreationToken,
4693        properties: ViewportProperties,
4694        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
4695        control_handle: FlatlandControlHandle,
4696    },
4697    /// An Image is a bitmap backed by a specific VMO in a BufferCollection.
4698    ///
4699    /// Image creation requires an allocated BufferCollection registered with Allocator. This
4700    /// function will fail unless all clients of the specified BufferCollection have set their
4701    /// constraints.
4702    ///
4703    /// The Image must reference a valid VMO index and must have ImageProperties that fall within
4704    /// the constraints specified by the backing BufferCollection (i.e. width and height within a
4705    /// valid range, etc.)
4706    ///
4707    /// Zero is not a valid Image id. All other values are valid, assuming they are not already in
4708    /// use for another piece of Content (see [`ReleaseImage`] for more details).
4709    CreateImage {
4710        image_id: ContentId,
4711        import_token: BufferCollectionImportToken,
4712        vmo_index: u32,
4713        properties: ImageProperties,
4714        control_handle: FlatlandControlHandle,
4715    },
4716    /// This function is used to determine the region (in texel space) of an image that will be used
4717    /// by Flatland when rendering. The image to be sampled is referenced by [`image_id`] and the
4718    /// sample region is specified by [`rect`] which itself is comprised of an origin point (x,y) as
4719    /// well as a width and height, in unnormalized coordinates. It is illegal to call this function
4720    /// on non-image content, or to sample a region outside of the texel space of the image. In
4721    /// other words, the region specifed by [`rect`] must not exceed the ranges (0, image_width) and
4722    /// (0, image_height). If (rect.x + rect.width > image_width) or (rect.y + rect.height >
4723    /// image_height) or if any of the values are negative, this will result in an error.
4724    ///
4725    /// If this method is not called, the default sample region is the rectangle with origin at
4726    /// (0, 0) and width and height set at ImageProperties from [`CreateImage`].
4727    SetImageSampleRegion {
4728        image_id: ContentId,
4729        rect: fidl_fuchsia_math::RectF,
4730        control_handle: FlatlandControlHandle,
4731    },
4732    /// The content size for an Image is the size of the rectangle in the parent's logical
4733    /// coordinate space that the image occupies. This combined with the global translation of the
4734    /// transform it is attached to determines the size and location of where the content is
4735    /// rendered on the display.
4736    ///
4737    /// If this method is not called, the default image destination size is the width and height set
4738    /// at ImageProperties from [`CreateImage`]. The destination size will be affected by scaling if
4739    /// [`SetScale`] is used on the attached Transform or its parents.
4740    SetImageDestinationSize {
4741        image_id: ContentId,
4742        size: fidl_fuchsia_math::SizeU,
4743        control_handle: FlatlandControlHandle,
4744    },
4745    /// Determines the blend function to use when rendering the content specified by
4746    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
4747    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
4748    /// that are available, please refer to the BlendMode enum. If this function is not called, then
4749    /// the default blendmode is BlendMode::SRC.
4750    SetImageBlendingFunction {
4751        image_id: ContentId,
4752        blend_mode: BlendMode,
4753        control_handle: FlatlandControlHandle,
4754    },
4755    /// Determines the blend function to use when rendering the content specified by
4756    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
4757    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
4758    /// that are available, please refer to the BlendMode2 enum. If this function is not called,
4759    /// the default blendmode is BlendMode2::REPLACE.
4760    SetImageBlendMode {
4761        image_id: ContentId,
4762        blend_mode: BlendMode2,
4763        control_handle: FlatlandControlHandle,
4764    },
4765    /// Sets an opacity in linear space to be applied to a flatland image. Opacity values must
4766    /// be in the range [0.0, 1.0].
4767    SetImageOpacity {
4768        image_id: ContentId,
4769        val: f32,
4770        control_handle: FlatlandControlHandle,
4771    },
4772    /// Sets the image flip to be applied to a flatland image. This call must be performed after a
4773    /// successful |CreateImage| call. If an invalid |image_id| is supplied, the channel will be
4774    /// closed due to FlatlandError::BAD_OPERATION. This flip will be applied to the Image before
4775    /// parent Transform Orientations. If this function is not called, then the default flip value
4776    /// is ImageFlip::NONE.
4777    SetImageFlip {
4778        image_id: ContentId,
4779        flip: ImageFlip,
4780        control_handle: FlatlandControlHandle,
4781    },
4782    /// Creates a solid-color rectangle. By default a filled-rect does not have a defined
4783    /// color or size. It is necessary to call |SetSolidFill| to specify a color and size
4784    /// before a filled rect can be used for rendering. Not doing so will result the
4785    CreateFilledRect {
4786        rect_id: ContentId,
4787        control_handle: FlatlandControlHandle,
4788    },
4789    /// Defines the color and size of a filled rect. |rect_id| must refer to content that
4790    /// was created via a call to CreateFilledRect. The color is not premultiplied. Color values
4791    /// must be within the range [0,1] inclusive, and normal 32-bit
4792    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29. Values
4793    /// that do not conform to these specifications will cause the channel to close.
4794    /// The rectangle's top left corner will be at (0, 0) in its transform's coordinate space.
4795    /// Hence, its bottom right corner will be at (size.width, size.height).
4796    SetSolidFill {
4797        rect_id: ContentId,
4798        color: ColorRgba,
4799        size: fidl_fuchsia_math::SizeU,
4800        control_handle: FlatlandControlHandle,
4801    },
4802    /// Automatically garbage collects the rectangle when it is no longer needed for
4803    /// rendering. |rect_id| must have been instantiated with a call to
4804    /// |CreateFilledRect|. Once released, the ID immediately goes out of scope and is free
4805    /// to be used again.
4806    ReleaseFilledRect {
4807        rect_id: ContentId,
4808        control_handle: FlatlandControlHandle,
4809    },
4810    /// Setting a piece of Content on a Transform makes that Content visible in the render tree as
4811    /// long as the Transform is visible from the root Transform. The Content will be rendered
4812    /// before, and therefore "behind", any Content attached to the descendants of the Transform.
4813    ///
4814    /// Because each Transform can have, at most, a single piece of Content on it, calling this
4815    /// function on a Transform that already has Content will replace that Content.
4816    ///
4817    /// A Content may be set on more than one Transform.
4818    ///
4819    /// Calling this function with a Content id of 0 will remove any Content currently on the
4820    /// Transform.
4821    SetContent {
4822        transform_id: TransformId,
4823        content_id: ContentId,
4824        control_handle: FlatlandControlHandle,
4825    },
4826    /// Transforms are usually sufficient to change how Content is presented. Viewports, however,
4827    /// have special properties that are not part of the Transform hierarchy. Those properties can
4828    /// be set using this function.
4829    SetViewportProperties {
4830        viewport_id: ContentId,
4831        properties: ViewportProperties,
4832        control_handle: FlatlandControlHandle,
4833    },
4834    /// Released Transforms will be garbage collected by the system once they are no longer
4835    /// necessary for rendering. For Transforms, this means there is no path from any unreleased
4836    /// Transform to the newly-released Transform.
4837    ///
4838    /// Once released, the id immediately goes out of scope for future function calls and can be
4839    /// reused when creating new Transforms.
4840    ///
4841    /// It is an error to call functions with a released id (unless that id has been reused to
4842    /// construct a new Transform).
4843    ReleaseTransform {
4844        transform_id: TransformId,
4845        control_handle: FlatlandControlHandle,
4846    },
4847    ReleaseView {
4848        control_handle: FlatlandControlHandle,
4849    },
4850    /// Releases a Viewport from the scene, even if the Viewport is still connected to a Transform.
4851    /// Unlike other resources, Viewports are garbage collected by the system during the next
4852    /// [`Present`] because a removed Viewport is guaranteed to provide no renderable content.
4853    ///
4854    /// Use SetContent(transform_id, 0) to clean up references to released Viewports.
4855    ///
4856    /// Despite having a return type, this function is still feed-forward like [`CreateView`] and
4857    /// requires a call to [`Present`] to be executed. The ViewportCreationToken will be returned
4858    /// after the presented operations have been executed.
4859    ReleaseViewport {
4860        viewport_id: ContentId,
4861        responder: FlatlandReleaseViewportResponder,
4862    },
4863    /// Released Images will be garbage collected by the system once they are no longer necessary
4864    /// for rendering. For Images, this means the Image is no longer attached to any Transform and
4865    /// any pending rendering that references the Image is complete.
4866    ///
4867    /// Use SetContent(transform_id, 0) to clean up references to released Images.
4868    ///
4869    /// Once released, the id immediately goes out of scope for future function calls and can be
4870    /// reused when creating new Images.
4871    ///
4872    /// It is an error to call functions with a released id (unless that id has been reused to
4873    /// construct a new Image).
4874    ReleaseImage {
4875        image_id: ContentId,
4876        control_handle: FlatlandControlHandle,
4877    },
4878    /// This function will reset all state on this interface. This includes destroying all existing
4879    /// View and Viewports without returning the associated Token to the caller.
4880    Clear {
4881        control_handle: FlatlandControlHandle,
4882    },
4883    /// Set debug name of the current client that can be used by Flatland to print as a prefix to
4884    /// logs to help client distinguish what is theirs. [`name`] can be an arbitrary string, but the
4885    /// current process name (see fsl::GetCurrentProcessName()) is a good default.
4886    SetDebugName {
4887        name: String,
4888        control_handle: FlatlandControlHandle,
4889    },
4890}
4891
4892impl FlatlandRequest {
4893    #[allow(irrefutable_let_patterns)]
4894    pub fn into_release_image_immediately(self) -> Option<(ContentId, FlatlandControlHandle)> {
4895        if let FlatlandRequest::ReleaseImageImmediately { image_id, control_handle } = self {
4896            Some((image_id, control_handle))
4897        } else {
4898            None
4899        }
4900    }
4901
4902    #[allow(irrefutable_let_patterns)]
4903    pub fn into_present(self) -> Option<(PresentArgs, FlatlandControlHandle)> {
4904        if let FlatlandRequest::Present { args, control_handle } = self {
4905            Some((args, control_handle))
4906        } else {
4907            None
4908        }
4909    }
4910
4911    #[allow(irrefutable_let_patterns)]
4912    pub fn into_create_view(
4913        self,
4914    ) -> Option<(
4915        fidl_fuchsia_ui_views::ViewCreationToken,
4916        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4917        FlatlandControlHandle,
4918    )> {
4919        if let FlatlandRequest::CreateView { token, parent_viewport_watcher, control_handle } = self
4920        {
4921            Some((token, parent_viewport_watcher, control_handle))
4922        } else {
4923            None
4924        }
4925    }
4926
4927    #[allow(irrefutable_let_patterns)]
4928    pub fn into_create_view2(
4929        self,
4930    ) -> Option<(
4931        fidl_fuchsia_ui_views::ViewCreationToken,
4932        fidl_fuchsia_ui_views::ViewIdentityOnCreation,
4933        ViewBoundProtocols,
4934        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4935        FlatlandControlHandle,
4936    )> {
4937        if let FlatlandRequest::CreateView2 {
4938            token,
4939            view_identity,
4940            protocols,
4941            parent_viewport_watcher,
4942            control_handle,
4943        } = self
4944        {
4945            Some((token, view_identity, protocols, parent_viewport_watcher, control_handle))
4946        } else {
4947            None
4948        }
4949    }
4950
4951    #[allow(irrefutable_let_patterns)]
4952    pub fn into_create_transform(self) -> Option<(TransformId, FlatlandControlHandle)> {
4953        if let FlatlandRequest::CreateTransform { transform_id, control_handle } = self {
4954            Some((transform_id, control_handle))
4955        } else {
4956            None
4957        }
4958    }
4959
4960    #[allow(irrefutable_let_patterns)]
4961    pub fn into_set_translation(
4962        self,
4963    ) -> Option<(TransformId, fidl_fuchsia_math::Vec_, FlatlandControlHandle)> {
4964        if let FlatlandRequest::SetTranslation { transform_id, translation, control_handle } = self
4965        {
4966            Some((transform_id, translation, control_handle))
4967        } else {
4968            None
4969        }
4970    }
4971
4972    #[allow(irrefutable_let_patterns)]
4973    pub fn into_set_orientation(self) -> Option<(TransformId, Orientation, FlatlandControlHandle)> {
4974        if let FlatlandRequest::SetOrientation { transform_id, orientation, control_handle } = self
4975        {
4976            Some((transform_id, orientation, control_handle))
4977        } else {
4978            None
4979        }
4980    }
4981
4982    #[allow(irrefutable_let_patterns)]
4983    pub fn into_set_scale(
4984        self,
4985    ) -> Option<(TransformId, fidl_fuchsia_math::VecF, FlatlandControlHandle)> {
4986        if let FlatlandRequest::SetScale { transform_id, scale, control_handle } = self {
4987            Some((transform_id, scale, control_handle))
4988        } else {
4989            None
4990        }
4991    }
4992
4993    #[allow(irrefutable_let_patterns)]
4994    pub fn into_set_opacity(self) -> Option<(TransformId, f32, FlatlandControlHandle)> {
4995        if let FlatlandRequest::SetOpacity { transform_id, value, control_handle } = self {
4996            Some((transform_id, value, control_handle))
4997        } else {
4998            None
4999        }
5000    }
5001
5002    #[allow(irrefutable_let_patterns)]
5003    pub fn into_set_clip_boundary(
5004        self,
5005    ) -> Option<(TransformId, Option<Box<fidl_fuchsia_math::Rect>>, FlatlandControlHandle)> {
5006        if let FlatlandRequest::SetClipBoundary { transform_id, rect, control_handle } = self {
5007            Some((transform_id, rect, control_handle))
5008        } else {
5009            None
5010        }
5011    }
5012
5013    #[allow(irrefutable_let_patterns)]
5014    pub fn into_add_child(self) -> Option<(TransformId, TransformId, FlatlandControlHandle)> {
5015        if let FlatlandRequest::AddChild {
5016            parent_transform_id,
5017            child_transform_id,
5018            control_handle,
5019        } = self
5020        {
5021            Some((parent_transform_id, child_transform_id, control_handle))
5022        } else {
5023            None
5024        }
5025    }
5026
5027    #[allow(irrefutable_let_patterns)]
5028    pub fn into_remove_child(self) -> Option<(TransformId, TransformId, FlatlandControlHandle)> {
5029        if let FlatlandRequest::RemoveChild {
5030            parent_transform_id,
5031            child_transform_id,
5032            control_handle,
5033        } = self
5034        {
5035            Some((parent_transform_id, child_transform_id, control_handle))
5036        } else {
5037            None
5038        }
5039    }
5040
5041    #[allow(irrefutable_let_patterns)]
5042    pub fn into_replace_children(
5043        self,
5044    ) -> Option<(TransformId, Vec<TransformId>, FlatlandControlHandle)> {
5045        if let FlatlandRequest::ReplaceChildren {
5046            parent_transform_id,
5047            new_child_transform_ids,
5048            control_handle,
5049        } = self
5050        {
5051            Some((parent_transform_id, new_child_transform_ids, control_handle))
5052        } else {
5053            None
5054        }
5055    }
5056
5057    #[allow(irrefutable_let_patterns)]
5058    pub fn into_set_root_transform(self) -> Option<(TransformId, FlatlandControlHandle)> {
5059        if let FlatlandRequest::SetRootTransform { transform_id, control_handle } = self {
5060            Some((transform_id, control_handle))
5061        } else {
5062            None
5063        }
5064    }
5065
5066    #[allow(irrefutable_let_patterns)]
5067    pub fn into_set_hit_regions(
5068        self,
5069    ) -> Option<(TransformId, Vec<HitRegion>, FlatlandControlHandle)> {
5070        if let FlatlandRequest::SetHitRegions { transform_id, regions, control_handle } = self {
5071            Some((transform_id, regions, control_handle))
5072        } else {
5073            None
5074        }
5075    }
5076
5077    #[allow(irrefutable_let_patterns)]
5078    pub fn into_set_infinite_hit_region(
5079        self,
5080    ) -> Option<(TransformId, HitTestInteraction, FlatlandControlHandle)> {
5081        if let FlatlandRequest::SetInfiniteHitRegion { transform_id, hit_test, control_handle } =
5082            self
5083        {
5084            Some((transform_id, hit_test, control_handle))
5085        } else {
5086            None
5087        }
5088    }
5089
5090    #[allow(irrefutable_let_patterns)]
5091    pub fn into_create_viewport(
5092        self,
5093    ) -> Option<(
5094        ContentId,
5095        fidl_fuchsia_ui_views::ViewportCreationToken,
5096        ViewportProperties,
5097        fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5098        FlatlandControlHandle,
5099    )> {
5100        if let FlatlandRequest::CreateViewport {
5101            viewport_id,
5102            token,
5103            properties,
5104            child_view_watcher,
5105            control_handle,
5106        } = self
5107        {
5108            Some((viewport_id, token, properties, child_view_watcher, control_handle))
5109        } else {
5110            None
5111        }
5112    }
5113
5114    #[allow(irrefutable_let_patterns)]
5115    pub fn into_create_image(
5116        self,
5117    ) -> Option<(ContentId, BufferCollectionImportToken, u32, ImageProperties, FlatlandControlHandle)>
5118    {
5119        if let FlatlandRequest::CreateImage {
5120            image_id,
5121            import_token,
5122            vmo_index,
5123            properties,
5124            control_handle,
5125        } = self
5126        {
5127            Some((image_id, import_token, vmo_index, properties, control_handle))
5128        } else {
5129            None
5130        }
5131    }
5132
5133    #[allow(irrefutable_let_patterns)]
5134    pub fn into_set_image_sample_region(
5135        self,
5136    ) -> Option<(ContentId, fidl_fuchsia_math::RectF, FlatlandControlHandle)> {
5137        if let FlatlandRequest::SetImageSampleRegion { image_id, rect, control_handle } = self {
5138            Some((image_id, rect, control_handle))
5139        } else {
5140            None
5141        }
5142    }
5143
5144    #[allow(irrefutable_let_patterns)]
5145    pub fn into_set_image_destination_size(
5146        self,
5147    ) -> Option<(ContentId, fidl_fuchsia_math::SizeU, FlatlandControlHandle)> {
5148        if let FlatlandRequest::SetImageDestinationSize { image_id, size, control_handle } = self {
5149            Some((image_id, size, control_handle))
5150        } else {
5151            None
5152        }
5153    }
5154
5155    #[allow(irrefutable_let_patterns)]
5156    pub fn into_set_image_blending_function(
5157        self,
5158    ) -> Option<(ContentId, BlendMode, FlatlandControlHandle)> {
5159        if let FlatlandRequest::SetImageBlendingFunction { image_id, blend_mode, control_handle } =
5160            self
5161        {
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_blend_mode(
5170        self,
5171    ) -> Option<(ContentId, BlendMode2, FlatlandControlHandle)> {
5172        if let FlatlandRequest::SetImageBlendMode { image_id, blend_mode, control_handle } = self {
5173            Some((image_id, blend_mode, control_handle))
5174        } else {
5175            None
5176        }
5177    }
5178
5179    #[allow(irrefutable_let_patterns)]
5180    pub fn into_set_image_opacity(self) -> Option<(ContentId, f32, FlatlandControlHandle)> {
5181        if let FlatlandRequest::SetImageOpacity { image_id, val, control_handle } = self {
5182            Some((image_id, val, control_handle))
5183        } else {
5184            None
5185        }
5186    }
5187
5188    #[allow(irrefutable_let_patterns)]
5189    pub fn into_set_image_flip(self) -> Option<(ContentId, ImageFlip, FlatlandControlHandle)> {
5190        if let FlatlandRequest::SetImageFlip { image_id, flip, control_handle } = self {
5191            Some((image_id, flip, control_handle))
5192        } else {
5193            None
5194        }
5195    }
5196
5197    #[allow(irrefutable_let_patterns)]
5198    pub fn into_create_filled_rect(self) -> Option<(ContentId, FlatlandControlHandle)> {
5199        if let FlatlandRequest::CreateFilledRect { rect_id, control_handle } = self {
5200            Some((rect_id, control_handle))
5201        } else {
5202            None
5203        }
5204    }
5205
5206    #[allow(irrefutable_let_patterns)]
5207    pub fn into_set_solid_fill(
5208        self,
5209    ) -> Option<(ContentId, ColorRgba, fidl_fuchsia_math::SizeU, FlatlandControlHandle)> {
5210        if let FlatlandRequest::SetSolidFill { rect_id, color, size, control_handle } = self {
5211            Some((rect_id, color, size, control_handle))
5212        } else {
5213            None
5214        }
5215    }
5216
5217    #[allow(irrefutable_let_patterns)]
5218    pub fn into_release_filled_rect(self) -> Option<(ContentId, FlatlandControlHandle)> {
5219        if let FlatlandRequest::ReleaseFilledRect { rect_id, control_handle } = self {
5220            Some((rect_id, control_handle))
5221        } else {
5222            None
5223        }
5224    }
5225
5226    #[allow(irrefutable_let_patterns)]
5227    pub fn into_set_content(self) -> Option<(TransformId, ContentId, FlatlandControlHandle)> {
5228        if let FlatlandRequest::SetContent { transform_id, content_id, control_handle } = self {
5229            Some((transform_id, content_id, control_handle))
5230        } else {
5231            None
5232        }
5233    }
5234
5235    #[allow(irrefutable_let_patterns)]
5236    pub fn into_set_viewport_properties(
5237        self,
5238    ) -> Option<(ContentId, ViewportProperties, FlatlandControlHandle)> {
5239        if let FlatlandRequest::SetViewportProperties { viewport_id, properties, control_handle } =
5240            self
5241        {
5242            Some((viewport_id, properties, control_handle))
5243        } else {
5244            None
5245        }
5246    }
5247
5248    #[allow(irrefutable_let_patterns)]
5249    pub fn into_release_transform(self) -> Option<(TransformId, FlatlandControlHandle)> {
5250        if let FlatlandRequest::ReleaseTransform { transform_id, control_handle } = self {
5251            Some((transform_id, control_handle))
5252        } else {
5253            None
5254        }
5255    }
5256
5257    #[allow(irrefutable_let_patterns)]
5258    pub fn into_release_view(self) -> Option<(FlatlandControlHandle)> {
5259        if let FlatlandRequest::ReleaseView { control_handle } = self {
5260            Some((control_handle))
5261        } else {
5262            None
5263        }
5264    }
5265
5266    #[allow(irrefutable_let_patterns)]
5267    pub fn into_release_viewport(self) -> Option<(ContentId, FlatlandReleaseViewportResponder)> {
5268        if let FlatlandRequest::ReleaseViewport { viewport_id, responder } = self {
5269            Some((viewport_id, responder))
5270        } else {
5271            None
5272        }
5273    }
5274
5275    #[allow(irrefutable_let_patterns)]
5276    pub fn into_release_image(self) -> Option<(ContentId, FlatlandControlHandle)> {
5277        if let FlatlandRequest::ReleaseImage { image_id, control_handle } = self {
5278            Some((image_id, control_handle))
5279        } else {
5280            None
5281        }
5282    }
5283
5284    #[allow(irrefutable_let_patterns)]
5285    pub fn into_clear(self) -> Option<(FlatlandControlHandle)> {
5286        if let FlatlandRequest::Clear { control_handle } = self {
5287            Some((control_handle))
5288        } else {
5289            None
5290        }
5291    }
5292
5293    #[allow(irrefutable_let_patterns)]
5294    pub fn into_set_debug_name(self) -> Option<(String, FlatlandControlHandle)> {
5295        if let FlatlandRequest::SetDebugName { name, control_handle } = self {
5296            Some((name, control_handle))
5297        } else {
5298            None
5299        }
5300    }
5301
5302    /// Name of the method defined in FIDL
5303    pub fn method_name(&self) -> &'static str {
5304        match *self {
5305            FlatlandRequest::ReleaseImageImmediately { .. } => "release_image_immediately",
5306            FlatlandRequest::Present { .. } => "present",
5307            FlatlandRequest::CreateView { .. } => "create_view",
5308            FlatlandRequest::CreateView2 { .. } => "create_view2",
5309            FlatlandRequest::CreateTransform { .. } => "create_transform",
5310            FlatlandRequest::SetTranslation { .. } => "set_translation",
5311            FlatlandRequest::SetOrientation { .. } => "set_orientation",
5312            FlatlandRequest::SetScale { .. } => "set_scale",
5313            FlatlandRequest::SetOpacity { .. } => "set_opacity",
5314            FlatlandRequest::SetClipBoundary { .. } => "set_clip_boundary",
5315            FlatlandRequest::AddChild { .. } => "add_child",
5316            FlatlandRequest::RemoveChild { .. } => "remove_child",
5317            FlatlandRequest::ReplaceChildren { .. } => "replace_children",
5318            FlatlandRequest::SetRootTransform { .. } => "set_root_transform",
5319            FlatlandRequest::SetHitRegions { .. } => "set_hit_regions",
5320            FlatlandRequest::SetInfiniteHitRegion { .. } => "set_infinite_hit_region",
5321            FlatlandRequest::CreateViewport { .. } => "create_viewport",
5322            FlatlandRequest::CreateImage { .. } => "create_image",
5323            FlatlandRequest::SetImageSampleRegion { .. } => "set_image_sample_region",
5324            FlatlandRequest::SetImageDestinationSize { .. } => "set_image_destination_size",
5325            FlatlandRequest::SetImageBlendingFunction { .. } => "set_image_blending_function",
5326            FlatlandRequest::SetImageBlendMode { .. } => "set_image_blend_mode",
5327            FlatlandRequest::SetImageOpacity { .. } => "set_image_opacity",
5328            FlatlandRequest::SetImageFlip { .. } => "set_image_flip",
5329            FlatlandRequest::CreateFilledRect { .. } => "create_filled_rect",
5330            FlatlandRequest::SetSolidFill { .. } => "set_solid_fill",
5331            FlatlandRequest::ReleaseFilledRect { .. } => "release_filled_rect",
5332            FlatlandRequest::SetContent { .. } => "set_content",
5333            FlatlandRequest::SetViewportProperties { .. } => "set_viewport_properties",
5334            FlatlandRequest::ReleaseTransform { .. } => "release_transform",
5335            FlatlandRequest::ReleaseView { .. } => "release_view",
5336            FlatlandRequest::ReleaseViewport { .. } => "release_viewport",
5337            FlatlandRequest::ReleaseImage { .. } => "release_image",
5338            FlatlandRequest::Clear { .. } => "clear",
5339            FlatlandRequest::SetDebugName { .. } => "set_debug_name",
5340        }
5341    }
5342}
5343
5344#[derive(Debug, Clone)]
5345pub struct FlatlandControlHandle {
5346    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5347}
5348
5349impl fidl::endpoints::ControlHandle for FlatlandControlHandle {
5350    fn shutdown(&self) {
5351        self.inner.shutdown()
5352    }
5353
5354    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5355        self.inner.shutdown_with_epitaph(status)
5356    }
5357
5358    fn is_closed(&self) -> bool {
5359        self.inner.channel().is_closed()
5360    }
5361    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5362        self.inner.channel().on_closed()
5363    }
5364
5365    #[cfg(target_os = "fuchsia")]
5366    fn signal_peer(
5367        &self,
5368        clear_mask: zx::Signals,
5369        set_mask: zx::Signals,
5370    ) -> Result<(), zx_status::Status> {
5371        use fidl::Peered;
5372        self.inner.channel().signal_peer(clear_mask, set_mask)
5373    }
5374}
5375
5376impl FlatlandControlHandle {
5377    pub fn send_on_next_frame_begin(
5378        &self,
5379        mut values: &OnNextFrameBeginValues,
5380    ) -> Result<(), fidl::Error> {
5381        self.inner.send::<FlatlandOnNextFrameBeginRequest>(
5382            (values,),
5383            0,
5384            0x10f69a5cdeece84a,
5385            fidl::encoding::DynamicFlags::empty(),
5386        )
5387    }
5388
5389    pub fn send_on_frame_presented(
5390        &self,
5391        mut frame_presented_info: &fidl_fuchsia_scenic_scheduling::FramePresentedInfo,
5392    ) -> Result<(), fidl::Error> {
5393        self.inner.send::<FlatlandOnFramePresentedRequest>(
5394            (frame_presented_info,),
5395            0,
5396            0x56e43e1a5f30216d,
5397            fidl::encoding::DynamicFlags::empty(),
5398        )
5399    }
5400
5401    pub fn send_on_error(&self, mut error: FlatlandError) -> Result<(), fidl::Error> {
5402        self.inner.send::<FlatlandOnErrorRequest>(
5403            (error,),
5404            0,
5405            0x1ebf39e90cd8b8d,
5406            fidl::encoding::DynamicFlags::empty(),
5407        )
5408    }
5409}
5410
5411#[must_use = "FIDL methods require a response to be sent"]
5412#[derive(Debug)]
5413pub struct FlatlandReleaseViewportResponder {
5414    control_handle: std::mem::ManuallyDrop<FlatlandControlHandle>,
5415    tx_id: u32,
5416}
5417
5418/// Set the the channel to be shutdown (see [`FlatlandControlHandle::shutdown`])
5419/// if the responder is dropped without sending a response, so that the client
5420/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5421impl std::ops::Drop for FlatlandReleaseViewportResponder {
5422    fn drop(&mut self) {
5423        self.control_handle.shutdown();
5424        // Safety: drops once, never accessed again
5425        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5426    }
5427}
5428
5429impl fidl::endpoints::Responder for FlatlandReleaseViewportResponder {
5430    type ControlHandle = FlatlandControlHandle;
5431
5432    fn control_handle(&self) -> &FlatlandControlHandle {
5433        &self.control_handle
5434    }
5435
5436    fn drop_without_shutdown(mut self) {
5437        // Safety: drops once, never accessed again due to mem::forget
5438        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5439        // Prevent Drop from running (which would shut down the channel)
5440        std::mem::forget(self);
5441    }
5442}
5443
5444impl FlatlandReleaseViewportResponder {
5445    /// Sends a response to the FIDL transaction.
5446    ///
5447    /// Sets the channel to shutdown if an error occurs.
5448    pub fn send(
5449        self,
5450        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5451    ) -> Result<(), fidl::Error> {
5452        let _result = self.send_raw(token);
5453        if _result.is_err() {
5454            self.control_handle.shutdown();
5455        }
5456        self.drop_without_shutdown();
5457        _result
5458    }
5459
5460    /// Similar to "send" but does not shutdown the channel if an error occurs.
5461    pub fn send_no_shutdown_on_err(
5462        self,
5463        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5464    ) -> Result<(), fidl::Error> {
5465        let _result = self.send_raw(token);
5466        self.drop_without_shutdown();
5467        _result
5468    }
5469
5470    fn send_raw(
5471        &self,
5472        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5473    ) -> Result<(), fidl::Error> {
5474        self.control_handle.inner.send::<FlatlandReleaseViewportResponse>(
5475            (&mut token,),
5476            self.tx_id,
5477            0xbad474aeb5293f9,
5478            fidl::encoding::DynamicFlags::empty(),
5479        )
5480    }
5481}
5482
5483#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5484pub struct FlatlandDisplayMarker;
5485
5486impl fidl::endpoints::ProtocolMarker for FlatlandDisplayMarker {
5487    type Proxy = FlatlandDisplayProxy;
5488    type RequestStream = FlatlandDisplayRequestStream;
5489    #[cfg(target_os = "fuchsia")]
5490    type SynchronousProxy = FlatlandDisplaySynchronousProxy;
5491
5492    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.FlatlandDisplay";
5493}
5494impl fidl::endpoints::DiscoverableProtocolMarker for FlatlandDisplayMarker {}
5495
5496pub trait FlatlandDisplayProxyInterface: Send + Sync {
5497    fn r#set_content(
5498        &self,
5499        token: fidl_fuchsia_ui_views::ViewportCreationToken,
5500        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5501    ) -> Result<(), fidl::Error>;
5502    fn r#set_device_pixel_ratio(
5503        &self,
5504        device_pixel_ratio: &fidl_fuchsia_math::VecF,
5505    ) -> Result<(), fidl::Error>;
5506}
5507#[derive(Debug)]
5508#[cfg(target_os = "fuchsia")]
5509pub struct FlatlandDisplaySynchronousProxy {
5510    client: fidl::client::sync::Client,
5511}
5512
5513#[cfg(target_os = "fuchsia")]
5514impl fidl::endpoints::SynchronousProxy for FlatlandDisplaySynchronousProxy {
5515    type Proxy = FlatlandDisplayProxy;
5516    type Protocol = FlatlandDisplayMarker;
5517
5518    fn from_channel(inner: fidl::Channel) -> Self {
5519        Self::new(inner)
5520    }
5521
5522    fn into_channel(self) -> fidl::Channel {
5523        self.client.into_channel()
5524    }
5525
5526    fn as_channel(&self) -> &fidl::Channel {
5527        self.client.as_channel()
5528    }
5529}
5530
5531#[cfg(target_os = "fuchsia")]
5532impl FlatlandDisplaySynchronousProxy {
5533    pub fn new(channel: fidl::Channel) -> Self {
5534        Self { client: fidl::client::sync::Client::new(channel) }
5535    }
5536
5537    pub fn into_channel(self) -> fidl::Channel {
5538        self.client.into_channel()
5539    }
5540
5541    /// Waits until an event arrives and returns it. It is safe for other
5542    /// threads to make concurrent requests while waiting for an event.
5543    pub fn wait_for_event(
5544        &self,
5545        deadline: zx::MonotonicInstant,
5546    ) -> Result<FlatlandDisplayEvent, fidl::Error> {
5547        FlatlandDisplayEvent::decode(self.client.wait_for_event::<FlatlandDisplayMarker>(deadline)?)
5548    }
5549
5550    pub fn r#set_content(
5551        &self,
5552        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5553        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5554    ) -> Result<(), fidl::Error> {
5555        self.client.send::<FlatlandDisplaySetContentRequest>(
5556            (&mut token, child_view_watcher),
5557            0x6748193a39918298,
5558            fidl::encoding::DynamicFlags::empty(),
5559        )
5560    }
5561
5562    /// Sets the ratio of display's physical pixels to device independent pixels that should be used
5563    /// for the tree of Flatland content that are attached to this display. See
5564    /// [`LayoutInfo.device_pixel_ratio`] for details.
5565    ///
5566    /// The default value is (1.0, 1.0). The valid values are 1.0 and above.
5567    pub fn r#set_device_pixel_ratio(
5568        &self,
5569        mut device_pixel_ratio: &fidl_fuchsia_math::VecF,
5570    ) -> Result<(), fidl::Error> {
5571        self.client.send::<FlatlandDisplaySetDevicePixelRatioRequest>(
5572            (device_pixel_ratio,),
5573            0x392c3e70cc0a81a4,
5574            fidl::encoding::DynamicFlags::empty(),
5575        )
5576    }
5577}
5578
5579#[cfg(target_os = "fuchsia")]
5580impl From<FlatlandDisplaySynchronousProxy> for zx::NullableHandle {
5581    fn from(value: FlatlandDisplaySynchronousProxy) -> Self {
5582        value.into_channel().into()
5583    }
5584}
5585
5586#[cfg(target_os = "fuchsia")]
5587impl From<fidl::Channel> for FlatlandDisplaySynchronousProxy {
5588    fn from(value: fidl::Channel) -> Self {
5589        Self::new(value)
5590    }
5591}
5592
5593#[cfg(target_os = "fuchsia")]
5594impl fidl::endpoints::FromClient for FlatlandDisplaySynchronousProxy {
5595    type Protocol = FlatlandDisplayMarker;
5596
5597    fn from_client(value: fidl::endpoints::ClientEnd<FlatlandDisplayMarker>) -> Self {
5598        Self::new(value.into_channel())
5599    }
5600}
5601
5602#[derive(Debug, Clone)]
5603pub struct FlatlandDisplayProxy {
5604    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5605}
5606
5607impl fidl::endpoints::Proxy for FlatlandDisplayProxy {
5608    type Protocol = FlatlandDisplayMarker;
5609
5610    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5611        Self::new(inner)
5612    }
5613
5614    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5615        self.client.into_channel().map_err(|client| Self { client })
5616    }
5617
5618    fn as_channel(&self) -> &::fidl::AsyncChannel {
5619        self.client.as_channel()
5620    }
5621}
5622
5623impl FlatlandDisplayProxy {
5624    /// Create a new Proxy for fuchsia.ui.composition/FlatlandDisplay.
5625    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5626        let protocol_name = <FlatlandDisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5627        Self { client: fidl::client::Client::new(channel, protocol_name) }
5628    }
5629
5630    /// Get a Stream of events from the remote end of the protocol.
5631    ///
5632    /// # Panics
5633    ///
5634    /// Panics if the event stream was already taken.
5635    pub fn take_event_stream(&self) -> FlatlandDisplayEventStream {
5636        FlatlandDisplayEventStream { event_receiver: self.client.take_event_receiver() }
5637    }
5638
5639    pub fn r#set_content(
5640        &self,
5641        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5642        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5643    ) -> Result<(), fidl::Error> {
5644        FlatlandDisplayProxyInterface::r#set_content(self, token, child_view_watcher)
5645    }
5646
5647    /// Sets the ratio of display's physical pixels to device independent pixels that should be used
5648    /// for the tree of Flatland content that are attached to this display. See
5649    /// [`LayoutInfo.device_pixel_ratio`] for details.
5650    ///
5651    /// The default value is (1.0, 1.0). The valid values are 1.0 and above.
5652    pub fn r#set_device_pixel_ratio(
5653        &self,
5654        mut device_pixel_ratio: &fidl_fuchsia_math::VecF,
5655    ) -> Result<(), fidl::Error> {
5656        FlatlandDisplayProxyInterface::r#set_device_pixel_ratio(self, device_pixel_ratio)
5657    }
5658}
5659
5660impl FlatlandDisplayProxyInterface for FlatlandDisplayProxy {
5661    fn r#set_content(
5662        &self,
5663        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5664        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5665    ) -> Result<(), fidl::Error> {
5666        self.client.send::<FlatlandDisplaySetContentRequest>(
5667            (&mut token, child_view_watcher),
5668            0x6748193a39918298,
5669            fidl::encoding::DynamicFlags::empty(),
5670        )
5671    }
5672
5673    fn r#set_device_pixel_ratio(
5674        &self,
5675        mut device_pixel_ratio: &fidl_fuchsia_math::VecF,
5676    ) -> Result<(), fidl::Error> {
5677        self.client.send::<FlatlandDisplaySetDevicePixelRatioRequest>(
5678            (device_pixel_ratio,),
5679            0x392c3e70cc0a81a4,
5680            fidl::encoding::DynamicFlags::empty(),
5681        )
5682    }
5683}
5684
5685pub struct FlatlandDisplayEventStream {
5686    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5687}
5688
5689impl std::marker::Unpin for FlatlandDisplayEventStream {}
5690
5691impl futures::stream::FusedStream for FlatlandDisplayEventStream {
5692    fn is_terminated(&self) -> bool {
5693        self.event_receiver.is_terminated()
5694    }
5695}
5696
5697impl futures::Stream for FlatlandDisplayEventStream {
5698    type Item = Result<FlatlandDisplayEvent, fidl::Error>;
5699
5700    fn poll_next(
5701        mut self: std::pin::Pin<&mut Self>,
5702        cx: &mut std::task::Context<'_>,
5703    ) -> std::task::Poll<Option<Self::Item>> {
5704        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5705            &mut self.event_receiver,
5706            cx
5707        )?) {
5708            Some(buf) => std::task::Poll::Ready(Some(FlatlandDisplayEvent::decode(buf))),
5709            None => std::task::Poll::Ready(None),
5710        }
5711    }
5712}
5713
5714#[derive(Debug)]
5715pub enum FlatlandDisplayEvent {}
5716
5717impl FlatlandDisplayEvent {
5718    /// Decodes a message buffer as a [`FlatlandDisplayEvent`].
5719    fn decode(
5720        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5721    ) -> Result<FlatlandDisplayEvent, fidl::Error> {
5722        let (bytes, _handles) = buf.split_mut();
5723        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5724        debug_assert_eq!(tx_header.tx_id, 0);
5725        match tx_header.ordinal {
5726            _ => Err(fidl::Error::UnknownOrdinal {
5727                ordinal: tx_header.ordinal,
5728                protocol_name:
5729                    <FlatlandDisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5730            }),
5731        }
5732    }
5733}
5734
5735/// A Stream of incoming requests for fuchsia.ui.composition/FlatlandDisplay.
5736pub struct FlatlandDisplayRequestStream {
5737    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5738    is_terminated: bool,
5739}
5740
5741impl std::marker::Unpin for FlatlandDisplayRequestStream {}
5742
5743impl futures::stream::FusedStream for FlatlandDisplayRequestStream {
5744    fn is_terminated(&self) -> bool {
5745        self.is_terminated
5746    }
5747}
5748
5749impl fidl::endpoints::RequestStream for FlatlandDisplayRequestStream {
5750    type Protocol = FlatlandDisplayMarker;
5751    type ControlHandle = FlatlandDisplayControlHandle;
5752
5753    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5754        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5755    }
5756
5757    fn control_handle(&self) -> Self::ControlHandle {
5758        FlatlandDisplayControlHandle { inner: self.inner.clone() }
5759    }
5760
5761    fn into_inner(
5762        self,
5763    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5764    {
5765        (self.inner, self.is_terminated)
5766    }
5767
5768    fn from_inner(
5769        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5770        is_terminated: bool,
5771    ) -> Self {
5772        Self { inner, is_terminated }
5773    }
5774}
5775
5776impl futures::Stream for FlatlandDisplayRequestStream {
5777    type Item = Result<FlatlandDisplayRequest, fidl::Error>;
5778
5779    fn poll_next(
5780        mut self: std::pin::Pin<&mut Self>,
5781        cx: &mut std::task::Context<'_>,
5782    ) -> std::task::Poll<Option<Self::Item>> {
5783        let this = &mut *self;
5784        if this.inner.check_shutdown(cx) {
5785            this.is_terminated = true;
5786            return std::task::Poll::Ready(None);
5787        }
5788        if this.is_terminated {
5789            panic!("polled FlatlandDisplayRequestStream after completion");
5790        }
5791        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5792            |bytes, handles| {
5793                match this.inner.channel().read_etc(cx, bytes, handles) {
5794                    std::task::Poll::Ready(Ok(())) => {}
5795                    std::task::Poll::Pending => return std::task::Poll::Pending,
5796                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5797                        this.is_terminated = true;
5798                        return std::task::Poll::Ready(None);
5799                    }
5800                    std::task::Poll::Ready(Err(e)) => {
5801                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5802                            e.into(),
5803                        ))));
5804                    }
5805                }
5806
5807                // A message has been received from the channel
5808                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5809
5810                std::task::Poll::Ready(Some(match header.ordinal {
5811                    0x6748193a39918298 => {
5812                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5813                        let mut req = fidl::new_empty!(
5814                            FlatlandDisplaySetContentRequest,
5815                            fidl::encoding::DefaultFuchsiaResourceDialect
5816                        );
5817                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandDisplaySetContentRequest>(&header, _body_bytes, handles, &mut req)?;
5818                        let control_handle =
5819                            FlatlandDisplayControlHandle { inner: this.inner.clone() };
5820                        Ok(FlatlandDisplayRequest::SetContent {
5821                            token: req.token,
5822                            child_view_watcher: req.child_view_watcher,
5823
5824                            control_handle,
5825                        })
5826                    }
5827                    0x392c3e70cc0a81a4 => {
5828                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5829                        let mut req = fidl::new_empty!(
5830                            FlatlandDisplaySetDevicePixelRatioRequest,
5831                            fidl::encoding::DefaultFuchsiaResourceDialect
5832                        );
5833                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandDisplaySetDevicePixelRatioRequest>(&header, _body_bytes, handles, &mut req)?;
5834                        let control_handle =
5835                            FlatlandDisplayControlHandle { inner: this.inner.clone() };
5836                        Ok(FlatlandDisplayRequest::SetDevicePixelRatio {
5837                            device_pixel_ratio: req.device_pixel_ratio,
5838
5839                            control_handle,
5840                        })
5841                    }
5842                    _ => Err(fidl::Error::UnknownOrdinal {
5843                        ordinal: header.ordinal,
5844                        protocol_name:
5845                            <FlatlandDisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5846                    }),
5847                }))
5848            },
5849        )
5850    }
5851}
5852
5853/// This API connects to the singleton "primary display", and allows a tree of Flatland content to
5854/// be attached underneath.  Only one FlatlandDisplay client connection is allowed at one time.
5855#[derive(Debug)]
5856pub enum FlatlandDisplayRequest {
5857    SetContent {
5858        token: fidl_fuchsia_ui_views::ViewportCreationToken,
5859        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5860        control_handle: FlatlandDisplayControlHandle,
5861    },
5862    /// Sets the ratio of display's physical pixels to device independent pixels that should be used
5863    /// for the tree of Flatland content that are attached to this display. See
5864    /// [`LayoutInfo.device_pixel_ratio`] for details.
5865    ///
5866    /// The default value is (1.0, 1.0). The valid values are 1.0 and above.
5867    SetDevicePixelRatio {
5868        device_pixel_ratio: fidl_fuchsia_math::VecF,
5869        control_handle: FlatlandDisplayControlHandle,
5870    },
5871}
5872
5873impl FlatlandDisplayRequest {
5874    #[allow(irrefutable_let_patterns)]
5875    pub fn into_set_content(
5876        self,
5877    ) -> Option<(
5878        fidl_fuchsia_ui_views::ViewportCreationToken,
5879        fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5880        FlatlandDisplayControlHandle,
5881    )> {
5882        if let FlatlandDisplayRequest::SetContent { token, child_view_watcher, control_handle } =
5883            self
5884        {
5885            Some((token, child_view_watcher, control_handle))
5886        } else {
5887            None
5888        }
5889    }
5890
5891    #[allow(irrefutable_let_patterns)]
5892    pub fn into_set_device_pixel_ratio(
5893        self,
5894    ) -> Option<(fidl_fuchsia_math::VecF, FlatlandDisplayControlHandle)> {
5895        if let FlatlandDisplayRequest::SetDevicePixelRatio { device_pixel_ratio, control_handle } =
5896            self
5897        {
5898            Some((device_pixel_ratio, control_handle))
5899        } else {
5900            None
5901        }
5902    }
5903
5904    /// Name of the method defined in FIDL
5905    pub fn method_name(&self) -> &'static str {
5906        match *self {
5907            FlatlandDisplayRequest::SetContent { .. } => "set_content",
5908            FlatlandDisplayRequest::SetDevicePixelRatio { .. } => "set_device_pixel_ratio",
5909        }
5910    }
5911}
5912
5913#[derive(Debug, Clone)]
5914pub struct FlatlandDisplayControlHandle {
5915    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5916}
5917
5918impl fidl::endpoints::ControlHandle for FlatlandDisplayControlHandle {
5919    fn shutdown(&self) {
5920        self.inner.shutdown()
5921    }
5922
5923    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5924        self.inner.shutdown_with_epitaph(status)
5925    }
5926
5927    fn is_closed(&self) -> bool {
5928        self.inner.channel().is_closed()
5929    }
5930    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5931        self.inner.channel().on_closed()
5932    }
5933
5934    #[cfg(target_os = "fuchsia")]
5935    fn signal_peer(
5936        &self,
5937        clear_mask: zx::Signals,
5938        set_mask: zx::Signals,
5939    ) -> Result<(), zx_status::Status> {
5940        use fidl::Peered;
5941        self.inner.channel().signal_peer(clear_mask, set_mask)
5942    }
5943}
5944
5945impl FlatlandDisplayControlHandle {}
5946
5947#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5948pub struct ParentViewportWatcherMarker;
5949
5950impl fidl::endpoints::ProtocolMarker for ParentViewportWatcherMarker {
5951    type Proxy = ParentViewportWatcherProxy;
5952    type RequestStream = ParentViewportWatcherRequestStream;
5953    #[cfg(target_os = "fuchsia")]
5954    type SynchronousProxy = ParentViewportWatcherSynchronousProxy;
5955
5956    const DEBUG_NAME: &'static str = "(anonymous) ParentViewportWatcher";
5957}
5958
5959pub trait ParentViewportWatcherProxyInterface: Send + Sync {
5960    type GetLayoutResponseFut: std::future::Future<Output = Result<LayoutInfo, fidl::Error>> + Send;
5961    fn r#get_layout(&self) -> Self::GetLayoutResponseFut;
5962    type GetStatusResponseFut: std::future::Future<Output = Result<ParentViewportStatus, fidl::Error>>
5963        + Send;
5964    fn r#get_status(&self) -> Self::GetStatusResponseFut;
5965}
5966#[derive(Debug)]
5967#[cfg(target_os = "fuchsia")]
5968pub struct ParentViewportWatcherSynchronousProxy {
5969    client: fidl::client::sync::Client,
5970}
5971
5972#[cfg(target_os = "fuchsia")]
5973impl fidl::endpoints::SynchronousProxy for ParentViewportWatcherSynchronousProxy {
5974    type Proxy = ParentViewportWatcherProxy;
5975    type Protocol = ParentViewportWatcherMarker;
5976
5977    fn from_channel(inner: fidl::Channel) -> Self {
5978        Self::new(inner)
5979    }
5980
5981    fn into_channel(self) -> fidl::Channel {
5982        self.client.into_channel()
5983    }
5984
5985    fn as_channel(&self) -> &fidl::Channel {
5986        self.client.as_channel()
5987    }
5988}
5989
5990#[cfg(target_os = "fuchsia")]
5991impl ParentViewportWatcherSynchronousProxy {
5992    pub fn new(channel: fidl::Channel) -> Self {
5993        Self { client: fidl::client::sync::Client::new(channel) }
5994    }
5995
5996    pub fn into_channel(self) -> fidl::Channel {
5997        self.client.into_channel()
5998    }
5999
6000    /// Waits until an event arrives and returns it. It is safe for other
6001    /// threads to make concurrent requests while waiting for an event.
6002    pub fn wait_for_event(
6003        &self,
6004        deadline: zx::MonotonicInstant,
6005    ) -> Result<ParentViewportWatcherEvent, fidl::Error> {
6006        ParentViewportWatcherEvent::decode(
6007            self.client.wait_for_event::<ParentViewportWatcherMarker>(deadline)?,
6008        )
6009    }
6010
6011    /// A hanging get for receiving layout information. Clients may receive layout information
6012    /// before the ParentViewportWatcher operation has been presented. This allows children to
6013    /// layout their content before their first call to [`Present`]. In transition cases where two
6014    /// ParentViewportWatcher channels exist at the same time, both protocol instances will be
6015    /// receiving different layout information.
6016    ///
6017    /// This hanging get will only fire when the LayoutInfo is different than the previously
6018    /// returned LayoutInfo. Note that, since LayoutInfo is a table, only some fields may have
6019    /// changed.
6020    ///
6021    /// It is invalid to call `GetLayout` while a previous call is still pending. Doing so will
6022    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6023    /// closed.
6024    pub fn r#get_layout(
6025        &self,
6026        ___deadline: zx::MonotonicInstant,
6027    ) -> Result<LayoutInfo, fidl::Error> {
6028        let _response = self.client.send_query::<
6029            fidl::encoding::EmptyPayload,
6030            ParentViewportWatcherGetLayoutResponse,
6031            ParentViewportWatcherMarker,
6032        >(
6033            (),
6034            0x3cbe5d9638e032,
6035            fidl::encoding::DynamicFlags::empty(),
6036            ___deadline,
6037        )?;
6038        Ok(_response.info)
6039    }
6040
6041    /// A hanging get for receiving the status of the parent Viewport. This provides global
6042    /// connectivity information to the child.
6043    ///
6044    /// This hanging get will only fire when the ParentViewportStatus is different than the
6045    /// previously returned ParentViewportStatus.
6046    ///
6047    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
6048    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6049    /// closed.
6050    pub fn r#get_status(
6051        &self,
6052        ___deadline: zx::MonotonicInstant,
6053    ) -> Result<ParentViewportStatus, fidl::Error> {
6054        let _response = self.client.send_query::<
6055            fidl::encoding::EmptyPayload,
6056            ParentViewportWatcherGetStatusResponse,
6057            ParentViewportWatcherMarker,
6058        >(
6059            (),
6060            0x7caa022f050d9ea6,
6061            fidl::encoding::DynamicFlags::empty(),
6062            ___deadline,
6063        )?;
6064        Ok(_response.status)
6065    }
6066}
6067
6068#[cfg(target_os = "fuchsia")]
6069impl From<ParentViewportWatcherSynchronousProxy> for zx::NullableHandle {
6070    fn from(value: ParentViewportWatcherSynchronousProxy) -> Self {
6071        value.into_channel().into()
6072    }
6073}
6074
6075#[cfg(target_os = "fuchsia")]
6076impl From<fidl::Channel> for ParentViewportWatcherSynchronousProxy {
6077    fn from(value: fidl::Channel) -> Self {
6078        Self::new(value)
6079    }
6080}
6081
6082#[cfg(target_os = "fuchsia")]
6083impl fidl::endpoints::FromClient for ParentViewportWatcherSynchronousProxy {
6084    type Protocol = ParentViewportWatcherMarker;
6085
6086    fn from_client(value: fidl::endpoints::ClientEnd<ParentViewportWatcherMarker>) -> Self {
6087        Self::new(value.into_channel())
6088    }
6089}
6090
6091#[derive(Debug, Clone)]
6092pub struct ParentViewportWatcherProxy {
6093    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6094}
6095
6096impl fidl::endpoints::Proxy for ParentViewportWatcherProxy {
6097    type Protocol = ParentViewportWatcherMarker;
6098
6099    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6100        Self::new(inner)
6101    }
6102
6103    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6104        self.client.into_channel().map_err(|client| Self { client })
6105    }
6106
6107    fn as_channel(&self) -> &::fidl::AsyncChannel {
6108        self.client.as_channel()
6109    }
6110}
6111
6112impl ParentViewportWatcherProxy {
6113    /// Create a new Proxy for fuchsia.ui.composition/ParentViewportWatcher.
6114    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6115        let protocol_name =
6116            <ParentViewportWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6117        Self { client: fidl::client::Client::new(channel, protocol_name) }
6118    }
6119
6120    /// Get a Stream of events from the remote end of the protocol.
6121    ///
6122    /// # Panics
6123    ///
6124    /// Panics if the event stream was already taken.
6125    pub fn take_event_stream(&self) -> ParentViewportWatcherEventStream {
6126        ParentViewportWatcherEventStream { event_receiver: self.client.take_event_receiver() }
6127    }
6128
6129    /// A hanging get for receiving layout information. Clients may receive layout information
6130    /// before the ParentViewportWatcher operation has been presented. This allows children to
6131    /// layout their content before their first call to [`Present`]. In transition cases where two
6132    /// ParentViewportWatcher channels exist at the same time, both protocol instances will be
6133    /// receiving different layout information.
6134    ///
6135    /// This hanging get will only fire when the LayoutInfo is different than the previously
6136    /// returned LayoutInfo. Note that, since LayoutInfo is a table, only some fields may have
6137    /// changed.
6138    ///
6139    /// It is invalid to call `GetLayout` while a previous call is still pending. Doing so will
6140    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6141    /// closed.
6142    pub fn r#get_layout(
6143        &self,
6144    ) -> fidl::client::QueryResponseFut<LayoutInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
6145    {
6146        ParentViewportWatcherProxyInterface::r#get_layout(self)
6147    }
6148
6149    /// A hanging get for receiving the status of the parent Viewport. This provides global
6150    /// connectivity information to the child.
6151    ///
6152    /// This hanging get will only fire when the ParentViewportStatus is different than the
6153    /// previously returned ParentViewportStatus.
6154    ///
6155    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
6156    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6157    /// closed.
6158    pub fn r#get_status(
6159        &self,
6160    ) -> fidl::client::QueryResponseFut<
6161        ParentViewportStatus,
6162        fidl::encoding::DefaultFuchsiaResourceDialect,
6163    > {
6164        ParentViewportWatcherProxyInterface::r#get_status(self)
6165    }
6166}
6167
6168impl ParentViewportWatcherProxyInterface for ParentViewportWatcherProxy {
6169    type GetLayoutResponseFut =
6170        fidl::client::QueryResponseFut<LayoutInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
6171    fn r#get_layout(&self) -> Self::GetLayoutResponseFut {
6172        fn _decode(
6173            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6174        ) -> Result<LayoutInfo, fidl::Error> {
6175            let _response = fidl::client::decode_transaction_body::<
6176                ParentViewportWatcherGetLayoutResponse,
6177                fidl::encoding::DefaultFuchsiaResourceDialect,
6178                0x3cbe5d9638e032,
6179            >(_buf?)?;
6180            Ok(_response.info)
6181        }
6182        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, LayoutInfo>(
6183            (),
6184            0x3cbe5d9638e032,
6185            fidl::encoding::DynamicFlags::empty(),
6186            _decode,
6187        )
6188    }
6189
6190    type GetStatusResponseFut = fidl::client::QueryResponseFut<
6191        ParentViewportStatus,
6192        fidl::encoding::DefaultFuchsiaResourceDialect,
6193    >;
6194    fn r#get_status(&self) -> Self::GetStatusResponseFut {
6195        fn _decode(
6196            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6197        ) -> Result<ParentViewportStatus, fidl::Error> {
6198            let _response = fidl::client::decode_transaction_body::<
6199                ParentViewportWatcherGetStatusResponse,
6200                fidl::encoding::DefaultFuchsiaResourceDialect,
6201                0x7caa022f050d9ea6,
6202            >(_buf?)?;
6203            Ok(_response.status)
6204        }
6205        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ParentViewportStatus>(
6206            (),
6207            0x7caa022f050d9ea6,
6208            fidl::encoding::DynamicFlags::empty(),
6209            _decode,
6210        )
6211    }
6212}
6213
6214pub struct ParentViewportWatcherEventStream {
6215    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6216}
6217
6218impl std::marker::Unpin for ParentViewportWatcherEventStream {}
6219
6220impl futures::stream::FusedStream for ParentViewportWatcherEventStream {
6221    fn is_terminated(&self) -> bool {
6222        self.event_receiver.is_terminated()
6223    }
6224}
6225
6226impl futures::Stream for ParentViewportWatcherEventStream {
6227    type Item = Result<ParentViewportWatcherEvent, fidl::Error>;
6228
6229    fn poll_next(
6230        mut self: std::pin::Pin<&mut Self>,
6231        cx: &mut std::task::Context<'_>,
6232    ) -> std::task::Poll<Option<Self::Item>> {
6233        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6234            &mut self.event_receiver,
6235            cx
6236        )?) {
6237            Some(buf) => std::task::Poll::Ready(Some(ParentViewportWatcherEvent::decode(buf))),
6238            None => std::task::Poll::Ready(None),
6239        }
6240    }
6241}
6242
6243#[derive(Debug)]
6244pub enum ParentViewportWatcherEvent {}
6245
6246impl ParentViewportWatcherEvent {
6247    /// Decodes a message buffer as a [`ParentViewportWatcherEvent`].
6248    fn decode(
6249        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6250    ) -> Result<ParentViewportWatcherEvent, fidl::Error> {
6251        let (bytes, _handles) = buf.split_mut();
6252        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6253        debug_assert_eq!(tx_header.tx_id, 0);
6254        match tx_header.ordinal {
6255            _ => Err(fidl::Error::UnknownOrdinal {
6256                ordinal: tx_header.ordinal,
6257                protocol_name:
6258                    <ParentViewportWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6259            }),
6260        }
6261    }
6262}
6263
6264/// A Stream of incoming requests for fuchsia.ui.composition/ParentViewportWatcher.
6265pub struct ParentViewportWatcherRequestStream {
6266    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6267    is_terminated: bool,
6268}
6269
6270impl std::marker::Unpin for ParentViewportWatcherRequestStream {}
6271
6272impl futures::stream::FusedStream for ParentViewportWatcherRequestStream {
6273    fn is_terminated(&self) -> bool {
6274        self.is_terminated
6275    }
6276}
6277
6278impl fidl::endpoints::RequestStream for ParentViewportWatcherRequestStream {
6279    type Protocol = ParentViewportWatcherMarker;
6280    type ControlHandle = ParentViewportWatcherControlHandle;
6281
6282    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6283        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6284    }
6285
6286    fn control_handle(&self) -> Self::ControlHandle {
6287        ParentViewportWatcherControlHandle { inner: self.inner.clone() }
6288    }
6289
6290    fn into_inner(
6291        self,
6292    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6293    {
6294        (self.inner, self.is_terminated)
6295    }
6296
6297    fn from_inner(
6298        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6299        is_terminated: bool,
6300    ) -> Self {
6301        Self { inner, is_terminated }
6302    }
6303}
6304
6305impl futures::Stream for ParentViewportWatcherRequestStream {
6306    type Item = Result<ParentViewportWatcherRequest, fidl::Error>;
6307
6308    fn poll_next(
6309        mut self: std::pin::Pin<&mut Self>,
6310        cx: &mut std::task::Context<'_>,
6311    ) -> std::task::Poll<Option<Self::Item>> {
6312        let this = &mut *self;
6313        if this.inner.check_shutdown(cx) {
6314            this.is_terminated = true;
6315            return std::task::Poll::Ready(None);
6316        }
6317        if this.is_terminated {
6318            panic!("polled ParentViewportWatcherRequestStream after completion");
6319        }
6320        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6321            |bytes, handles| {
6322                match this.inner.channel().read_etc(cx, bytes, handles) {
6323                    std::task::Poll::Ready(Ok(())) => {}
6324                    std::task::Poll::Pending => return std::task::Poll::Pending,
6325                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6326                        this.is_terminated = true;
6327                        return std::task::Poll::Ready(None);
6328                    }
6329                    std::task::Poll::Ready(Err(e)) => {
6330                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6331                            e.into(),
6332                        ))));
6333                    }
6334                }
6335
6336                // A message has been received from the channel
6337                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6338
6339                std::task::Poll::Ready(Some(match header.ordinal {
6340                0x3cbe5d9638e032 => {
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::GetLayout {
6348                        responder: ParentViewportWatcherGetLayoutResponder {
6349                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6350                            tx_id: header.tx_id,
6351                        },
6352                    })
6353                }
6354                0x7caa022f050d9ea6 => {
6355                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6356                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
6357                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6358                    let control_handle = ParentViewportWatcherControlHandle {
6359                        inner: this.inner.clone(),
6360                    };
6361                    Ok(ParentViewportWatcherRequest::GetStatus {
6362                        responder: ParentViewportWatcherGetStatusResponder {
6363                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6364                            tx_id: header.tx_id,
6365                        },
6366                    })
6367                }
6368                _ => Err(fidl::Error::UnknownOrdinal {
6369                    ordinal: header.ordinal,
6370                    protocol_name: <ParentViewportWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6371                }),
6372            }))
6373            },
6374        )
6375    }
6376}
6377
6378/// A protocol that provides information about the parent Viewport attached to a Flatland instance's
6379/// sole View.  Although Flatland instances can have at most one view, it is possible to have
6380/// multiple ParentViewportWatchers during the brief transition period when replacing the instance's
6381/// View with another, e.g. via [`CreateView`].  During this period, certain updates may be
6382/// duplicated and sent to each ParentViewportWatcher connection.
6383///
6384/// A ParentViewportWatcher will remain connected as long as the corresponding parent Viewport
6385/// exists; the connection will also be closed if the parents's ViewportCreationToken is dropped
6386/// without using it to create a Viewport.
6387#[derive(Debug)]
6388pub enum ParentViewportWatcherRequest {
6389    /// A hanging get for receiving layout information. Clients may receive layout information
6390    /// before the ParentViewportWatcher operation has been presented. This allows children to
6391    /// layout their content before their first call to [`Present`]. In transition cases where two
6392    /// ParentViewportWatcher channels exist at the same time, both protocol instances will be
6393    /// receiving different layout information.
6394    ///
6395    /// This hanging get will only fire when the LayoutInfo is different than the previously
6396    /// returned LayoutInfo. Note that, since LayoutInfo is a table, only some fields may have
6397    /// changed.
6398    ///
6399    /// It is invalid to call `GetLayout` while a previous call is still pending. Doing so will
6400    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6401    /// closed.
6402    GetLayout { responder: ParentViewportWatcherGetLayoutResponder },
6403    /// A hanging get for receiving the status of the parent Viewport. This provides global
6404    /// connectivity information to the child.
6405    ///
6406    /// This hanging get will only fire when the ParentViewportStatus is different than the
6407    /// previously returned ParentViewportStatus.
6408    ///
6409    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
6410    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6411    /// closed.
6412    GetStatus { responder: ParentViewportWatcherGetStatusResponder },
6413}
6414
6415impl ParentViewportWatcherRequest {
6416    #[allow(irrefutable_let_patterns)]
6417    pub fn into_get_layout(self) -> Option<(ParentViewportWatcherGetLayoutResponder)> {
6418        if let ParentViewportWatcherRequest::GetLayout { responder } = self {
6419            Some((responder))
6420        } else {
6421            None
6422        }
6423    }
6424
6425    #[allow(irrefutable_let_patterns)]
6426    pub fn into_get_status(self) -> Option<(ParentViewportWatcherGetStatusResponder)> {
6427        if let ParentViewportWatcherRequest::GetStatus { responder } = self {
6428            Some((responder))
6429        } else {
6430            None
6431        }
6432    }
6433
6434    /// Name of the method defined in FIDL
6435    pub fn method_name(&self) -> &'static str {
6436        match *self {
6437            ParentViewportWatcherRequest::GetLayout { .. } => "get_layout",
6438            ParentViewportWatcherRequest::GetStatus { .. } => "get_status",
6439        }
6440    }
6441}
6442
6443#[derive(Debug, Clone)]
6444pub struct ParentViewportWatcherControlHandle {
6445    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6446}
6447
6448impl fidl::endpoints::ControlHandle for ParentViewportWatcherControlHandle {
6449    fn shutdown(&self) {
6450        self.inner.shutdown()
6451    }
6452
6453    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6454        self.inner.shutdown_with_epitaph(status)
6455    }
6456
6457    fn is_closed(&self) -> bool {
6458        self.inner.channel().is_closed()
6459    }
6460    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6461        self.inner.channel().on_closed()
6462    }
6463
6464    #[cfg(target_os = "fuchsia")]
6465    fn signal_peer(
6466        &self,
6467        clear_mask: zx::Signals,
6468        set_mask: zx::Signals,
6469    ) -> Result<(), zx_status::Status> {
6470        use fidl::Peered;
6471        self.inner.channel().signal_peer(clear_mask, set_mask)
6472    }
6473}
6474
6475impl ParentViewportWatcherControlHandle {}
6476
6477#[must_use = "FIDL methods require a response to be sent"]
6478#[derive(Debug)]
6479pub struct ParentViewportWatcherGetLayoutResponder {
6480    control_handle: std::mem::ManuallyDrop<ParentViewportWatcherControlHandle>,
6481    tx_id: u32,
6482}
6483
6484/// Set the the channel to be shutdown (see [`ParentViewportWatcherControlHandle::shutdown`])
6485/// if the responder is dropped without sending a response, so that the client
6486/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6487impl std::ops::Drop for ParentViewportWatcherGetLayoutResponder {
6488    fn drop(&mut self) {
6489        self.control_handle.shutdown();
6490        // Safety: drops once, never accessed again
6491        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6492    }
6493}
6494
6495impl fidl::endpoints::Responder for ParentViewportWatcherGetLayoutResponder {
6496    type ControlHandle = ParentViewportWatcherControlHandle;
6497
6498    fn control_handle(&self) -> &ParentViewportWatcherControlHandle {
6499        &self.control_handle
6500    }
6501
6502    fn drop_without_shutdown(mut self) {
6503        // Safety: drops once, never accessed again due to mem::forget
6504        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6505        // Prevent Drop from running (which would shut down the channel)
6506        std::mem::forget(self);
6507    }
6508}
6509
6510impl ParentViewportWatcherGetLayoutResponder {
6511    /// Sends a response to the FIDL transaction.
6512    ///
6513    /// Sets the channel to shutdown if an error occurs.
6514    pub fn send(self, mut info: &LayoutInfo) -> Result<(), fidl::Error> {
6515        let _result = self.send_raw(info);
6516        if _result.is_err() {
6517            self.control_handle.shutdown();
6518        }
6519        self.drop_without_shutdown();
6520        _result
6521    }
6522
6523    /// Similar to "send" but does not shutdown the channel if an error occurs.
6524    pub fn send_no_shutdown_on_err(self, mut info: &LayoutInfo) -> Result<(), fidl::Error> {
6525        let _result = self.send_raw(info);
6526        self.drop_without_shutdown();
6527        _result
6528    }
6529
6530    fn send_raw(&self, mut info: &LayoutInfo) -> Result<(), fidl::Error> {
6531        self.control_handle.inner.send::<ParentViewportWatcherGetLayoutResponse>(
6532            (info,),
6533            self.tx_id,
6534            0x3cbe5d9638e032,
6535            fidl::encoding::DynamicFlags::empty(),
6536        )
6537    }
6538}
6539
6540#[must_use = "FIDL methods require a response to be sent"]
6541#[derive(Debug)]
6542pub struct ParentViewportWatcherGetStatusResponder {
6543    control_handle: std::mem::ManuallyDrop<ParentViewportWatcherControlHandle>,
6544    tx_id: u32,
6545}
6546
6547/// Set the the channel to be shutdown (see [`ParentViewportWatcherControlHandle::shutdown`])
6548/// if the responder is dropped without sending a response, so that the client
6549/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6550impl std::ops::Drop for ParentViewportWatcherGetStatusResponder {
6551    fn drop(&mut self) {
6552        self.control_handle.shutdown();
6553        // Safety: drops once, never accessed again
6554        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6555    }
6556}
6557
6558impl fidl::endpoints::Responder for ParentViewportWatcherGetStatusResponder {
6559    type ControlHandle = ParentViewportWatcherControlHandle;
6560
6561    fn control_handle(&self) -> &ParentViewportWatcherControlHandle {
6562        &self.control_handle
6563    }
6564
6565    fn drop_without_shutdown(mut self) {
6566        // Safety: drops once, never accessed again due to mem::forget
6567        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6568        // Prevent Drop from running (which would shut down the channel)
6569        std::mem::forget(self);
6570    }
6571}
6572
6573impl ParentViewportWatcherGetStatusResponder {
6574    /// Sends a response to the FIDL transaction.
6575    ///
6576    /// Sets the channel to shutdown if an error occurs.
6577    pub fn send(self, mut status: ParentViewportStatus) -> Result<(), fidl::Error> {
6578        let _result = self.send_raw(status);
6579        if _result.is_err() {
6580            self.control_handle.shutdown();
6581        }
6582        self.drop_without_shutdown();
6583        _result
6584    }
6585
6586    /// Similar to "send" but does not shutdown the channel if an error occurs.
6587    pub fn send_no_shutdown_on_err(
6588        self,
6589        mut status: ParentViewportStatus,
6590    ) -> Result<(), fidl::Error> {
6591        let _result = self.send_raw(status);
6592        self.drop_without_shutdown();
6593        _result
6594    }
6595
6596    fn send_raw(&self, mut status: ParentViewportStatus) -> Result<(), fidl::Error> {
6597        self.control_handle.inner.send::<ParentViewportWatcherGetStatusResponse>(
6598            (status,),
6599            self.tx_id,
6600            0x7caa022f050d9ea6,
6601            fidl::encoding::DynamicFlags::empty(),
6602        )
6603    }
6604}
6605
6606#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6607pub struct ScreenCaptureMarker;
6608
6609impl fidl::endpoints::ProtocolMarker for ScreenCaptureMarker {
6610    type Proxy = ScreenCaptureProxy;
6611    type RequestStream = ScreenCaptureRequestStream;
6612    #[cfg(target_os = "fuchsia")]
6613    type SynchronousProxy = ScreenCaptureSynchronousProxy;
6614
6615    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.ScreenCapture";
6616}
6617impl fidl::endpoints::DiscoverableProtocolMarker for ScreenCaptureMarker {}
6618pub type ScreenCaptureConfigureResult = Result<(), ScreenCaptureError>;
6619pub type ScreenCaptureGetNextFrameResult = Result<FrameInfo, ScreenCaptureError>;
6620pub type ScreenCaptureReleaseFrameResult = Result<(), ScreenCaptureError>;
6621
6622pub trait ScreenCaptureProxyInterface: Send + Sync {
6623    type ConfigureResponseFut: std::future::Future<Output = Result<ScreenCaptureConfigureResult, fidl::Error>>
6624        + Send;
6625    fn r#configure(&self, payload: ScreenCaptureConfig) -> Self::ConfigureResponseFut;
6626    type GetNextFrameResponseFut: std::future::Future<Output = Result<ScreenCaptureGetNextFrameResult, fidl::Error>>
6627        + Send;
6628    fn r#get_next_frame(&self, payload: GetNextFrameArgs) -> Self::GetNextFrameResponseFut;
6629    type ReleaseFrameResponseFut: std::future::Future<Output = Result<ScreenCaptureReleaseFrameResult, fidl::Error>>
6630        + Send;
6631    fn r#release_frame(&self, buffer_id: u32) -> Self::ReleaseFrameResponseFut;
6632}
6633#[derive(Debug)]
6634#[cfg(target_os = "fuchsia")]
6635pub struct ScreenCaptureSynchronousProxy {
6636    client: fidl::client::sync::Client,
6637}
6638
6639#[cfg(target_os = "fuchsia")]
6640impl fidl::endpoints::SynchronousProxy for ScreenCaptureSynchronousProxy {
6641    type Proxy = ScreenCaptureProxy;
6642    type Protocol = ScreenCaptureMarker;
6643
6644    fn from_channel(inner: fidl::Channel) -> Self {
6645        Self::new(inner)
6646    }
6647
6648    fn into_channel(self) -> fidl::Channel {
6649        self.client.into_channel()
6650    }
6651
6652    fn as_channel(&self) -> &fidl::Channel {
6653        self.client.as_channel()
6654    }
6655}
6656
6657#[cfg(target_os = "fuchsia")]
6658impl ScreenCaptureSynchronousProxy {
6659    pub fn new(channel: fidl::Channel) -> Self {
6660        Self { client: fidl::client::sync::Client::new(channel) }
6661    }
6662
6663    pub fn into_channel(self) -> fidl::Channel {
6664        self.client.into_channel()
6665    }
6666
6667    /// Waits until an event arrives and returns it. It is safe for other
6668    /// threads to make concurrent requests while waiting for an event.
6669    pub fn wait_for_event(
6670        &self,
6671        deadline: zx::MonotonicInstant,
6672    ) -> Result<ScreenCaptureEvent, fidl::Error> {
6673        ScreenCaptureEvent::decode(self.client.wait_for_event::<ScreenCaptureMarker>(deadline)?)
6674    }
6675
6676    /// Clients should first use the Allocator protocol to register a
6677    /// BufferCollection. This function will fail with BAD_OPERATION unless all clients of the
6678    /// BufferCollection have set their constraints.
6679    ///
6680    /// Afterwards, clients should create and configure the images that will
6681    /// eventually be rendered to using this method. All the buffers in the
6682    /// collection from 0 to (buffer_count-1) may be used for screen capture.
6683    ///
6684    /// Clients are responsible for determining the rotation of the display,
6685    /// and applying the corrective rotation. For instance, if the display is
6686    /// mounted 90 degrees clockwise (the "top" is on the right, when looking
6687    /// at the display), then the client should specify a 270 degree rotation
6688    /// to account for it.
6689    ///
6690    /// Similarly, the clients are responsible for specifying a buffer big
6691    /// enough for the rotated image. If the buffer is too small, a best effort
6692    /// attempt will be made to render the image.
6693    ///
6694    /// Finally, clients request the server to render the current screen to the
6695    /// shared buffers using [`GetNextFrame`].
6696    ///
6697    /// [`Configure`] can be called again with a new BufferCollectionImportToken
6698    /// if the client wishes to change any of the configuration settings. In
6699    /// this case all the buffers from the previous call to [`Configure`] will
6700    /// be released.
6701    pub fn r#configure(
6702        &self,
6703        mut payload: ScreenCaptureConfig,
6704        ___deadline: zx::MonotonicInstant,
6705    ) -> Result<ScreenCaptureConfigureResult, fidl::Error> {
6706        let _response = self.client.send_query::<ScreenCaptureConfig, fidl::encoding::ResultType<
6707            fidl::encoding::EmptyStruct,
6708            ScreenCaptureError,
6709        >, ScreenCaptureMarker>(
6710            &mut payload,
6711            0x3b6e5af1d294afd9,
6712            fidl::encoding::DynamicFlags::empty(),
6713            ___deadline,
6714        )?;
6715        Ok(_response.map(|x| x))
6716    }
6717
6718    /// Following a successful call to [`Configure`], clients can call
6719    /// GetNextFrame. This will populate a buffer with the most recent frame.
6720    ///
6721    /// Clients should wait on the zx::event they pass for successful
6722    /// completion of the screenshot. It is not guaranteed that the screenshot
6723    /// will be completed by the time this function returns.
6724    ///
6725    /// The requested image will be in the BufferCollection that the client set
6726    /// up in the VMO at the index specified by buffer_id.
6727    ///
6728    /// When ScreenCapture is used to provide a stream, the rate that the
6729    /// client calls GetNextFrame will drive the frame rate.
6730    ///
6731    /// Errors:
6732    /// BAD_OPERATION if Configure was not called, or not called successfully
6733    /// MISSING_ARGS if a required argument is not present
6734    /// BUFFER_FULL if all buffers in the BufferCollection are in use. In this case, ReleaseFrame
6735    /// must be called to make a buffer available before this function can be called successfully.
6736    pub fn r#get_next_frame(
6737        &self,
6738        mut payload: GetNextFrameArgs,
6739        ___deadline: zx::MonotonicInstant,
6740    ) -> Result<ScreenCaptureGetNextFrameResult, fidl::Error> {
6741        let _response = self.client.send_query::<
6742            GetNextFrameArgs,
6743            fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>,
6744            ScreenCaptureMarker,
6745        >(
6746            &mut payload,
6747            0x552c1580aab8c4a7,
6748            fidl::encoding::DynamicFlags::empty(),
6749            ___deadline,
6750        )?;
6751        Ok(_response.map(|x| x))
6752    }
6753
6754    /// Once the client no longer needs an image, they can call ReleaseFrame on
6755    /// the VMO index of the buffer so that the server can reuse it in the future.
6756    pub fn r#release_frame(
6757        &self,
6758        mut buffer_id: u32,
6759        ___deadline: zx::MonotonicInstant,
6760    ) -> Result<ScreenCaptureReleaseFrameResult, fidl::Error> {
6761        let _response =
6762            self.client.send_query::<ScreenCaptureReleaseFrameRequest, fidl::encoding::ResultType<
6763                fidl::encoding::EmptyStruct,
6764                ScreenCaptureError,
6765            >, ScreenCaptureMarker>(
6766                (buffer_id,),
6767                0x46704dce24e35950,
6768                fidl::encoding::DynamicFlags::empty(),
6769                ___deadline,
6770            )?;
6771        Ok(_response.map(|x| x))
6772    }
6773}
6774
6775#[cfg(target_os = "fuchsia")]
6776impl From<ScreenCaptureSynchronousProxy> for zx::NullableHandle {
6777    fn from(value: ScreenCaptureSynchronousProxy) -> Self {
6778        value.into_channel().into()
6779    }
6780}
6781
6782#[cfg(target_os = "fuchsia")]
6783impl From<fidl::Channel> for ScreenCaptureSynchronousProxy {
6784    fn from(value: fidl::Channel) -> Self {
6785        Self::new(value)
6786    }
6787}
6788
6789#[cfg(target_os = "fuchsia")]
6790impl fidl::endpoints::FromClient for ScreenCaptureSynchronousProxy {
6791    type Protocol = ScreenCaptureMarker;
6792
6793    fn from_client(value: fidl::endpoints::ClientEnd<ScreenCaptureMarker>) -> Self {
6794        Self::new(value.into_channel())
6795    }
6796}
6797
6798#[derive(Debug, Clone)]
6799pub struct ScreenCaptureProxy {
6800    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6801}
6802
6803impl fidl::endpoints::Proxy for ScreenCaptureProxy {
6804    type Protocol = ScreenCaptureMarker;
6805
6806    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6807        Self::new(inner)
6808    }
6809
6810    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6811        self.client.into_channel().map_err(|client| Self { client })
6812    }
6813
6814    fn as_channel(&self) -> &::fidl::AsyncChannel {
6815        self.client.as_channel()
6816    }
6817}
6818
6819impl ScreenCaptureProxy {
6820    /// Create a new Proxy for fuchsia.ui.composition/ScreenCapture.
6821    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6822        let protocol_name = <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6823        Self { client: fidl::client::Client::new(channel, protocol_name) }
6824    }
6825
6826    /// Get a Stream of events from the remote end of the protocol.
6827    ///
6828    /// # Panics
6829    ///
6830    /// Panics if the event stream was already taken.
6831    pub fn take_event_stream(&self) -> ScreenCaptureEventStream {
6832        ScreenCaptureEventStream { event_receiver: self.client.take_event_receiver() }
6833    }
6834
6835    /// Clients should first use the Allocator protocol to register a
6836    /// BufferCollection. This function will fail with BAD_OPERATION unless all clients of the
6837    /// BufferCollection have set their constraints.
6838    ///
6839    /// Afterwards, clients should create and configure the images that will
6840    /// eventually be rendered to using this method. All the buffers in the
6841    /// collection from 0 to (buffer_count-1) may be used for screen capture.
6842    ///
6843    /// Clients are responsible for determining the rotation of the display,
6844    /// and applying the corrective rotation. For instance, if the display is
6845    /// mounted 90 degrees clockwise (the "top" is on the right, when looking
6846    /// at the display), then the client should specify a 270 degree rotation
6847    /// to account for it.
6848    ///
6849    /// Similarly, the clients are responsible for specifying a buffer big
6850    /// enough for the rotated image. If the buffer is too small, a best effort
6851    /// attempt will be made to render the image.
6852    ///
6853    /// Finally, clients request the server to render the current screen to the
6854    /// shared buffers using [`GetNextFrame`].
6855    ///
6856    /// [`Configure`] can be called again with a new BufferCollectionImportToken
6857    /// if the client wishes to change any of the configuration settings. In
6858    /// this case all the buffers from the previous call to [`Configure`] will
6859    /// be released.
6860    pub fn r#configure(
6861        &self,
6862        mut payload: ScreenCaptureConfig,
6863    ) -> fidl::client::QueryResponseFut<
6864        ScreenCaptureConfigureResult,
6865        fidl::encoding::DefaultFuchsiaResourceDialect,
6866    > {
6867        ScreenCaptureProxyInterface::r#configure(self, payload)
6868    }
6869
6870    /// Following a successful call to [`Configure`], clients can call
6871    /// GetNextFrame. This will populate a buffer with the most recent frame.
6872    ///
6873    /// Clients should wait on the zx::event they pass for successful
6874    /// completion of the screenshot. It is not guaranteed that the screenshot
6875    /// will be completed by the time this function returns.
6876    ///
6877    /// The requested image will be in the BufferCollection that the client set
6878    /// up in the VMO at the index specified by buffer_id.
6879    ///
6880    /// When ScreenCapture is used to provide a stream, the rate that the
6881    /// client calls GetNextFrame will drive the frame rate.
6882    ///
6883    /// Errors:
6884    /// BAD_OPERATION if Configure was not called, or not called successfully
6885    /// MISSING_ARGS if a required argument is not present
6886    /// BUFFER_FULL if all buffers in the BufferCollection are in use. In this case, ReleaseFrame
6887    /// must be called to make a buffer available before this function can be called successfully.
6888    pub fn r#get_next_frame(
6889        &self,
6890        mut payload: GetNextFrameArgs,
6891    ) -> fidl::client::QueryResponseFut<
6892        ScreenCaptureGetNextFrameResult,
6893        fidl::encoding::DefaultFuchsiaResourceDialect,
6894    > {
6895        ScreenCaptureProxyInterface::r#get_next_frame(self, payload)
6896    }
6897
6898    /// Once the client no longer needs an image, they can call ReleaseFrame on
6899    /// the VMO index of the buffer so that the server can reuse it in the future.
6900    pub fn r#release_frame(
6901        &self,
6902        mut buffer_id: u32,
6903    ) -> fidl::client::QueryResponseFut<
6904        ScreenCaptureReleaseFrameResult,
6905        fidl::encoding::DefaultFuchsiaResourceDialect,
6906    > {
6907        ScreenCaptureProxyInterface::r#release_frame(self, buffer_id)
6908    }
6909}
6910
6911impl ScreenCaptureProxyInterface for ScreenCaptureProxy {
6912    type ConfigureResponseFut = fidl::client::QueryResponseFut<
6913        ScreenCaptureConfigureResult,
6914        fidl::encoding::DefaultFuchsiaResourceDialect,
6915    >;
6916    fn r#configure(&self, mut payload: ScreenCaptureConfig) -> Self::ConfigureResponseFut {
6917        fn _decode(
6918            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6919        ) -> Result<ScreenCaptureConfigureResult, fidl::Error> {
6920            let _response = fidl::client::decode_transaction_body::<
6921                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ScreenCaptureError>,
6922                fidl::encoding::DefaultFuchsiaResourceDialect,
6923                0x3b6e5af1d294afd9,
6924            >(_buf?)?;
6925            Ok(_response.map(|x| x))
6926        }
6927        self.client.send_query_and_decode::<ScreenCaptureConfig, ScreenCaptureConfigureResult>(
6928            &mut payload,
6929            0x3b6e5af1d294afd9,
6930            fidl::encoding::DynamicFlags::empty(),
6931            _decode,
6932        )
6933    }
6934
6935    type GetNextFrameResponseFut = fidl::client::QueryResponseFut<
6936        ScreenCaptureGetNextFrameResult,
6937        fidl::encoding::DefaultFuchsiaResourceDialect,
6938    >;
6939    fn r#get_next_frame(&self, mut payload: GetNextFrameArgs) -> Self::GetNextFrameResponseFut {
6940        fn _decode(
6941            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6942        ) -> Result<ScreenCaptureGetNextFrameResult, fidl::Error> {
6943            let _response = fidl::client::decode_transaction_body::<
6944                fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>,
6945                fidl::encoding::DefaultFuchsiaResourceDialect,
6946                0x552c1580aab8c4a7,
6947            >(_buf?)?;
6948            Ok(_response.map(|x| x))
6949        }
6950        self.client.send_query_and_decode::<GetNextFrameArgs, ScreenCaptureGetNextFrameResult>(
6951            &mut payload,
6952            0x552c1580aab8c4a7,
6953            fidl::encoding::DynamicFlags::empty(),
6954            _decode,
6955        )
6956    }
6957
6958    type ReleaseFrameResponseFut = fidl::client::QueryResponseFut<
6959        ScreenCaptureReleaseFrameResult,
6960        fidl::encoding::DefaultFuchsiaResourceDialect,
6961    >;
6962    fn r#release_frame(&self, mut buffer_id: u32) -> Self::ReleaseFrameResponseFut {
6963        fn _decode(
6964            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6965        ) -> Result<ScreenCaptureReleaseFrameResult, fidl::Error> {
6966            let _response = fidl::client::decode_transaction_body::<
6967                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ScreenCaptureError>,
6968                fidl::encoding::DefaultFuchsiaResourceDialect,
6969                0x46704dce24e35950,
6970            >(_buf?)?;
6971            Ok(_response.map(|x| x))
6972        }
6973        self.client.send_query_and_decode::<
6974            ScreenCaptureReleaseFrameRequest,
6975            ScreenCaptureReleaseFrameResult,
6976        >(
6977            (buffer_id,),
6978            0x46704dce24e35950,
6979            fidl::encoding::DynamicFlags::empty(),
6980            _decode,
6981        )
6982    }
6983}
6984
6985pub struct ScreenCaptureEventStream {
6986    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6987}
6988
6989impl std::marker::Unpin for ScreenCaptureEventStream {}
6990
6991impl futures::stream::FusedStream for ScreenCaptureEventStream {
6992    fn is_terminated(&self) -> bool {
6993        self.event_receiver.is_terminated()
6994    }
6995}
6996
6997impl futures::Stream for ScreenCaptureEventStream {
6998    type Item = Result<ScreenCaptureEvent, fidl::Error>;
6999
7000    fn poll_next(
7001        mut self: std::pin::Pin<&mut Self>,
7002        cx: &mut std::task::Context<'_>,
7003    ) -> std::task::Poll<Option<Self::Item>> {
7004        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7005            &mut self.event_receiver,
7006            cx
7007        )?) {
7008            Some(buf) => std::task::Poll::Ready(Some(ScreenCaptureEvent::decode(buf))),
7009            None => std::task::Poll::Ready(None),
7010        }
7011    }
7012}
7013
7014#[derive(Debug)]
7015pub enum ScreenCaptureEvent {}
7016
7017impl ScreenCaptureEvent {
7018    /// Decodes a message buffer as a [`ScreenCaptureEvent`].
7019    fn decode(
7020        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7021    ) -> Result<ScreenCaptureEvent, fidl::Error> {
7022        let (bytes, _handles) = buf.split_mut();
7023        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7024        debug_assert_eq!(tx_header.tx_id, 0);
7025        match tx_header.ordinal {
7026            _ => Err(fidl::Error::UnknownOrdinal {
7027                ordinal: tx_header.ordinal,
7028                protocol_name: <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7029            }),
7030        }
7031    }
7032}
7033
7034/// A Stream of incoming requests for fuchsia.ui.composition/ScreenCapture.
7035pub struct ScreenCaptureRequestStream {
7036    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7037    is_terminated: bool,
7038}
7039
7040impl std::marker::Unpin for ScreenCaptureRequestStream {}
7041
7042impl futures::stream::FusedStream for ScreenCaptureRequestStream {
7043    fn is_terminated(&self) -> bool {
7044        self.is_terminated
7045    }
7046}
7047
7048impl fidl::endpoints::RequestStream for ScreenCaptureRequestStream {
7049    type Protocol = ScreenCaptureMarker;
7050    type ControlHandle = ScreenCaptureControlHandle;
7051
7052    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7053        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7054    }
7055
7056    fn control_handle(&self) -> Self::ControlHandle {
7057        ScreenCaptureControlHandle { inner: self.inner.clone() }
7058    }
7059
7060    fn into_inner(
7061        self,
7062    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7063    {
7064        (self.inner, self.is_terminated)
7065    }
7066
7067    fn from_inner(
7068        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7069        is_terminated: bool,
7070    ) -> Self {
7071        Self { inner, is_terminated }
7072    }
7073}
7074
7075impl futures::Stream for ScreenCaptureRequestStream {
7076    type Item = Result<ScreenCaptureRequest, fidl::Error>;
7077
7078    fn poll_next(
7079        mut self: std::pin::Pin<&mut Self>,
7080        cx: &mut std::task::Context<'_>,
7081    ) -> std::task::Poll<Option<Self::Item>> {
7082        let this = &mut *self;
7083        if this.inner.check_shutdown(cx) {
7084            this.is_terminated = true;
7085            return std::task::Poll::Ready(None);
7086        }
7087        if this.is_terminated {
7088            panic!("polled ScreenCaptureRequestStream after completion");
7089        }
7090        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7091            |bytes, handles| {
7092                match this.inner.channel().read_etc(cx, bytes, handles) {
7093                    std::task::Poll::Ready(Ok(())) => {}
7094                    std::task::Poll::Pending => return std::task::Poll::Pending,
7095                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7096                        this.is_terminated = true;
7097                        return std::task::Poll::Ready(None);
7098                    }
7099                    std::task::Poll::Ready(Err(e)) => {
7100                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7101                            e.into(),
7102                        ))));
7103                    }
7104                }
7105
7106                // A message has been received from the channel
7107                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7108
7109                std::task::Poll::Ready(Some(match header.ordinal {
7110                    0x3b6e5af1d294afd9 => {
7111                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7112                        let mut req = fidl::new_empty!(
7113                            ScreenCaptureConfig,
7114                            fidl::encoding::DefaultFuchsiaResourceDialect
7115                        );
7116                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenCaptureConfig>(&header, _body_bytes, handles, &mut req)?;
7117                        let control_handle =
7118                            ScreenCaptureControlHandle { inner: this.inner.clone() };
7119                        Ok(ScreenCaptureRequest::Configure {
7120                            payload: req,
7121                            responder: ScreenCaptureConfigureResponder {
7122                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7123                                tx_id: header.tx_id,
7124                            },
7125                        })
7126                    }
7127                    0x552c1580aab8c4a7 => {
7128                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7129                        let mut req = fidl::new_empty!(
7130                            GetNextFrameArgs,
7131                            fidl::encoding::DefaultFuchsiaResourceDialect
7132                        );
7133                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GetNextFrameArgs>(&header, _body_bytes, handles, &mut req)?;
7134                        let control_handle =
7135                            ScreenCaptureControlHandle { inner: this.inner.clone() };
7136                        Ok(ScreenCaptureRequest::GetNextFrame {
7137                            payload: req,
7138                            responder: ScreenCaptureGetNextFrameResponder {
7139                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7140                                tx_id: header.tx_id,
7141                            },
7142                        })
7143                    }
7144                    0x46704dce24e35950 => {
7145                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7146                        let mut req = fidl::new_empty!(
7147                            ScreenCaptureReleaseFrameRequest,
7148                            fidl::encoding::DefaultFuchsiaResourceDialect
7149                        );
7150                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenCaptureReleaseFrameRequest>(&header, _body_bytes, handles, &mut req)?;
7151                        let control_handle =
7152                            ScreenCaptureControlHandle { inner: this.inner.clone() };
7153                        Ok(ScreenCaptureRequest::ReleaseFrame {
7154                            buffer_id: req.buffer_id,
7155
7156                            responder: ScreenCaptureReleaseFrameResponder {
7157                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7158                                tx_id: header.tx_id,
7159                            },
7160                        })
7161                    }
7162                    _ => Err(fidl::Error::UnknownOrdinal {
7163                        ordinal: header.ordinal,
7164                        protocol_name:
7165                            <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7166                    }),
7167                }))
7168            },
7169        )
7170    }
7171}
7172
7173/// This protocol provides a low-level ScreenCapture API for clients to use.
7174/// ScreenCapture clients should familiarize themselves with the
7175/// [`fuchsia.sysmem/BufferCollection`] and [`fuchsia.ui.composition/Allocator`] protocols
7176/// as those are necessary to create the BufferCollections and images ScreenCapture uses.
7177#[derive(Debug)]
7178pub enum ScreenCaptureRequest {
7179    /// Clients should first use the Allocator protocol to register a
7180    /// BufferCollection. This function will fail with BAD_OPERATION unless all clients of the
7181    /// BufferCollection have set their constraints.
7182    ///
7183    /// Afterwards, clients should create and configure the images that will
7184    /// eventually be rendered to using this method. All the buffers in the
7185    /// collection from 0 to (buffer_count-1) may be used for screen capture.
7186    ///
7187    /// Clients are responsible for determining the rotation of the display,
7188    /// and applying the corrective rotation. For instance, if the display is
7189    /// mounted 90 degrees clockwise (the "top" is on the right, when looking
7190    /// at the display), then the client should specify a 270 degree rotation
7191    /// to account for it.
7192    ///
7193    /// Similarly, the clients are responsible for specifying a buffer big
7194    /// enough for the rotated image. If the buffer is too small, a best effort
7195    /// attempt will be made to render the image.
7196    ///
7197    /// Finally, clients request the server to render the current screen to the
7198    /// shared buffers using [`GetNextFrame`].
7199    ///
7200    /// [`Configure`] can be called again with a new BufferCollectionImportToken
7201    /// if the client wishes to change any of the configuration settings. In
7202    /// this case all the buffers from the previous call to [`Configure`] will
7203    /// be released.
7204    Configure { payload: ScreenCaptureConfig, responder: ScreenCaptureConfigureResponder },
7205    /// Following a successful call to [`Configure`], clients can call
7206    /// GetNextFrame. This will populate a buffer with the most recent frame.
7207    ///
7208    /// Clients should wait on the zx::event they pass for successful
7209    /// completion of the screenshot. It is not guaranteed that the screenshot
7210    /// will be completed by the time this function returns.
7211    ///
7212    /// The requested image will be in the BufferCollection that the client set
7213    /// up in the VMO at the index specified by buffer_id.
7214    ///
7215    /// When ScreenCapture is used to provide a stream, the rate that the
7216    /// client calls GetNextFrame will drive the frame rate.
7217    ///
7218    /// Errors:
7219    /// BAD_OPERATION if Configure was not called, or not called successfully
7220    /// MISSING_ARGS if a required argument is not present
7221    /// BUFFER_FULL if all buffers in the BufferCollection are in use. In this case, ReleaseFrame
7222    /// must be called to make a buffer available before this function can be called successfully.
7223    GetNextFrame { payload: GetNextFrameArgs, responder: ScreenCaptureGetNextFrameResponder },
7224    /// Once the client no longer needs an image, they can call ReleaseFrame on
7225    /// the VMO index of the buffer so that the server can reuse it in the future.
7226    ReleaseFrame { buffer_id: u32, responder: ScreenCaptureReleaseFrameResponder },
7227}
7228
7229impl ScreenCaptureRequest {
7230    #[allow(irrefutable_let_patterns)]
7231    pub fn into_configure(self) -> Option<(ScreenCaptureConfig, ScreenCaptureConfigureResponder)> {
7232        if let ScreenCaptureRequest::Configure { payload, responder } = self {
7233            Some((payload, responder))
7234        } else {
7235            None
7236        }
7237    }
7238
7239    #[allow(irrefutable_let_patterns)]
7240    pub fn into_get_next_frame(
7241        self,
7242    ) -> Option<(GetNextFrameArgs, ScreenCaptureGetNextFrameResponder)> {
7243        if let ScreenCaptureRequest::GetNextFrame { payload, responder } = self {
7244            Some((payload, responder))
7245        } else {
7246            None
7247        }
7248    }
7249
7250    #[allow(irrefutable_let_patterns)]
7251    pub fn into_release_frame(self) -> Option<(u32, ScreenCaptureReleaseFrameResponder)> {
7252        if let ScreenCaptureRequest::ReleaseFrame { buffer_id, responder } = self {
7253            Some((buffer_id, responder))
7254        } else {
7255            None
7256        }
7257    }
7258
7259    /// Name of the method defined in FIDL
7260    pub fn method_name(&self) -> &'static str {
7261        match *self {
7262            ScreenCaptureRequest::Configure { .. } => "configure",
7263            ScreenCaptureRequest::GetNextFrame { .. } => "get_next_frame",
7264            ScreenCaptureRequest::ReleaseFrame { .. } => "release_frame",
7265        }
7266    }
7267}
7268
7269#[derive(Debug, Clone)]
7270pub struct ScreenCaptureControlHandle {
7271    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7272}
7273
7274impl fidl::endpoints::ControlHandle for ScreenCaptureControlHandle {
7275    fn shutdown(&self) {
7276        self.inner.shutdown()
7277    }
7278
7279    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7280        self.inner.shutdown_with_epitaph(status)
7281    }
7282
7283    fn is_closed(&self) -> bool {
7284        self.inner.channel().is_closed()
7285    }
7286    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7287        self.inner.channel().on_closed()
7288    }
7289
7290    #[cfg(target_os = "fuchsia")]
7291    fn signal_peer(
7292        &self,
7293        clear_mask: zx::Signals,
7294        set_mask: zx::Signals,
7295    ) -> Result<(), zx_status::Status> {
7296        use fidl::Peered;
7297        self.inner.channel().signal_peer(clear_mask, set_mask)
7298    }
7299}
7300
7301impl ScreenCaptureControlHandle {}
7302
7303#[must_use = "FIDL methods require a response to be sent"]
7304#[derive(Debug)]
7305pub struct ScreenCaptureConfigureResponder {
7306    control_handle: std::mem::ManuallyDrop<ScreenCaptureControlHandle>,
7307    tx_id: u32,
7308}
7309
7310/// Set the the channel to be shutdown (see [`ScreenCaptureControlHandle::shutdown`])
7311/// if the responder is dropped without sending a response, so that the client
7312/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7313impl std::ops::Drop for ScreenCaptureConfigureResponder {
7314    fn drop(&mut self) {
7315        self.control_handle.shutdown();
7316        // Safety: drops once, never accessed again
7317        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7318    }
7319}
7320
7321impl fidl::endpoints::Responder for ScreenCaptureConfigureResponder {
7322    type ControlHandle = ScreenCaptureControlHandle;
7323
7324    fn control_handle(&self) -> &ScreenCaptureControlHandle {
7325        &self.control_handle
7326    }
7327
7328    fn drop_without_shutdown(mut self) {
7329        // Safety: drops once, never accessed again due to mem::forget
7330        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7331        // Prevent Drop from running (which would shut down the channel)
7332        std::mem::forget(self);
7333    }
7334}
7335
7336impl ScreenCaptureConfigureResponder {
7337    /// Sends a response to the FIDL transaction.
7338    ///
7339    /// Sets the channel to shutdown if an error occurs.
7340    pub fn send(self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7341        let _result = self.send_raw(result);
7342        if _result.is_err() {
7343            self.control_handle.shutdown();
7344        }
7345        self.drop_without_shutdown();
7346        _result
7347    }
7348
7349    /// Similar to "send" but does not shutdown the channel if an error occurs.
7350    pub fn send_no_shutdown_on_err(
7351        self,
7352        mut result: Result<(), ScreenCaptureError>,
7353    ) -> Result<(), fidl::Error> {
7354        let _result = self.send_raw(result);
7355        self.drop_without_shutdown();
7356        _result
7357    }
7358
7359    fn send_raw(&self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7360        self.control_handle.inner.send::<fidl::encoding::ResultType<
7361            fidl::encoding::EmptyStruct,
7362            ScreenCaptureError,
7363        >>(
7364            result,
7365            self.tx_id,
7366            0x3b6e5af1d294afd9,
7367            fidl::encoding::DynamicFlags::empty(),
7368        )
7369    }
7370}
7371
7372#[must_use = "FIDL methods require a response to be sent"]
7373#[derive(Debug)]
7374pub struct ScreenCaptureGetNextFrameResponder {
7375    control_handle: std::mem::ManuallyDrop<ScreenCaptureControlHandle>,
7376    tx_id: u32,
7377}
7378
7379/// Set the the channel to be shutdown (see [`ScreenCaptureControlHandle::shutdown`])
7380/// if the responder is dropped without sending a response, so that the client
7381/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7382impl std::ops::Drop for ScreenCaptureGetNextFrameResponder {
7383    fn drop(&mut self) {
7384        self.control_handle.shutdown();
7385        // Safety: drops once, never accessed again
7386        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7387    }
7388}
7389
7390impl fidl::endpoints::Responder for ScreenCaptureGetNextFrameResponder {
7391    type ControlHandle = ScreenCaptureControlHandle;
7392
7393    fn control_handle(&self) -> &ScreenCaptureControlHandle {
7394        &self.control_handle
7395    }
7396
7397    fn drop_without_shutdown(mut self) {
7398        // Safety: drops once, never accessed again due to mem::forget
7399        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7400        // Prevent Drop from running (which would shut down the channel)
7401        std::mem::forget(self);
7402    }
7403}
7404
7405impl ScreenCaptureGetNextFrameResponder {
7406    /// Sends a response to the FIDL transaction.
7407    ///
7408    /// Sets the channel to shutdown if an error occurs.
7409    pub fn send(
7410        self,
7411        mut result: Result<FrameInfo, ScreenCaptureError>,
7412    ) -> Result<(), fidl::Error> {
7413        let _result = self.send_raw(result);
7414        if _result.is_err() {
7415            self.control_handle.shutdown();
7416        }
7417        self.drop_without_shutdown();
7418        _result
7419    }
7420
7421    /// Similar to "send" but does not shutdown the channel if an error occurs.
7422    pub fn send_no_shutdown_on_err(
7423        self,
7424        mut result: Result<FrameInfo, ScreenCaptureError>,
7425    ) -> Result<(), fidl::Error> {
7426        let _result = self.send_raw(result);
7427        self.drop_without_shutdown();
7428        _result
7429    }
7430
7431    fn send_raw(
7432        &self,
7433        mut result: Result<FrameInfo, ScreenCaptureError>,
7434    ) -> Result<(), fidl::Error> {
7435        self.control_handle.inner.send::<fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>>(
7436            result.as_mut().map_err(|e| *e),
7437            self.tx_id,
7438            0x552c1580aab8c4a7,
7439            fidl::encoding::DynamicFlags::empty(),
7440        )
7441    }
7442}
7443
7444#[must_use = "FIDL methods require a response to be sent"]
7445#[derive(Debug)]
7446pub struct ScreenCaptureReleaseFrameResponder {
7447    control_handle: std::mem::ManuallyDrop<ScreenCaptureControlHandle>,
7448    tx_id: u32,
7449}
7450
7451/// Set the the channel to be shutdown (see [`ScreenCaptureControlHandle::shutdown`])
7452/// if the responder is dropped without sending a response, so that the client
7453/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7454impl std::ops::Drop for ScreenCaptureReleaseFrameResponder {
7455    fn drop(&mut self) {
7456        self.control_handle.shutdown();
7457        // Safety: drops once, never accessed again
7458        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7459    }
7460}
7461
7462impl fidl::endpoints::Responder for ScreenCaptureReleaseFrameResponder {
7463    type ControlHandle = ScreenCaptureControlHandle;
7464
7465    fn control_handle(&self) -> &ScreenCaptureControlHandle {
7466        &self.control_handle
7467    }
7468
7469    fn drop_without_shutdown(mut self) {
7470        // Safety: drops once, never accessed again due to mem::forget
7471        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7472        // Prevent Drop from running (which would shut down the channel)
7473        std::mem::forget(self);
7474    }
7475}
7476
7477impl ScreenCaptureReleaseFrameResponder {
7478    /// Sends a response to the FIDL transaction.
7479    ///
7480    /// Sets the channel to shutdown if an error occurs.
7481    pub fn send(self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7482        let _result = self.send_raw(result);
7483        if _result.is_err() {
7484            self.control_handle.shutdown();
7485        }
7486        self.drop_without_shutdown();
7487        _result
7488    }
7489
7490    /// Similar to "send" but does not shutdown the channel if an error occurs.
7491    pub fn send_no_shutdown_on_err(
7492        self,
7493        mut result: Result<(), ScreenCaptureError>,
7494    ) -> Result<(), fidl::Error> {
7495        let _result = self.send_raw(result);
7496        self.drop_without_shutdown();
7497        _result
7498    }
7499
7500    fn send_raw(&self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7501        self.control_handle.inner.send::<fidl::encoding::ResultType<
7502            fidl::encoding::EmptyStruct,
7503            ScreenCaptureError,
7504        >>(
7505            result,
7506            self.tx_id,
7507            0x46704dce24e35950,
7508            fidl::encoding::DynamicFlags::empty(),
7509        )
7510    }
7511}
7512
7513#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7514pub struct ScreenshotMarker;
7515
7516impl fidl::endpoints::ProtocolMarker for ScreenshotMarker {
7517    type Proxy = ScreenshotProxy;
7518    type RequestStream = ScreenshotRequestStream;
7519    #[cfg(target_os = "fuchsia")]
7520    type SynchronousProxy = ScreenshotSynchronousProxy;
7521
7522    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.Screenshot";
7523}
7524impl fidl::endpoints::DiscoverableProtocolMarker for ScreenshotMarker {}
7525
7526pub trait ScreenshotProxyInterface: Send + Sync {
7527    type TakeResponseFut: std::future::Future<Output = Result<ScreenshotTakeResponse, fidl::Error>>
7528        + Send;
7529    fn r#take(&self, payload: ScreenshotTakeRequest) -> Self::TakeResponseFut;
7530    type TakeFileResponseFut: std::future::Future<Output = Result<ScreenshotTakeFileResponse, fidl::Error>>
7531        + Send;
7532    fn r#take_file(&self, payload: ScreenshotTakeFileRequest) -> Self::TakeFileResponseFut;
7533}
7534#[derive(Debug)]
7535#[cfg(target_os = "fuchsia")]
7536pub struct ScreenshotSynchronousProxy {
7537    client: fidl::client::sync::Client,
7538}
7539
7540#[cfg(target_os = "fuchsia")]
7541impl fidl::endpoints::SynchronousProxy for ScreenshotSynchronousProxy {
7542    type Proxy = ScreenshotProxy;
7543    type Protocol = ScreenshotMarker;
7544
7545    fn from_channel(inner: fidl::Channel) -> Self {
7546        Self::new(inner)
7547    }
7548
7549    fn into_channel(self) -> fidl::Channel {
7550        self.client.into_channel()
7551    }
7552
7553    fn as_channel(&self) -> &fidl::Channel {
7554        self.client.as_channel()
7555    }
7556}
7557
7558#[cfg(target_os = "fuchsia")]
7559impl ScreenshotSynchronousProxy {
7560    pub fn new(channel: fidl::Channel) -> Self {
7561        Self { client: fidl::client::sync::Client::new(channel) }
7562    }
7563
7564    pub fn into_channel(self) -> fidl::Channel {
7565        self.client.into_channel()
7566    }
7567
7568    /// Waits until an event arrives and returns it. It is safe for other
7569    /// threads to make concurrent requests while waiting for an event.
7570    pub fn wait_for_event(
7571        &self,
7572        deadline: zx::MonotonicInstant,
7573    ) -> Result<ScreenshotEvent, fidl::Error> {
7574        ScreenshotEvent::decode(self.client.wait_for_event::<ScreenshotMarker>(deadline)?)
7575    }
7576
7577    /// Collects the current graphical content of a display in a specified buffer `format` in the
7578    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7579    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7580    /// linear color space.
7581    ///
7582    /// See https://fuchsia.dev/fuchsia-src/concepts/ui/scenic/color_spaces for more information.
7583    ///
7584    /// Screenshot is taken immediately, populated with the display's content from the most recent
7585    /// VSYNC.
7586    ///
7587    /// If the client calls [`Take`] a second time before a first [`Take`] call returns, the server
7588    /// will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7589    ///
7590    /// If capture fails due to an internal error, the server will close the Screenshot connection
7591    /// with a ZX_ERR_INTERNAL epitaph.
7592    pub fn r#take(
7593        &self,
7594        mut payload: ScreenshotTakeRequest,
7595        ___deadline: zx::MonotonicInstant,
7596    ) -> Result<ScreenshotTakeResponse, fidl::Error> {
7597        let _response = self
7598            .client
7599            .send_query::<ScreenshotTakeRequest, ScreenshotTakeResponse, ScreenshotMarker>(
7600                &mut payload,
7601                0x51341396e9fd2fd0,
7602                fidl::encoding::DynamicFlags::empty(),
7603                ___deadline,
7604            )?;
7605        Ok(_response)
7606    }
7607
7608    /// Collects the current graphical content of a display in a specified buffer `format` in the
7609    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7610    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7611    /// linear color space.
7612    ///
7613    /// TODO(https://fxbug.dev/42065844): Link to fuchsia.dev documentation when it's up.
7614    ///
7615    /// Screenshot is taken immediately, populated with the display's content from the most recent
7616    /// VSYNC.
7617    ///
7618    /// If the client calls [`TakeFile`] a second time before a first [`TakeFile`] call returns,
7619    /// the server will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7620    ///
7621    /// If capture fails due to an internal error, the server will close the Screenshot connection
7622    /// with a ZX_ERR_INTERNAL epitaph.
7623    ///
7624    /// This call should be used if the client is on the host and does not support VMOs,
7625    /// as is the case for ffx tools.
7626    pub fn r#take_file(
7627        &self,
7628        mut payload: ScreenshotTakeFileRequest,
7629        ___deadline: zx::MonotonicInstant,
7630    ) -> Result<ScreenshotTakeFileResponse, fidl::Error> {
7631        let _response = self
7632            .client
7633            .send_query::<ScreenshotTakeFileRequest, ScreenshotTakeFileResponse, ScreenshotMarker>(
7634                &mut payload,
7635                0x470aeea0a4d32903,
7636                fidl::encoding::DynamicFlags::empty(),
7637                ___deadline,
7638            )?;
7639        Ok(_response)
7640    }
7641}
7642
7643#[cfg(target_os = "fuchsia")]
7644impl From<ScreenshotSynchronousProxy> for zx::NullableHandle {
7645    fn from(value: ScreenshotSynchronousProxy) -> Self {
7646        value.into_channel().into()
7647    }
7648}
7649
7650#[cfg(target_os = "fuchsia")]
7651impl From<fidl::Channel> for ScreenshotSynchronousProxy {
7652    fn from(value: fidl::Channel) -> Self {
7653        Self::new(value)
7654    }
7655}
7656
7657#[cfg(target_os = "fuchsia")]
7658impl fidl::endpoints::FromClient for ScreenshotSynchronousProxy {
7659    type Protocol = ScreenshotMarker;
7660
7661    fn from_client(value: fidl::endpoints::ClientEnd<ScreenshotMarker>) -> Self {
7662        Self::new(value.into_channel())
7663    }
7664}
7665
7666#[derive(Debug, Clone)]
7667pub struct ScreenshotProxy {
7668    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7669}
7670
7671impl fidl::endpoints::Proxy for ScreenshotProxy {
7672    type Protocol = ScreenshotMarker;
7673
7674    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7675        Self::new(inner)
7676    }
7677
7678    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7679        self.client.into_channel().map_err(|client| Self { client })
7680    }
7681
7682    fn as_channel(&self) -> &::fidl::AsyncChannel {
7683        self.client.as_channel()
7684    }
7685}
7686
7687impl ScreenshotProxy {
7688    /// Create a new Proxy for fuchsia.ui.composition/Screenshot.
7689    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7690        let protocol_name = <ScreenshotMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7691        Self { client: fidl::client::Client::new(channel, protocol_name) }
7692    }
7693
7694    /// Get a Stream of events from the remote end of the protocol.
7695    ///
7696    /// # Panics
7697    ///
7698    /// Panics if the event stream was already taken.
7699    pub fn take_event_stream(&self) -> ScreenshotEventStream {
7700        ScreenshotEventStream { event_receiver: self.client.take_event_receiver() }
7701    }
7702
7703    /// Collects the current graphical content of a display in a specified buffer `format` in the
7704    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7705    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7706    /// linear color space.
7707    ///
7708    /// See https://fuchsia.dev/fuchsia-src/concepts/ui/scenic/color_spaces for more information.
7709    ///
7710    /// Screenshot is taken immediately, populated with the display's content from the most recent
7711    /// VSYNC.
7712    ///
7713    /// If the client calls [`Take`] a second time before a first [`Take`] call returns, the server
7714    /// will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7715    ///
7716    /// If capture fails due to an internal error, the server will close the Screenshot connection
7717    /// with a ZX_ERR_INTERNAL epitaph.
7718    pub fn r#take(
7719        &self,
7720        mut payload: ScreenshotTakeRequest,
7721    ) -> fidl::client::QueryResponseFut<
7722        ScreenshotTakeResponse,
7723        fidl::encoding::DefaultFuchsiaResourceDialect,
7724    > {
7725        ScreenshotProxyInterface::r#take(self, payload)
7726    }
7727
7728    /// Collects the current graphical content of a display in a specified buffer `format` in the
7729    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7730    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7731    /// linear color space.
7732    ///
7733    /// TODO(https://fxbug.dev/42065844): Link to fuchsia.dev documentation when it's up.
7734    ///
7735    /// Screenshot is taken immediately, populated with the display's content from the most recent
7736    /// VSYNC.
7737    ///
7738    /// If the client calls [`TakeFile`] a second time before a first [`TakeFile`] call returns,
7739    /// the server will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7740    ///
7741    /// If capture fails due to an internal error, the server will close the Screenshot connection
7742    /// with a ZX_ERR_INTERNAL epitaph.
7743    ///
7744    /// This call should be used if the client is on the host and does not support VMOs,
7745    /// as is the case for ffx tools.
7746    pub fn r#take_file(
7747        &self,
7748        mut payload: ScreenshotTakeFileRequest,
7749    ) -> fidl::client::QueryResponseFut<
7750        ScreenshotTakeFileResponse,
7751        fidl::encoding::DefaultFuchsiaResourceDialect,
7752    > {
7753        ScreenshotProxyInterface::r#take_file(self, payload)
7754    }
7755}
7756
7757impl ScreenshotProxyInterface for ScreenshotProxy {
7758    type TakeResponseFut = fidl::client::QueryResponseFut<
7759        ScreenshotTakeResponse,
7760        fidl::encoding::DefaultFuchsiaResourceDialect,
7761    >;
7762    fn r#take(&self, mut payload: ScreenshotTakeRequest) -> Self::TakeResponseFut {
7763        fn _decode(
7764            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7765        ) -> Result<ScreenshotTakeResponse, fidl::Error> {
7766            let _response = fidl::client::decode_transaction_body::<
7767                ScreenshotTakeResponse,
7768                fidl::encoding::DefaultFuchsiaResourceDialect,
7769                0x51341396e9fd2fd0,
7770            >(_buf?)?;
7771            Ok(_response)
7772        }
7773        self.client.send_query_and_decode::<ScreenshotTakeRequest, ScreenshotTakeResponse>(
7774            &mut payload,
7775            0x51341396e9fd2fd0,
7776            fidl::encoding::DynamicFlags::empty(),
7777            _decode,
7778        )
7779    }
7780
7781    type TakeFileResponseFut = fidl::client::QueryResponseFut<
7782        ScreenshotTakeFileResponse,
7783        fidl::encoding::DefaultFuchsiaResourceDialect,
7784    >;
7785    fn r#take_file(&self, mut payload: ScreenshotTakeFileRequest) -> Self::TakeFileResponseFut {
7786        fn _decode(
7787            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7788        ) -> Result<ScreenshotTakeFileResponse, fidl::Error> {
7789            let _response = fidl::client::decode_transaction_body::<
7790                ScreenshotTakeFileResponse,
7791                fidl::encoding::DefaultFuchsiaResourceDialect,
7792                0x470aeea0a4d32903,
7793            >(_buf?)?;
7794            Ok(_response)
7795        }
7796        self.client.send_query_and_decode::<ScreenshotTakeFileRequest, ScreenshotTakeFileResponse>(
7797            &mut payload,
7798            0x470aeea0a4d32903,
7799            fidl::encoding::DynamicFlags::empty(),
7800            _decode,
7801        )
7802    }
7803}
7804
7805pub struct ScreenshotEventStream {
7806    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7807}
7808
7809impl std::marker::Unpin for ScreenshotEventStream {}
7810
7811impl futures::stream::FusedStream for ScreenshotEventStream {
7812    fn is_terminated(&self) -> bool {
7813        self.event_receiver.is_terminated()
7814    }
7815}
7816
7817impl futures::Stream for ScreenshotEventStream {
7818    type Item = Result<ScreenshotEvent, fidl::Error>;
7819
7820    fn poll_next(
7821        mut self: std::pin::Pin<&mut Self>,
7822        cx: &mut std::task::Context<'_>,
7823    ) -> std::task::Poll<Option<Self::Item>> {
7824        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7825            &mut self.event_receiver,
7826            cx
7827        )?) {
7828            Some(buf) => std::task::Poll::Ready(Some(ScreenshotEvent::decode(buf))),
7829            None => std::task::Poll::Ready(None),
7830        }
7831    }
7832}
7833
7834#[derive(Debug)]
7835pub enum ScreenshotEvent {}
7836
7837impl ScreenshotEvent {
7838    /// Decodes a message buffer as a [`ScreenshotEvent`].
7839    fn decode(
7840        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7841    ) -> Result<ScreenshotEvent, fidl::Error> {
7842        let (bytes, _handles) = buf.split_mut();
7843        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7844        debug_assert_eq!(tx_header.tx_id, 0);
7845        match tx_header.ordinal {
7846            _ => Err(fidl::Error::UnknownOrdinal {
7847                ordinal: tx_header.ordinal,
7848                protocol_name: <ScreenshotMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7849            }),
7850        }
7851    }
7852}
7853
7854/// A Stream of incoming requests for fuchsia.ui.composition/Screenshot.
7855pub struct ScreenshotRequestStream {
7856    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7857    is_terminated: bool,
7858}
7859
7860impl std::marker::Unpin for ScreenshotRequestStream {}
7861
7862impl futures::stream::FusedStream for ScreenshotRequestStream {
7863    fn is_terminated(&self) -> bool {
7864        self.is_terminated
7865    }
7866}
7867
7868impl fidl::endpoints::RequestStream for ScreenshotRequestStream {
7869    type Protocol = ScreenshotMarker;
7870    type ControlHandle = ScreenshotControlHandle;
7871
7872    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7873        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7874    }
7875
7876    fn control_handle(&self) -> Self::ControlHandle {
7877        ScreenshotControlHandle { inner: self.inner.clone() }
7878    }
7879
7880    fn into_inner(
7881        self,
7882    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7883    {
7884        (self.inner, self.is_terminated)
7885    }
7886
7887    fn from_inner(
7888        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7889        is_terminated: bool,
7890    ) -> Self {
7891        Self { inner, is_terminated }
7892    }
7893}
7894
7895impl futures::Stream for ScreenshotRequestStream {
7896    type Item = Result<ScreenshotRequest, fidl::Error>;
7897
7898    fn poll_next(
7899        mut self: std::pin::Pin<&mut Self>,
7900        cx: &mut std::task::Context<'_>,
7901    ) -> std::task::Poll<Option<Self::Item>> {
7902        let this = &mut *self;
7903        if this.inner.check_shutdown(cx) {
7904            this.is_terminated = true;
7905            return std::task::Poll::Ready(None);
7906        }
7907        if this.is_terminated {
7908            panic!("polled ScreenshotRequestStream after completion");
7909        }
7910        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7911            |bytes, handles| {
7912                match this.inner.channel().read_etc(cx, bytes, handles) {
7913                    std::task::Poll::Ready(Ok(())) => {}
7914                    std::task::Poll::Pending => return std::task::Poll::Pending,
7915                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7916                        this.is_terminated = true;
7917                        return std::task::Poll::Ready(None);
7918                    }
7919                    std::task::Poll::Ready(Err(e)) => {
7920                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7921                            e.into(),
7922                        ))));
7923                    }
7924                }
7925
7926                // A message has been received from the channel
7927                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7928
7929                std::task::Poll::Ready(Some(match header.ordinal {
7930                    0x51341396e9fd2fd0 => {
7931                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7932                        let mut req = fidl::new_empty!(
7933                            ScreenshotTakeRequest,
7934                            fidl::encoding::DefaultFuchsiaResourceDialect
7935                        );
7936                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenshotTakeRequest>(&header, _body_bytes, handles, &mut req)?;
7937                        let control_handle = ScreenshotControlHandle { inner: this.inner.clone() };
7938                        Ok(ScreenshotRequest::Take {
7939                            payload: req,
7940                            responder: ScreenshotTakeResponder {
7941                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7942                                tx_id: header.tx_id,
7943                            },
7944                        })
7945                    }
7946                    0x470aeea0a4d32903 => {
7947                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7948                        let mut req = fidl::new_empty!(
7949                            ScreenshotTakeFileRequest,
7950                            fidl::encoding::DefaultFuchsiaResourceDialect
7951                        );
7952                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenshotTakeFileRequest>(&header, _body_bytes, handles, &mut req)?;
7953                        let control_handle = ScreenshotControlHandle { inner: this.inner.clone() };
7954                        Ok(ScreenshotRequest::TakeFile {
7955                            payload: req,
7956                            responder: ScreenshotTakeFileResponder {
7957                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7958                                tx_id: header.tx_id,
7959                            },
7960                        })
7961                    }
7962                    _ => Err(fidl::Error::UnknownOrdinal {
7963                        ordinal: header.ordinal,
7964                        protocol_name:
7965                            <ScreenshotMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7966                    }),
7967                }))
7968            },
7969        )
7970    }
7971}
7972
7973/// Collects the current graphical content of a display.
7974#[derive(Debug)]
7975pub enum ScreenshotRequest {
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    /// See https://fuchsia.dev/fuchsia-src/concepts/ui/scenic/color_spaces for more information.
7982    ///
7983    /// Screenshot is taken immediately, populated with the display's content from the most recent
7984    /// VSYNC.
7985    ///
7986    /// If the client calls [`Take`] a second time before a first [`Take`] call returns, the server
7987    /// 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    Take { payload: ScreenshotTakeRequest, responder: ScreenshotTakeResponder },
7992    /// Collects the current graphical content of a display in a specified buffer `format` in the
7993    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7994    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7995    /// linear color space.
7996    ///
7997    /// TODO(https://fxbug.dev/42065844): Link to fuchsia.dev documentation when it's up.
7998    ///
7999    /// Screenshot is taken immediately, populated with the display's content from the most recent
8000    /// VSYNC.
8001    ///
8002    /// If the client calls [`TakeFile`] a second time before a first [`TakeFile`] call returns,
8003    /// the server will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
8004    ///
8005    /// If capture fails due to an internal error, the server will close the Screenshot connection
8006    /// with a ZX_ERR_INTERNAL epitaph.
8007    ///
8008    /// This call should be used if the client is on the host and does not support VMOs,
8009    /// as is the case for ffx tools.
8010    TakeFile { payload: ScreenshotTakeFileRequest, responder: ScreenshotTakeFileResponder },
8011}
8012
8013impl ScreenshotRequest {
8014    #[allow(irrefutable_let_patterns)]
8015    pub fn into_take(self) -> Option<(ScreenshotTakeRequest, ScreenshotTakeResponder)> {
8016        if let ScreenshotRequest::Take { payload, responder } = self {
8017            Some((payload, responder))
8018        } else {
8019            None
8020        }
8021    }
8022
8023    #[allow(irrefutable_let_patterns)]
8024    pub fn into_take_file(
8025        self,
8026    ) -> Option<(ScreenshotTakeFileRequest, ScreenshotTakeFileResponder)> {
8027        if let ScreenshotRequest::TakeFile { payload, responder } = self {
8028            Some((payload, responder))
8029        } else {
8030            None
8031        }
8032    }
8033
8034    /// Name of the method defined in FIDL
8035    pub fn method_name(&self) -> &'static str {
8036        match *self {
8037            ScreenshotRequest::Take { .. } => "take",
8038            ScreenshotRequest::TakeFile { .. } => "take_file",
8039        }
8040    }
8041}
8042
8043#[derive(Debug, Clone)]
8044pub struct ScreenshotControlHandle {
8045    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8046}
8047
8048impl fidl::endpoints::ControlHandle for ScreenshotControlHandle {
8049    fn shutdown(&self) {
8050        self.inner.shutdown()
8051    }
8052
8053    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8054        self.inner.shutdown_with_epitaph(status)
8055    }
8056
8057    fn is_closed(&self) -> bool {
8058        self.inner.channel().is_closed()
8059    }
8060    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8061        self.inner.channel().on_closed()
8062    }
8063
8064    #[cfg(target_os = "fuchsia")]
8065    fn signal_peer(
8066        &self,
8067        clear_mask: zx::Signals,
8068        set_mask: zx::Signals,
8069    ) -> Result<(), zx_status::Status> {
8070        use fidl::Peered;
8071        self.inner.channel().signal_peer(clear_mask, set_mask)
8072    }
8073}
8074
8075impl ScreenshotControlHandle {}
8076
8077#[must_use = "FIDL methods require a response to be sent"]
8078#[derive(Debug)]
8079pub struct ScreenshotTakeResponder {
8080    control_handle: std::mem::ManuallyDrop<ScreenshotControlHandle>,
8081    tx_id: u32,
8082}
8083
8084/// Set the the channel to be shutdown (see [`ScreenshotControlHandle::shutdown`])
8085/// if the responder is dropped without sending a response, so that the client
8086/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8087impl std::ops::Drop for ScreenshotTakeResponder {
8088    fn drop(&mut self) {
8089        self.control_handle.shutdown();
8090        // Safety: drops once, never accessed again
8091        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8092    }
8093}
8094
8095impl fidl::endpoints::Responder for ScreenshotTakeResponder {
8096    type ControlHandle = ScreenshotControlHandle;
8097
8098    fn control_handle(&self) -> &ScreenshotControlHandle {
8099        &self.control_handle
8100    }
8101
8102    fn drop_without_shutdown(mut self) {
8103        // Safety: drops once, never accessed again due to mem::forget
8104        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8105        // Prevent Drop from running (which would shut down the channel)
8106        std::mem::forget(self);
8107    }
8108}
8109
8110impl ScreenshotTakeResponder {
8111    /// Sends a response to the FIDL transaction.
8112    ///
8113    /// Sets the channel to shutdown if an error occurs.
8114    pub fn send(self, mut payload: ScreenshotTakeResponse) -> Result<(), fidl::Error> {
8115        let _result = self.send_raw(payload);
8116        if _result.is_err() {
8117            self.control_handle.shutdown();
8118        }
8119        self.drop_without_shutdown();
8120        _result
8121    }
8122
8123    /// Similar to "send" but does not shutdown the channel if an error occurs.
8124    pub fn send_no_shutdown_on_err(
8125        self,
8126        mut payload: ScreenshotTakeResponse,
8127    ) -> Result<(), fidl::Error> {
8128        let _result = self.send_raw(payload);
8129        self.drop_without_shutdown();
8130        _result
8131    }
8132
8133    fn send_raw(&self, mut payload: ScreenshotTakeResponse) -> Result<(), fidl::Error> {
8134        self.control_handle.inner.send::<ScreenshotTakeResponse>(
8135            &mut payload,
8136            self.tx_id,
8137            0x51341396e9fd2fd0,
8138            fidl::encoding::DynamicFlags::empty(),
8139        )
8140    }
8141}
8142
8143#[must_use = "FIDL methods require a response to be sent"]
8144#[derive(Debug)]
8145pub struct ScreenshotTakeFileResponder {
8146    control_handle: std::mem::ManuallyDrop<ScreenshotControlHandle>,
8147    tx_id: u32,
8148}
8149
8150/// Set the the channel to be shutdown (see [`ScreenshotControlHandle::shutdown`])
8151/// if the responder is dropped without sending a response, so that the client
8152/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8153impl std::ops::Drop for ScreenshotTakeFileResponder {
8154    fn drop(&mut self) {
8155        self.control_handle.shutdown();
8156        // Safety: drops once, never accessed again
8157        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8158    }
8159}
8160
8161impl fidl::endpoints::Responder for ScreenshotTakeFileResponder {
8162    type ControlHandle = ScreenshotControlHandle;
8163
8164    fn control_handle(&self) -> &ScreenshotControlHandle {
8165        &self.control_handle
8166    }
8167
8168    fn drop_without_shutdown(mut self) {
8169        // Safety: drops once, never accessed again due to mem::forget
8170        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8171        // Prevent Drop from running (which would shut down the channel)
8172        std::mem::forget(self);
8173    }
8174}
8175
8176impl ScreenshotTakeFileResponder {
8177    /// Sends a response to the FIDL transaction.
8178    ///
8179    /// Sets the channel to shutdown if an error occurs.
8180    pub fn send(self, mut payload: ScreenshotTakeFileResponse) -> Result<(), fidl::Error> {
8181        let _result = self.send_raw(payload);
8182        if _result.is_err() {
8183            self.control_handle.shutdown();
8184        }
8185        self.drop_without_shutdown();
8186        _result
8187    }
8188
8189    /// Similar to "send" but does not shutdown the channel if an error occurs.
8190    pub fn send_no_shutdown_on_err(
8191        self,
8192        mut payload: ScreenshotTakeFileResponse,
8193    ) -> Result<(), fidl::Error> {
8194        let _result = self.send_raw(payload);
8195        self.drop_without_shutdown();
8196        _result
8197    }
8198
8199    fn send_raw(&self, mut payload: ScreenshotTakeFileResponse) -> Result<(), fidl::Error> {
8200        self.control_handle.inner.send::<ScreenshotTakeFileResponse>(
8201            &mut payload,
8202            self.tx_id,
8203            0x470aeea0a4d32903,
8204            fidl::encoding::DynamicFlags::empty(),
8205        )
8206    }
8207}
8208
8209#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8210pub struct TrustedFlatlandMarker;
8211
8212impl fidl::endpoints::ProtocolMarker for TrustedFlatlandMarker {
8213    type Proxy = TrustedFlatlandProxy;
8214    type RequestStream = TrustedFlatlandRequestStream;
8215    #[cfg(target_os = "fuchsia")]
8216    type SynchronousProxy = TrustedFlatlandSynchronousProxy;
8217
8218    const DEBUG_NAME: &'static str = "(anonymous) TrustedFlatland";
8219}
8220
8221pub trait TrustedFlatlandProxyInterface: Send + Sync {
8222    fn r#release_image_immediately(&self, image_id: &ContentId) -> Result<(), fidl::Error>;
8223}
8224#[derive(Debug)]
8225#[cfg(target_os = "fuchsia")]
8226pub struct TrustedFlatlandSynchronousProxy {
8227    client: fidl::client::sync::Client,
8228}
8229
8230#[cfg(target_os = "fuchsia")]
8231impl fidl::endpoints::SynchronousProxy for TrustedFlatlandSynchronousProxy {
8232    type Proxy = TrustedFlatlandProxy;
8233    type Protocol = TrustedFlatlandMarker;
8234
8235    fn from_channel(inner: fidl::Channel) -> Self {
8236        Self::new(inner)
8237    }
8238
8239    fn into_channel(self) -> fidl::Channel {
8240        self.client.into_channel()
8241    }
8242
8243    fn as_channel(&self) -> &fidl::Channel {
8244        self.client.as_channel()
8245    }
8246}
8247
8248#[cfg(target_os = "fuchsia")]
8249impl TrustedFlatlandSynchronousProxy {
8250    pub fn new(channel: fidl::Channel) -> Self {
8251        Self { client: fidl::client::sync::Client::new(channel) }
8252    }
8253
8254    pub fn into_channel(self) -> fidl::Channel {
8255        self.client.into_channel()
8256    }
8257
8258    /// Waits until an event arrives and returns it. It is safe for other
8259    /// threads to make concurrent requests while waiting for an event.
8260    pub fn wait_for_event(
8261        &self,
8262        deadline: zx::MonotonicInstant,
8263    ) -> Result<TrustedFlatlandEvent, fidl::Error> {
8264        TrustedFlatlandEvent::decode(self.client.wait_for_event::<TrustedFlatlandMarker>(deadline)?)
8265    }
8266
8267    /// Releases an image immediately, without waiting for the next present.
8268    pub fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
8269        self.client.send::<TrustedFlatlandReleaseImageImmediatelyRequest>(
8270            (image_id,),
8271            0x245e1ac080772c8,
8272            fidl::encoding::DynamicFlags::empty(),
8273        )
8274    }
8275}
8276
8277#[cfg(target_os = "fuchsia")]
8278impl From<TrustedFlatlandSynchronousProxy> for zx::NullableHandle {
8279    fn from(value: TrustedFlatlandSynchronousProxy) -> Self {
8280        value.into_channel().into()
8281    }
8282}
8283
8284#[cfg(target_os = "fuchsia")]
8285impl From<fidl::Channel> for TrustedFlatlandSynchronousProxy {
8286    fn from(value: fidl::Channel) -> Self {
8287        Self::new(value)
8288    }
8289}
8290
8291#[cfg(target_os = "fuchsia")]
8292impl fidl::endpoints::FromClient for TrustedFlatlandSynchronousProxy {
8293    type Protocol = TrustedFlatlandMarker;
8294
8295    fn from_client(value: fidl::endpoints::ClientEnd<TrustedFlatlandMarker>) -> Self {
8296        Self::new(value.into_channel())
8297    }
8298}
8299
8300#[derive(Debug, Clone)]
8301pub struct TrustedFlatlandProxy {
8302    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8303}
8304
8305impl fidl::endpoints::Proxy for TrustedFlatlandProxy {
8306    type Protocol = TrustedFlatlandMarker;
8307
8308    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8309        Self::new(inner)
8310    }
8311
8312    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8313        self.client.into_channel().map_err(|client| Self { client })
8314    }
8315
8316    fn as_channel(&self) -> &::fidl::AsyncChannel {
8317        self.client.as_channel()
8318    }
8319}
8320
8321impl TrustedFlatlandProxy {
8322    /// Create a new Proxy for fuchsia.ui.composition/TrustedFlatland.
8323    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8324        let protocol_name = <TrustedFlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8325        Self { client: fidl::client::Client::new(channel, protocol_name) }
8326    }
8327
8328    /// Get a Stream of events from the remote end of the protocol.
8329    ///
8330    /// # Panics
8331    ///
8332    /// Panics if the event stream was already taken.
8333    pub fn take_event_stream(&self) -> TrustedFlatlandEventStream {
8334        TrustedFlatlandEventStream { event_receiver: self.client.take_event_receiver() }
8335    }
8336
8337    /// Releases an image immediately, without waiting for the next present.
8338    pub fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
8339        TrustedFlatlandProxyInterface::r#release_image_immediately(self, image_id)
8340    }
8341}
8342
8343impl TrustedFlatlandProxyInterface for TrustedFlatlandProxy {
8344    fn r#release_image_immediately(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
8345        self.client.send::<TrustedFlatlandReleaseImageImmediatelyRequest>(
8346            (image_id,),
8347            0x245e1ac080772c8,
8348            fidl::encoding::DynamicFlags::empty(),
8349        )
8350    }
8351}
8352
8353pub struct TrustedFlatlandEventStream {
8354    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8355}
8356
8357impl std::marker::Unpin for TrustedFlatlandEventStream {}
8358
8359impl futures::stream::FusedStream for TrustedFlatlandEventStream {
8360    fn is_terminated(&self) -> bool {
8361        self.event_receiver.is_terminated()
8362    }
8363}
8364
8365impl futures::Stream for TrustedFlatlandEventStream {
8366    type Item = Result<TrustedFlatlandEvent, fidl::Error>;
8367
8368    fn poll_next(
8369        mut self: std::pin::Pin<&mut Self>,
8370        cx: &mut std::task::Context<'_>,
8371    ) -> std::task::Poll<Option<Self::Item>> {
8372        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8373            &mut self.event_receiver,
8374            cx
8375        )?) {
8376            Some(buf) => std::task::Poll::Ready(Some(TrustedFlatlandEvent::decode(buf))),
8377            None => std::task::Poll::Ready(None),
8378        }
8379    }
8380}
8381
8382#[derive(Debug)]
8383pub enum TrustedFlatlandEvent {}
8384
8385impl TrustedFlatlandEvent {
8386    /// Decodes a message buffer as a [`TrustedFlatlandEvent`].
8387    fn decode(
8388        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8389    ) -> Result<TrustedFlatlandEvent, fidl::Error> {
8390        let (bytes, _handles) = buf.split_mut();
8391        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8392        debug_assert_eq!(tx_header.tx_id, 0);
8393        match tx_header.ordinal {
8394            _ => Err(fidl::Error::UnknownOrdinal {
8395                ordinal: tx_header.ordinal,
8396                protocol_name:
8397                    <TrustedFlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8398            }),
8399        }
8400    }
8401}
8402
8403/// A Stream of incoming requests for fuchsia.ui.composition/TrustedFlatland.
8404pub struct TrustedFlatlandRequestStream {
8405    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8406    is_terminated: bool,
8407}
8408
8409impl std::marker::Unpin for TrustedFlatlandRequestStream {}
8410
8411impl futures::stream::FusedStream for TrustedFlatlandRequestStream {
8412    fn is_terminated(&self) -> bool {
8413        self.is_terminated
8414    }
8415}
8416
8417impl fidl::endpoints::RequestStream for TrustedFlatlandRequestStream {
8418    type Protocol = TrustedFlatlandMarker;
8419    type ControlHandle = TrustedFlatlandControlHandle;
8420
8421    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8422        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8423    }
8424
8425    fn control_handle(&self) -> Self::ControlHandle {
8426        TrustedFlatlandControlHandle { inner: self.inner.clone() }
8427    }
8428
8429    fn into_inner(
8430        self,
8431    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8432    {
8433        (self.inner, self.is_terminated)
8434    }
8435
8436    fn from_inner(
8437        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8438        is_terminated: bool,
8439    ) -> Self {
8440        Self { inner, is_terminated }
8441    }
8442}
8443
8444impl futures::Stream for TrustedFlatlandRequestStream {
8445    type Item = Result<TrustedFlatlandRequest, fidl::Error>;
8446
8447    fn poll_next(
8448        mut self: std::pin::Pin<&mut Self>,
8449        cx: &mut std::task::Context<'_>,
8450    ) -> std::task::Poll<Option<Self::Item>> {
8451        let this = &mut *self;
8452        if this.inner.check_shutdown(cx) {
8453            this.is_terminated = true;
8454            return std::task::Poll::Ready(None);
8455        }
8456        if this.is_terminated {
8457            panic!("polled TrustedFlatlandRequestStream after completion");
8458        }
8459        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8460            |bytes, handles| {
8461                match this.inner.channel().read_etc(cx, bytes, handles) {
8462                    std::task::Poll::Ready(Ok(())) => {}
8463                    std::task::Poll::Pending => return std::task::Poll::Pending,
8464                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8465                        this.is_terminated = true;
8466                        return std::task::Poll::Ready(None);
8467                    }
8468                    std::task::Poll::Ready(Err(e)) => {
8469                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8470                            e.into(),
8471                        ))));
8472                    }
8473                }
8474
8475                // A message has been received from the channel
8476                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8477
8478                std::task::Poll::Ready(Some(match header.ordinal {
8479                    0x245e1ac080772c8 => {
8480                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8481                        let mut req = fidl::new_empty!(
8482                            TrustedFlatlandReleaseImageImmediatelyRequest,
8483                            fidl::encoding::DefaultFuchsiaResourceDialect
8484                        );
8485                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TrustedFlatlandReleaseImageImmediatelyRequest>(&header, _body_bytes, handles, &mut req)?;
8486                        let control_handle =
8487                            TrustedFlatlandControlHandle { inner: this.inner.clone() };
8488                        Ok(TrustedFlatlandRequest::ReleaseImageImmediately {
8489                            image_id: req.image_id,
8490
8491                            control_handle,
8492                        })
8493                    }
8494                    _ => Err(fidl::Error::UnknownOrdinal {
8495                        ordinal: header.ordinal,
8496                        protocol_name:
8497                            <TrustedFlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8498                    }),
8499                }))
8500            },
8501        )
8502    }
8503}
8504
8505/// A privileged protocol for trusted Flatland instances that require special capabilities.
8506///
8507/// This protocol is composed into [`fuchsia.ui.composition/Flatland`]. Methods in this protocol
8508/// are only available if the `Flatland` instance was created through
8509/// [`fuchsia.ui.composition/TrustedFlatlandFactory`].
8510#[derive(Debug)]
8511pub enum TrustedFlatlandRequest {
8512    /// Releases an image immediately, without waiting for the next present.
8513    ReleaseImageImmediately { image_id: ContentId, control_handle: TrustedFlatlandControlHandle },
8514}
8515
8516impl TrustedFlatlandRequest {
8517    #[allow(irrefutable_let_patterns)]
8518    pub fn into_release_image_immediately(
8519        self,
8520    ) -> Option<(ContentId, TrustedFlatlandControlHandle)> {
8521        if let TrustedFlatlandRequest::ReleaseImageImmediately { image_id, control_handle } = self {
8522            Some((image_id, control_handle))
8523        } else {
8524            None
8525        }
8526    }
8527
8528    /// Name of the method defined in FIDL
8529    pub fn method_name(&self) -> &'static str {
8530        match *self {
8531            TrustedFlatlandRequest::ReleaseImageImmediately { .. } => "release_image_immediately",
8532        }
8533    }
8534}
8535
8536#[derive(Debug, Clone)]
8537pub struct TrustedFlatlandControlHandle {
8538    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8539}
8540
8541impl fidl::endpoints::ControlHandle for TrustedFlatlandControlHandle {
8542    fn shutdown(&self) {
8543        self.inner.shutdown()
8544    }
8545
8546    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8547        self.inner.shutdown_with_epitaph(status)
8548    }
8549
8550    fn is_closed(&self) -> bool {
8551        self.inner.channel().is_closed()
8552    }
8553    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8554        self.inner.channel().on_closed()
8555    }
8556
8557    #[cfg(target_os = "fuchsia")]
8558    fn signal_peer(
8559        &self,
8560        clear_mask: zx::Signals,
8561        set_mask: zx::Signals,
8562    ) -> Result<(), zx_status::Status> {
8563        use fidl::Peered;
8564        self.inner.channel().signal_peer(clear_mask, set_mask)
8565    }
8566}
8567
8568impl TrustedFlatlandControlHandle {}
8569
8570#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8571pub struct TrustedFlatlandFactoryMarker;
8572
8573impl fidl::endpoints::ProtocolMarker for TrustedFlatlandFactoryMarker {
8574    type Proxy = TrustedFlatlandFactoryProxy;
8575    type RequestStream = TrustedFlatlandFactoryRequestStream;
8576    #[cfg(target_os = "fuchsia")]
8577    type SynchronousProxy = TrustedFlatlandFactorySynchronousProxy;
8578
8579    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.TrustedFlatlandFactory";
8580}
8581impl fidl::endpoints::DiscoverableProtocolMarker for TrustedFlatlandFactoryMarker {}
8582pub type TrustedFlatlandFactoryCreateFlatlandResult = Result<(), TrustedFlatlandFactoryError>;
8583
8584pub trait TrustedFlatlandFactoryProxyInterface: Send + Sync {
8585    type CreateFlatlandResponseFut: std::future::Future<
8586            Output = Result<TrustedFlatlandFactoryCreateFlatlandResult, fidl::Error>,
8587        > + Send;
8588    fn r#create_flatland(
8589        &self,
8590        server_end: fidl::endpoints::ServerEnd<FlatlandMarker>,
8591        config: TrustedFlatlandConfig,
8592    ) -> Self::CreateFlatlandResponseFut;
8593}
8594#[derive(Debug)]
8595#[cfg(target_os = "fuchsia")]
8596pub struct TrustedFlatlandFactorySynchronousProxy {
8597    client: fidl::client::sync::Client,
8598}
8599
8600#[cfg(target_os = "fuchsia")]
8601impl fidl::endpoints::SynchronousProxy for TrustedFlatlandFactorySynchronousProxy {
8602    type Proxy = TrustedFlatlandFactoryProxy;
8603    type Protocol = TrustedFlatlandFactoryMarker;
8604
8605    fn from_channel(inner: fidl::Channel) -> Self {
8606        Self::new(inner)
8607    }
8608
8609    fn into_channel(self) -> fidl::Channel {
8610        self.client.into_channel()
8611    }
8612
8613    fn as_channel(&self) -> &fidl::Channel {
8614        self.client.as_channel()
8615    }
8616}
8617
8618#[cfg(target_os = "fuchsia")]
8619impl TrustedFlatlandFactorySynchronousProxy {
8620    pub fn new(channel: fidl::Channel) -> Self {
8621        Self { client: fidl::client::sync::Client::new(channel) }
8622    }
8623
8624    pub fn into_channel(self) -> fidl::Channel {
8625        self.client.into_channel()
8626    }
8627
8628    /// Waits until an event arrives and returns it. It is safe for other
8629    /// threads to make concurrent requests while waiting for an event.
8630    pub fn wait_for_event(
8631        &self,
8632        deadline: zx::MonotonicInstant,
8633    ) -> Result<TrustedFlatlandFactoryEvent, fidl::Error> {
8634        TrustedFlatlandFactoryEvent::decode(
8635            self.client.wait_for_event::<TrustedFlatlandFactoryMarker>(deadline)?,
8636        )
8637    }
8638
8639    /// Creates a new Flatland instance with the specified configuration.
8640    ///
8641    /// ## Error
8642    ///
8643    /// Returns a `TrustedFlatlandFactoryError` error if the operation fails.
8644    pub fn r#create_flatland(
8645        &self,
8646        mut server_end: fidl::endpoints::ServerEnd<FlatlandMarker>,
8647        mut config: TrustedFlatlandConfig,
8648        ___deadline: zx::MonotonicInstant,
8649    ) -> Result<TrustedFlatlandFactoryCreateFlatlandResult, fidl::Error> {
8650        let _response = self.client.send_query::<
8651            TrustedFlatlandFactoryCreateFlatlandRequest,
8652            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, TrustedFlatlandFactoryError>,
8653            TrustedFlatlandFactoryMarker,
8654        >(
8655            (server_end, &mut config,),
8656            0x48e89c53f00561dc,
8657            fidl::encoding::DynamicFlags::empty(),
8658            ___deadline,
8659        )?;
8660        Ok(_response.map(|x| x))
8661    }
8662}
8663
8664#[cfg(target_os = "fuchsia")]
8665impl From<TrustedFlatlandFactorySynchronousProxy> for zx::NullableHandle {
8666    fn from(value: TrustedFlatlandFactorySynchronousProxy) -> Self {
8667        value.into_channel().into()
8668    }
8669}
8670
8671#[cfg(target_os = "fuchsia")]
8672impl From<fidl::Channel> for TrustedFlatlandFactorySynchronousProxy {
8673    fn from(value: fidl::Channel) -> Self {
8674        Self::new(value)
8675    }
8676}
8677
8678#[cfg(target_os = "fuchsia")]
8679impl fidl::endpoints::FromClient for TrustedFlatlandFactorySynchronousProxy {
8680    type Protocol = TrustedFlatlandFactoryMarker;
8681
8682    fn from_client(value: fidl::endpoints::ClientEnd<TrustedFlatlandFactoryMarker>) -> Self {
8683        Self::new(value.into_channel())
8684    }
8685}
8686
8687#[derive(Debug, Clone)]
8688pub struct TrustedFlatlandFactoryProxy {
8689    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8690}
8691
8692impl fidl::endpoints::Proxy for TrustedFlatlandFactoryProxy {
8693    type Protocol = TrustedFlatlandFactoryMarker;
8694
8695    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8696        Self::new(inner)
8697    }
8698
8699    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8700        self.client.into_channel().map_err(|client| Self { client })
8701    }
8702
8703    fn as_channel(&self) -> &::fidl::AsyncChannel {
8704        self.client.as_channel()
8705    }
8706}
8707
8708impl TrustedFlatlandFactoryProxy {
8709    /// Create a new Proxy for fuchsia.ui.composition/TrustedFlatlandFactory.
8710    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8711        let protocol_name =
8712            <TrustedFlatlandFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8713        Self { client: fidl::client::Client::new(channel, protocol_name) }
8714    }
8715
8716    /// Get a Stream of events from the remote end of the protocol.
8717    ///
8718    /// # Panics
8719    ///
8720    /// Panics if the event stream was already taken.
8721    pub fn take_event_stream(&self) -> TrustedFlatlandFactoryEventStream {
8722        TrustedFlatlandFactoryEventStream { event_receiver: self.client.take_event_receiver() }
8723    }
8724
8725    /// Creates a new Flatland instance with the specified configuration.
8726    ///
8727    /// ## Error
8728    ///
8729    /// Returns a `TrustedFlatlandFactoryError` error if the operation fails.
8730    pub fn r#create_flatland(
8731        &self,
8732        mut server_end: fidl::endpoints::ServerEnd<FlatlandMarker>,
8733        mut config: TrustedFlatlandConfig,
8734    ) -> fidl::client::QueryResponseFut<
8735        TrustedFlatlandFactoryCreateFlatlandResult,
8736        fidl::encoding::DefaultFuchsiaResourceDialect,
8737    > {
8738        TrustedFlatlandFactoryProxyInterface::r#create_flatland(self, server_end, config)
8739    }
8740}
8741
8742impl TrustedFlatlandFactoryProxyInterface for TrustedFlatlandFactoryProxy {
8743    type CreateFlatlandResponseFut = fidl::client::QueryResponseFut<
8744        TrustedFlatlandFactoryCreateFlatlandResult,
8745        fidl::encoding::DefaultFuchsiaResourceDialect,
8746    >;
8747    fn r#create_flatland(
8748        &self,
8749        mut server_end: fidl::endpoints::ServerEnd<FlatlandMarker>,
8750        mut config: TrustedFlatlandConfig,
8751    ) -> Self::CreateFlatlandResponseFut {
8752        fn _decode(
8753            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8754        ) -> Result<TrustedFlatlandFactoryCreateFlatlandResult, fidl::Error> {
8755            let _response = fidl::client::decode_transaction_body::<
8756                fidl::encoding::ResultType<
8757                    fidl::encoding::EmptyStruct,
8758                    TrustedFlatlandFactoryError,
8759                >,
8760                fidl::encoding::DefaultFuchsiaResourceDialect,
8761                0x48e89c53f00561dc,
8762            >(_buf?)?;
8763            Ok(_response.map(|x| x))
8764        }
8765        self.client.send_query_and_decode::<
8766            TrustedFlatlandFactoryCreateFlatlandRequest,
8767            TrustedFlatlandFactoryCreateFlatlandResult,
8768        >(
8769            (server_end, &mut config,),
8770            0x48e89c53f00561dc,
8771            fidl::encoding::DynamicFlags::empty(),
8772            _decode,
8773        )
8774    }
8775}
8776
8777pub struct TrustedFlatlandFactoryEventStream {
8778    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8779}
8780
8781impl std::marker::Unpin for TrustedFlatlandFactoryEventStream {}
8782
8783impl futures::stream::FusedStream for TrustedFlatlandFactoryEventStream {
8784    fn is_terminated(&self) -> bool {
8785        self.event_receiver.is_terminated()
8786    }
8787}
8788
8789impl futures::Stream for TrustedFlatlandFactoryEventStream {
8790    type Item = Result<TrustedFlatlandFactoryEvent, fidl::Error>;
8791
8792    fn poll_next(
8793        mut self: std::pin::Pin<&mut Self>,
8794        cx: &mut std::task::Context<'_>,
8795    ) -> std::task::Poll<Option<Self::Item>> {
8796        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8797            &mut self.event_receiver,
8798            cx
8799        )?) {
8800            Some(buf) => std::task::Poll::Ready(Some(TrustedFlatlandFactoryEvent::decode(buf))),
8801            None => std::task::Poll::Ready(None),
8802        }
8803    }
8804}
8805
8806#[derive(Debug)]
8807pub enum TrustedFlatlandFactoryEvent {}
8808
8809impl TrustedFlatlandFactoryEvent {
8810    /// Decodes a message buffer as a [`TrustedFlatlandFactoryEvent`].
8811    fn decode(
8812        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8813    ) -> Result<TrustedFlatlandFactoryEvent, fidl::Error> {
8814        let (bytes, _handles) = buf.split_mut();
8815        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8816        debug_assert_eq!(tx_header.tx_id, 0);
8817        match tx_header.ordinal {
8818            _ => Err(fidl::Error::UnknownOrdinal {
8819                ordinal: tx_header.ordinal,
8820                protocol_name:
8821                    <TrustedFlatlandFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8822            }),
8823        }
8824    }
8825}
8826
8827/// A Stream of incoming requests for fuchsia.ui.composition/TrustedFlatlandFactory.
8828pub struct TrustedFlatlandFactoryRequestStream {
8829    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8830    is_terminated: bool,
8831}
8832
8833impl std::marker::Unpin for TrustedFlatlandFactoryRequestStream {}
8834
8835impl futures::stream::FusedStream for TrustedFlatlandFactoryRequestStream {
8836    fn is_terminated(&self) -> bool {
8837        self.is_terminated
8838    }
8839}
8840
8841impl fidl::endpoints::RequestStream for TrustedFlatlandFactoryRequestStream {
8842    type Protocol = TrustedFlatlandFactoryMarker;
8843    type ControlHandle = TrustedFlatlandFactoryControlHandle;
8844
8845    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8846        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8847    }
8848
8849    fn control_handle(&self) -> Self::ControlHandle {
8850        TrustedFlatlandFactoryControlHandle { inner: self.inner.clone() }
8851    }
8852
8853    fn into_inner(
8854        self,
8855    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8856    {
8857        (self.inner, self.is_terminated)
8858    }
8859
8860    fn from_inner(
8861        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8862        is_terminated: bool,
8863    ) -> Self {
8864        Self { inner, is_terminated }
8865    }
8866}
8867
8868impl futures::Stream for TrustedFlatlandFactoryRequestStream {
8869    type Item = Result<TrustedFlatlandFactoryRequest, fidl::Error>;
8870
8871    fn poll_next(
8872        mut self: std::pin::Pin<&mut Self>,
8873        cx: &mut std::task::Context<'_>,
8874    ) -> std::task::Poll<Option<Self::Item>> {
8875        let this = &mut *self;
8876        if this.inner.check_shutdown(cx) {
8877            this.is_terminated = true;
8878            return std::task::Poll::Ready(None);
8879        }
8880        if this.is_terminated {
8881            panic!("polled TrustedFlatlandFactoryRequestStream after completion");
8882        }
8883        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8884            |bytes, handles| {
8885                match this.inner.channel().read_etc(cx, bytes, handles) {
8886                    std::task::Poll::Ready(Ok(())) => {}
8887                    std::task::Poll::Pending => return std::task::Poll::Pending,
8888                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8889                        this.is_terminated = true;
8890                        return std::task::Poll::Ready(None);
8891                    }
8892                    std::task::Poll::Ready(Err(e)) => {
8893                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8894                            e.into(),
8895                        ))));
8896                    }
8897                }
8898
8899                // A message has been received from the channel
8900                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8901
8902                std::task::Poll::Ready(Some(match header.ordinal {
8903                0x48e89c53f00561dc => {
8904                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8905                    let mut req = fidl::new_empty!(TrustedFlatlandFactoryCreateFlatlandRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8906                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TrustedFlatlandFactoryCreateFlatlandRequest>(&header, _body_bytes, handles, &mut req)?;
8907                    let control_handle = TrustedFlatlandFactoryControlHandle {
8908                        inner: this.inner.clone(),
8909                    };
8910                    Ok(TrustedFlatlandFactoryRequest::CreateFlatland {server_end: req.server_end,
8911config: req.config,
8912
8913                        responder: TrustedFlatlandFactoryCreateFlatlandResponder {
8914                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8915                            tx_id: header.tx_id,
8916                        },
8917                    })
8918                }
8919                _ => Err(fidl::Error::UnknownOrdinal {
8920                    ordinal: header.ordinal,
8921                    protocol_name: <TrustedFlatlandFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8922                }),
8923            }))
8924            },
8925        )
8926    }
8927}
8928
8929/// A privileged factory for creating Flatland instances with special configurations.
8930///
8931/// This protocol is intended for trusted clients that require fine-grained control over
8932/// Flatland's behavior for performance-critical applications. It is not intended for
8933/// general use. Misuse of this API can negatively impact system performance and stability.
8934#[derive(Debug)]
8935pub enum TrustedFlatlandFactoryRequest {
8936    /// Creates a new Flatland instance with the specified configuration.
8937    ///
8938    /// ## Error
8939    ///
8940    /// Returns a `TrustedFlatlandFactoryError` error if the operation fails.
8941    CreateFlatland {
8942        server_end: fidl::endpoints::ServerEnd<FlatlandMarker>,
8943        config: TrustedFlatlandConfig,
8944        responder: TrustedFlatlandFactoryCreateFlatlandResponder,
8945    },
8946}
8947
8948impl TrustedFlatlandFactoryRequest {
8949    #[allow(irrefutable_let_patterns)]
8950    pub fn into_create_flatland(
8951        self,
8952    ) -> Option<(
8953        fidl::endpoints::ServerEnd<FlatlandMarker>,
8954        TrustedFlatlandConfig,
8955        TrustedFlatlandFactoryCreateFlatlandResponder,
8956    )> {
8957        if let TrustedFlatlandFactoryRequest::CreateFlatland { server_end, config, responder } =
8958            self
8959        {
8960            Some((server_end, config, responder))
8961        } else {
8962            None
8963        }
8964    }
8965
8966    /// Name of the method defined in FIDL
8967    pub fn method_name(&self) -> &'static str {
8968        match *self {
8969            TrustedFlatlandFactoryRequest::CreateFlatland { .. } => "create_flatland",
8970        }
8971    }
8972}
8973
8974#[derive(Debug, Clone)]
8975pub struct TrustedFlatlandFactoryControlHandle {
8976    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8977}
8978
8979impl fidl::endpoints::ControlHandle for TrustedFlatlandFactoryControlHandle {
8980    fn shutdown(&self) {
8981        self.inner.shutdown()
8982    }
8983
8984    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8985        self.inner.shutdown_with_epitaph(status)
8986    }
8987
8988    fn is_closed(&self) -> bool {
8989        self.inner.channel().is_closed()
8990    }
8991    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8992        self.inner.channel().on_closed()
8993    }
8994
8995    #[cfg(target_os = "fuchsia")]
8996    fn signal_peer(
8997        &self,
8998        clear_mask: zx::Signals,
8999        set_mask: zx::Signals,
9000    ) -> Result<(), zx_status::Status> {
9001        use fidl::Peered;
9002        self.inner.channel().signal_peer(clear_mask, set_mask)
9003    }
9004}
9005
9006impl TrustedFlatlandFactoryControlHandle {}
9007
9008#[must_use = "FIDL methods require a response to be sent"]
9009#[derive(Debug)]
9010pub struct TrustedFlatlandFactoryCreateFlatlandResponder {
9011    control_handle: std::mem::ManuallyDrop<TrustedFlatlandFactoryControlHandle>,
9012    tx_id: u32,
9013}
9014
9015/// Set the the channel to be shutdown (see [`TrustedFlatlandFactoryControlHandle::shutdown`])
9016/// if the responder is dropped without sending a response, so that the client
9017/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9018impl std::ops::Drop for TrustedFlatlandFactoryCreateFlatlandResponder {
9019    fn drop(&mut self) {
9020        self.control_handle.shutdown();
9021        // Safety: drops once, never accessed again
9022        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9023    }
9024}
9025
9026impl fidl::endpoints::Responder for TrustedFlatlandFactoryCreateFlatlandResponder {
9027    type ControlHandle = TrustedFlatlandFactoryControlHandle;
9028
9029    fn control_handle(&self) -> &TrustedFlatlandFactoryControlHandle {
9030        &self.control_handle
9031    }
9032
9033    fn drop_without_shutdown(mut self) {
9034        // Safety: drops once, never accessed again due to mem::forget
9035        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9036        // Prevent Drop from running (which would shut down the channel)
9037        std::mem::forget(self);
9038    }
9039}
9040
9041impl TrustedFlatlandFactoryCreateFlatlandResponder {
9042    /// Sends a response to the FIDL transaction.
9043    ///
9044    /// Sets the channel to shutdown if an error occurs.
9045    pub fn send(
9046        self,
9047        mut result: Result<(), TrustedFlatlandFactoryError>,
9048    ) -> Result<(), fidl::Error> {
9049        let _result = self.send_raw(result);
9050        if _result.is_err() {
9051            self.control_handle.shutdown();
9052        }
9053        self.drop_without_shutdown();
9054        _result
9055    }
9056
9057    /// Similar to "send" but does not shutdown the channel if an error occurs.
9058    pub fn send_no_shutdown_on_err(
9059        self,
9060        mut result: Result<(), TrustedFlatlandFactoryError>,
9061    ) -> Result<(), fidl::Error> {
9062        let _result = self.send_raw(result);
9063        self.drop_without_shutdown();
9064        _result
9065    }
9066
9067    fn send_raw(
9068        &self,
9069        mut result: Result<(), TrustedFlatlandFactoryError>,
9070    ) -> Result<(), fidl::Error> {
9071        self.control_handle.inner.send::<fidl::encoding::ResultType<
9072            fidl::encoding::EmptyStruct,
9073            TrustedFlatlandFactoryError,
9074        >>(
9075            result,
9076            self.tx_id,
9077            0x48e89c53f00561dc,
9078            fidl::encoding::DynamicFlags::empty(),
9079        )
9080    }
9081}
9082
9083mod internal {
9084    use super::*;
9085
9086    impl fidl::encoding::ResourceTypeMarker for AllocatorRegisterBufferCollectionRequest {
9087        type Borrowed<'a> = &'a mut Self;
9088        fn take_or_borrow<'a>(
9089            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9090        ) -> Self::Borrowed<'a> {
9091            value
9092        }
9093    }
9094
9095    unsafe impl fidl::encoding::TypeMarker for AllocatorRegisterBufferCollectionRequest {
9096        type Owned = Self;
9097
9098        #[inline(always)]
9099        fn inline_align(_context: fidl::encoding::Context) -> usize {
9100            8
9101        }
9102
9103        #[inline(always)]
9104        fn inline_size(_context: fidl::encoding::Context) -> usize {
9105            16
9106        }
9107    }
9108
9109    unsafe impl
9110        fidl::encoding::Encode<
9111            AllocatorRegisterBufferCollectionRequest,
9112            fidl::encoding::DefaultFuchsiaResourceDialect,
9113        > for &mut AllocatorRegisterBufferCollectionRequest
9114    {
9115        #[inline]
9116        unsafe fn encode(
9117            self,
9118            encoder: &mut fidl::encoding::Encoder<
9119                '_,
9120                fidl::encoding::DefaultFuchsiaResourceDialect,
9121            >,
9122            offset: usize,
9123            _depth: fidl::encoding::Depth,
9124        ) -> fidl::Result<()> {
9125            encoder.debug_check_bounds::<AllocatorRegisterBufferCollectionRequest>(offset);
9126            // Delegate to tuple encoding.
9127            fidl::encoding::Encode::<AllocatorRegisterBufferCollectionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9128                (
9129                    <RegisterBufferCollectionArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.args),
9130                ),
9131                encoder, offset, _depth
9132            )
9133        }
9134    }
9135    unsafe impl<
9136        T0: fidl::encoding::Encode<
9137                RegisterBufferCollectionArgs,
9138                fidl::encoding::DefaultFuchsiaResourceDialect,
9139            >,
9140    >
9141        fidl::encoding::Encode<
9142            AllocatorRegisterBufferCollectionRequest,
9143            fidl::encoding::DefaultFuchsiaResourceDialect,
9144        > for (T0,)
9145    {
9146        #[inline]
9147        unsafe fn encode(
9148            self,
9149            encoder: &mut fidl::encoding::Encoder<
9150                '_,
9151                fidl::encoding::DefaultFuchsiaResourceDialect,
9152            >,
9153            offset: usize,
9154            depth: fidl::encoding::Depth,
9155        ) -> fidl::Result<()> {
9156            encoder.debug_check_bounds::<AllocatorRegisterBufferCollectionRequest>(offset);
9157            // Zero out padding regions. There's no need to apply masks
9158            // because the unmasked parts will be overwritten by fields.
9159            // Write the fields.
9160            self.0.encode(encoder, offset + 0, depth)?;
9161            Ok(())
9162        }
9163    }
9164
9165    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9166        for AllocatorRegisterBufferCollectionRequest
9167    {
9168        #[inline(always)]
9169        fn new_empty() -> Self {
9170            Self {
9171                args: fidl::new_empty!(
9172                    RegisterBufferCollectionArgs,
9173                    fidl::encoding::DefaultFuchsiaResourceDialect
9174                ),
9175            }
9176        }
9177
9178        #[inline]
9179        unsafe fn decode(
9180            &mut self,
9181            decoder: &mut fidl::encoding::Decoder<
9182                '_,
9183                fidl::encoding::DefaultFuchsiaResourceDialect,
9184            >,
9185            offset: usize,
9186            _depth: fidl::encoding::Depth,
9187        ) -> fidl::Result<()> {
9188            decoder.debug_check_bounds::<Self>(offset);
9189            // Verify that padding bytes are zero.
9190            fidl::decode!(
9191                RegisterBufferCollectionArgs,
9192                fidl::encoding::DefaultFuchsiaResourceDialect,
9193                &mut self.args,
9194                decoder,
9195                offset + 0,
9196                _depth
9197            )?;
9198            Ok(())
9199        }
9200    }
9201
9202    impl fidl::encoding::ResourceTypeMarker for BufferCollectionExportToken {
9203        type Borrowed<'a> = &'a mut Self;
9204        fn take_or_borrow<'a>(
9205            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9206        ) -> Self::Borrowed<'a> {
9207            value
9208        }
9209    }
9210
9211    unsafe impl fidl::encoding::TypeMarker for BufferCollectionExportToken {
9212        type Owned = Self;
9213
9214        #[inline(always)]
9215        fn inline_align(_context: fidl::encoding::Context) -> usize {
9216            4
9217        }
9218
9219        #[inline(always)]
9220        fn inline_size(_context: fidl::encoding::Context) -> usize {
9221            4
9222        }
9223    }
9224
9225    unsafe impl
9226        fidl::encoding::Encode<
9227            BufferCollectionExportToken,
9228            fidl::encoding::DefaultFuchsiaResourceDialect,
9229        > for &mut BufferCollectionExportToken
9230    {
9231        #[inline]
9232        unsafe fn encode(
9233            self,
9234            encoder: &mut fidl::encoding::Encoder<
9235                '_,
9236                fidl::encoding::DefaultFuchsiaResourceDialect,
9237            >,
9238            offset: usize,
9239            _depth: fidl::encoding::Depth,
9240        ) -> fidl::Result<()> {
9241            encoder.debug_check_bounds::<BufferCollectionExportToken>(offset);
9242            // Delegate to tuple encoding.
9243            fidl::encoding::Encode::<
9244                BufferCollectionExportToken,
9245                fidl::encoding::DefaultFuchsiaResourceDialect,
9246            >::encode(
9247                (<fidl::encoding::HandleType<
9248                    fidl::EventPair,
9249                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9250                    2147483648,
9251                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9252                    &mut self.value
9253                ),),
9254                encoder,
9255                offset,
9256                _depth,
9257            )
9258        }
9259    }
9260    unsafe impl<
9261        T0: fidl::encoding::Encode<
9262                fidl::encoding::HandleType<
9263                    fidl::EventPair,
9264                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9265                    2147483648,
9266                >,
9267                fidl::encoding::DefaultFuchsiaResourceDialect,
9268            >,
9269    >
9270        fidl::encoding::Encode<
9271            BufferCollectionExportToken,
9272            fidl::encoding::DefaultFuchsiaResourceDialect,
9273        > for (T0,)
9274    {
9275        #[inline]
9276        unsafe fn encode(
9277            self,
9278            encoder: &mut fidl::encoding::Encoder<
9279                '_,
9280                fidl::encoding::DefaultFuchsiaResourceDialect,
9281            >,
9282            offset: usize,
9283            depth: fidl::encoding::Depth,
9284        ) -> fidl::Result<()> {
9285            encoder.debug_check_bounds::<BufferCollectionExportToken>(offset);
9286            // Zero out padding regions. There's no need to apply masks
9287            // because the unmasked parts will be overwritten by fields.
9288            // Write the fields.
9289            self.0.encode(encoder, offset + 0, depth)?;
9290            Ok(())
9291        }
9292    }
9293
9294    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9295        for BufferCollectionExportToken
9296    {
9297        #[inline(always)]
9298        fn new_empty() -> Self {
9299            Self {
9300                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9301            }
9302        }
9303
9304        #[inline]
9305        unsafe fn decode(
9306            &mut self,
9307            decoder: &mut fidl::encoding::Decoder<
9308                '_,
9309                fidl::encoding::DefaultFuchsiaResourceDialect,
9310            >,
9311            offset: usize,
9312            _depth: fidl::encoding::Depth,
9313        ) -> fidl::Result<()> {
9314            decoder.debug_check_bounds::<Self>(offset);
9315            // Verify that padding bytes are zero.
9316            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
9317            Ok(())
9318        }
9319    }
9320
9321    impl fidl::encoding::ResourceTypeMarker for BufferCollectionImportToken {
9322        type Borrowed<'a> = &'a mut Self;
9323        fn take_or_borrow<'a>(
9324            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9325        ) -> Self::Borrowed<'a> {
9326            value
9327        }
9328    }
9329
9330    unsafe impl fidl::encoding::TypeMarker for BufferCollectionImportToken {
9331        type Owned = Self;
9332
9333        #[inline(always)]
9334        fn inline_align(_context: fidl::encoding::Context) -> usize {
9335            4
9336        }
9337
9338        #[inline(always)]
9339        fn inline_size(_context: fidl::encoding::Context) -> usize {
9340            4
9341        }
9342    }
9343
9344    unsafe impl
9345        fidl::encoding::Encode<
9346            BufferCollectionImportToken,
9347            fidl::encoding::DefaultFuchsiaResourceDialect,
9348        > for &mut BufferCollectionImportToken
9349    {
9350        #[inline]
9351        unsafe fn encode(
9352            self,
9353            encoder: &mut fidl::encoding::Encoder<
9354                '_,
9355                fidl::encoding::DefaultFuchsiaResourceDialect,
9356            >,
9357            offset: usize,
9358            _depth: fidl::encoding::Depth,
9359        ) -> fidl::Result<()> {
9360            encoder.debug_check_bounds::<BufferCollectionImportToken>(offset);
9361            // Delegate to tuple encoding.
9362            fidl::encoding::Encode::<
9363                BufferCollectionImportToken,
9364                fidl::encoding::DefaultFuchsiaResourceDialect,
9365            >::encode(
9366                (<fidl::encoding::HandleType<
9367                    fidl::EventPair,
9368                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9369                    2147483648,
9370                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9371                    &mut self.value
9372                ),),
9373                encoder,
9374                offset,
9375                _depth,
9376            )
9377        }
9378    }
9379    unsafe impl<
9380        T0: fidl::encoding::Encode<
9381                fidl::encoding::HandleType<
9382                    fidl::EventPair,
9383                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9384                    2147483648,
9385                >,
9386                fidl::encoding::DefaultFuchsiaResourceDialect,
9387            >,
9388    >
9389        fidl::encoding::Encode<
9390            BufferCollectionImportToken,
9391            fidl::encoding::DefaultFuchsiaResourceDialect,
9392        > for (T0,)
9393    {
9394        #[inline]
9395        unsafe fn encode(
9396            self,
9397            encoder: &mut fidl::encoding::Encoder<
9398                '_,
9399                fidl::encoding::DefaultFuchsiaResourceDialect,
9400            >,
9401            offset: usize,
9402            depth: fidl::encoding::Depth,
9403        ) -> fidl::Result<()> {
9404            encoder.debug_check_bounds::<BufferCollectionImportToken>(offset);
9405            // Zero out padding regions. There's no need to apply masks
9406            // because the unmasked parts will be overwritten by fields.
9407            // Write the fields.
9408            self.0.encode(encoder, offset + 0, depth)?;
9409            Ok(())
9410        }
9411    }
9412
9413    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9414        for BufferCollectionImportToken
9415    {
9416        #[inline(always)]
9417        fn new_empty() -> Self {
9418            Self {
9419                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9420            }
9421        }
9422
9423        #[inline]
9424        unsafe fn decode(
9425            &mut self,
9426            decoder: &mut fidl::encoding::Decoder<
9427                '_,
9428                fidl::encoding::DefaultFuchsiaResourceDialect,
9429            >,
9430            offset: usize,
9431            _depth: fidl::encoding::Depth,
9432        ) -> fidl::Result<()> {
9433            decoder.debug_check_bounds::<Self>(offset);
9434            // Verify that padding bytes are zero.
9435            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
9436            Ok(())
9437        }
9438    }
9439
9440    impl fidl::encoding::ResourceTypeMarker for ChildViewWatcherGetViewRefResponse {
9441        type Borrowed<'a> = &'a mut Self;
9442        fn take_or_borrow<'a>(
9443            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9444        ) -> Self::Borrowed<'a> {
9445            value
9446        }
9447    }
9448
9449    unsafe impl fidl::encoding::TypeMarker for ChildViewWatcherGetViewRefResponse {
9450        type Owned = Self;
9451
9452        #[inline(always)]
9453        fn inline_align(_context: fidl::encoding::Context) -> usize {
9454            4
9455        }
9456
9457        #[inline(always)]
9458        fn inline_size(_context: fidl::encoding::Context) -> usize {
9459            4
9460        }
9461    }
9462
9463    unsafe impl
9464        fidl::encoding::Encode<
9465            ChildViewWatcherGetViewRefResponse,
9466            fidl::encoding::DefaultFuchsiaResourceDialect,
9467        > for &mut ChildViewWatcherGetViewRefResponse
9468    {
9469        #[inline]
9470        unsafe fn encode(
9471            self,
9472            encoder: &mut fidl::encoding::Encoder<
9473                '_,
9474                fidl::encoding::DefaultFuchsiaResourceDialect,
9475            >,
9476            offset: usize,
9477            _depth: fidl::encoding::Depth,
9478        ) -> fidl::Result<()> {
9479            encoder.debug_check_bounds::<ChildViewWatcherGetViewRefResponse>(offset);
9480            // Delegate to tuple encoding.
9481            fidl::encoding::Encode::<ChildViewWatcherGetViewRefResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9482                (
9483                    <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_ref),
9484                ),
9485                encoder, offset, _depth
9486            )
9487        }
9488    }
9489    unsafe impl<
9490        T0: fidl::encoding::Encode<
9491                fidl_fuchsia_ui_views::ViewRef,
9492                fidl::encoding::DefaultFuchsiaResourceDialect,
9493            >,
9494    >
9495        fidl::encoding::Encode<
9496            ChildViewWatcherGetViewRefResponse,
9497            fidl::encoding::DefaultFuchsiaResourceDialect,
9498        > for (T0,)
9499    {
9500        #[inline]
9501        unsafe fn encode(
9502            self,
9503            encoder: &mut fidl::encoding::Encoder<
9504                '_,
9505                fidl::encoding::DefaultFuchsiaResourceDialect,
9506            >,
9507            offset: usize,
9508            depth: fidl::encoding::Depth,
9509        ) -> fidl::Result<()> {
9510            encoder.debug_check_bounds::<ChildViewWatcherGetViewRefResponse>(offset);
9511            // Zero out padding regions. There's no need to apply masks
9512            // because the unmasked parts will be overwritten by fields.
9513            // Write the fields.
9514            self.0.encode(encoder, offset + 0, depth)?;
9515            Ok(())
9516        }
9517    }
9518
9519    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9520        for ChildViewWatcherGetViewRefResponse
9521    {
9522        #[inline(always)]
9523        fn new_empty() -> Self {
9524            Self {
9525                view_ref: fidl::new_empty!(
9526                    fidl_fuchsia_ui_views::ViewRef,
9527                    fidl::encoding::DefaultFuchsiaResourceDialect
9528                ),
9529            }
9530        }
9531
9532        #[inline]
9533        unsafe fn decode(
9534            &mut self,
9535            decoder: &mut fidl::encoding::Decoder<
9536                '_,
9537                fidl::encoding::DefaultFuchsiaResourceDialect,
9538            >,
9539            offset: usize,
9540            _depth: fidl::encoding::Depth,
9541        ) -> fidl::Result<()> {
9542            decoder.debug_check_bounds::<Self>(offset);
9543            // Verify that padding bytes are zero.
9544            fidl::decode!(
9545                fidl_fuchsia_ui_views::ViewRef,
9546                fidl::encoding::DefaultFuchsiaResourceDialect,
9547                &mut self.view_ref,
9548                decoder,
9549                offset + 0,
9550                _depth
9551            )?;
9552            Ok(())
9553        }
9554    }
9555
9556    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateFilledRectRequest {
9557        type Borrowed<'a> = &'a mut Self;
9558        fn take_or_borrow<'a>(
9559            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9560        ) -> Self::Borrowed<'a> {
9561            value
9562        }
9563    }
9564
9565    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateFilledRectRequest {
9566        type Owned = Self;
9567
9568        #[inline(always)]
9569        fn inline_align(_context: fidl::encoding::Context) -> usize {
9570            8
9571        }
9572
9573        #[inline(always)]
9574        fn inline_size(_context: fidl::encoding::Context) -> usize {
9575            8
9576        }
9577        #[inline(always)]
9578        fn encode_is_copy() -> bool {
9579            true
9580        }
9581
9582        #[inline(always)]
9583        fn decode_is_copy() -> bool {
9584            true
9585        }
9586    }
9587
9588    unsafe impl
9589        fidl::encoding::Encode<
9590            FlatlandCreateFilledRectRequest,
9591            fidl::encoding::DefaultFuchsiaResourceDialect,
9592        > for &mut FlatlandCreateFilledRectRequest
9593    {
9594        #[inline]
9595        unsafe fn encode(
9596            self,
9597            encoder: &mut fidl::encoding::Encoder<
9598                '_,
9599                fidl::encoding::DefaultFuchsiaResourceDialect,
9600            >,
9601            offset: usize,
9602            _depth: fidl::encoding::Depth,
9603        ) -> fidl::Result<()> {
9604            encoder.debug_check_bounds::<FlatlandCreateFilledRectRequest>(offset);
9605            unsafe {
9606                // Copy the object into the buffer.
9607                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
9608                (buf_ptr as *mut FlatlandCreateFilledRectRequest)
9609                    .write_unaligned((self as *const FlatlandCreateFilledRectRequest).read());
9610                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
9611                // done second because the memcpy will write garbage to these bytes.
9612            }
9613            Ok(())
9614        }
9615    }
9616    unsafe impl<
9617        T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>,
9618    >
9619        fidl::encoding::Encode<
9620            FlatlandCreateFilledRectRequest,
9621            fidl::encoding::DefaultFuchsiaResourceDialect,
9622        > for (T0,)
9623    {
9624        #[inline]
9625        unsafe fn encode(
9626            self,
9627            encoder: &mut fidl::encoding::Encoder<
9628                '_,
9629                fidl::encoding::DefaultFuchsiaResourceDialect,
9630            >,
9631            offset: usize,
9632            depth: fidl::encoding::Depth,
9633        ) -> fidl::Result<()> {
9634            encoder.debug_check_bounds::<FlatlandCreateFilledRectRequest>(offset);
9635            // Zero out padding regions. There's no need to apply masks
9636            // because the unmasked parts will be overwritten by fields.
9637            // Write the fields.
9638            self.0.encode(encoder, offset + 0, depth)?;
9639            Ok(())
9640        }
9641    }
9642
9643    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9644        for FlatlandCreateFilledRectRequest
9645    {
9646        #[inline(always)]
9647        fn new_empty() -> Self {
9648            Self {
9649                rect_id: fidl::new_empty!(ContentId, fidl::encoding::DefaultFuchsiaResourceDialect),
9650            }
9651        }
9652
9653        #[inline]
9654        unsafe fn decode(
9655            &mut self,
9656            decoder: &mut fidl::encoding::Decoder<
9657                '_,
9658                fidl::encoding::DefaultFuchsiaResourceDialect,
9659            >,
9660            offset: usize,
9661            _depth: fidl::encoding::Depth,
9662        ) -> fidl::Result<()> {
9663            decoder.debug_check_bounds::<Self>(offset);
9664            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
9665            // Verify that padding bytes are zero.
9666            // Copy from the buffer into the object.
9667            unsafe {
9668                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
9669            }
9670            Ok(())
9671        }
9672    }
9673
9674    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateImageRequest {
9675        type Borrowed<'a> = &'a mut Self;
9676        fn take_or_borrow<'a>(
9677            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9678        ) -> Self::Borrowed<'a> {
9679            value
9680        }
9681    }
9682
9683    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateImageRequest {
9684        type Owned = Self;
9685
9686        #[inline(always)]
9687        fn inline_align(_context: fidl::encoding::Context) -> usize {
9688            8
9689        }
9690
9691        #[inline(always)]
9692        fn inline_size(_context: fidl::encoding::Context) -> usize {
9693            32
9694        }
9695    }
9696
9697    unsafe impl
9698        fidl::encoding::Encode<
9699            FlatlandCreateImageRequest,
9700            fidl::encoding::DefaultFuchsiaResourceDialect,
9701        > for &mut FlatlandCreateImageRequest
9702    {
9703        #[inline]
9704        unsafe fn encode(
9705            self,
9706            encoder: &mut fidl::encoding::Encoder<
9707                '_,
9708                fidl::encoding::DefaultFuchsiaResourceDialect,
9709            >,
9710            offset: usize,
9711            _depth: fidl::encoding::Depth,
9712        ) -> fidl::Result<()> {
9713            encoder.debug_check_bounds::<FlatlandCreateImageRequest>(offset);
9714            // Delegate to tuple encoding.
9715            fidl::encoding::Encode::<FlatlandCreateImageRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9716                (
9717                    <ContentId as fidl::encoding::ValueTypeMarker>::borrow(&self.image_id),
9718                    <BufferCollectionImportToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.import_token),
9719                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_index),
9720                    <ImageProperties as fidl::encoding::ValueTypeMarker>::borrow(&self.properties),
9721                ),
9722                encoder, offset, _depth
9723            )
9724        }
9725    }
9726    unsafe impl<
9727        T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>,
9728        T1: fidl::encoding::Encode<
9729                BufferCollectionImportToken,
9730                fidl::encoding::DefaultFuchsiaResourceDialect,
9731            >,
9732        T2: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
9733        T3: fidl::encoding::Encode<ImageProperties, fidl::encoding::DefaultFuchsiaResourceDialect>,
9734    >
9735        fidl::encoding::Encode<
9736            FlatlandCreateImageRequest,
9737            fidl::encoding::DefaultFuchsiaResourceDialect,
9738        > for (T0, T1, T2, T3)
9739    {
9740        #[inline]
9741        unsafe fn encode(
9742            self,
9743            encoder: &mut fidl::encoding::Encoder<
9744                '_,
9745                fidl::encoding::DefaultFuchsiaResourceDialect,
9746            >,
9747            offset: usize,
9748            depth: fidl::encoding::Depth,
9749        ) -> fidl::Result<()> {
9750            encoder.debug_check_bounds::<FlatlandCreateImageRequest>(offset);
9751            // Zero out padding regions. There's no need to apply masks
9752            // because the unmasked parts will be overwritten by fields.
9753            // Write the fields.
9754            self.0.encode(encoder, offset + 0, depth)?;
9755            self.1.encode(encoder, offset + 8, depth)?;
9756            self.2.encode(encoder, offset + 12, depth)?;
9757            self.3.encode(encoder, offset + 16, depth)?;
9758            Ok(())
9759        }
9760    }
9761
9762    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9763        for FlatlandCreateImageRequest
9764    {
9765        #[inline(always)]
9766        fn new_empty() -> Self {
9767            Self {
9768                image_id: fidl::new_empty!(
9769                    ContentId,
9770                    fidl::encoding::DefaultFuchsiaResourceDialect
9771                ),
9772                import_token: fidl::new_empty!(
9773                    BufferCollectionImportToken,
9774                    fidl::encoding::DefaultFuchsiaResourceDialect
9775                ),
9776                vmo_index: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
9777                properties: fidl::new_empty!(
9778                    ImageProperties,
9779                    fidl::encoding::DefaultFuchsiaResourceDialect
9780                ),
9781            }
9782        }
9783
9784        #[inline]
9785        unsafe fn decode(
9786            &mut self,
9787            decoder: &mut fidl::encoding::Decoder<
9788                '_,
9789                fidl::encoding::DefaultFuchsiaResourceDialect,
9790            >,
9791            offset: usize,
9792            _depth: fidl::encoding::Depth,
9793        ) -> fidl::Result<()> {
9794            decoder.debug_check_bounds::<Self>(offset);
9795            // Verify that padding bytes are zero.
9796            fidl::decode!(
9797                ContentId,
9798                fidl::encoding::DefaultFuchsiaResourceDialect,
9799                &mut self.image_id,
9800                decoder,
9801                offset + 0,
9802                _depth
9803            )?;
9804            fidl::decode!(
9805                BufferCollectionImportToken,
9806                fidl::encoding::DefaultFuchsiaResourceDialect,
9807                &mut self.import_token,
9808                decoder,
9809                offset + 8,
9810                _depth
9811            )?;
9812            fidl::decode!(
9813                u32,
9814                fidl::encoding::DefaultFuchsiaResourceDialect,
9815                &mut self.vmo_index,
9816                decoder,
9817                offset + 12,
9818                _depth
9819            )?;
9820            fidl::decode!(
9821                ImageProperties,
9822                fidl::encoding::DefaultFuchsiaResourceDialect,
9823                &mut self.properties,
9824                decoder,
9825                offset + 16,
9826                _depth
9827            )?;
9828            Ok(())
9829        }
9830    }
9831
9832    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateView2Request {
9833        type Borrowed<'a> = &'a mut Self;
9834        fn take_or_borrow<'a>(
9835            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9836        ) -> Self::Borrowed<'a> {
9837            value
9838        }
9839    }
9840
9841    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateView2Request {
9842        type Owned = Self;
9843
9844        #[inline(always)]
9845        fn inline_align(_context: fidl::encoding::Context) -> usize {
9846            8
9847        }
9848
9849        #[inline(always)]
9850        fn inline_size(_context: fidl::encoding::Context) -> usize {
9851            40
9852        }
9853    }
9854
9855    unsafe impl
9856        fidl::encoding::Encode<
9857            FlatlandCreateView2Request,
9858            fidl::encoding::DefaultFuchsiaResourceDialect,
9859        > for &mut FlatlandCreateView2Request
9860    {
9861        #[inline]
9862        unsafe fn encode(
9863            self,
9864            encoder: &mut fidl::encoding::Encoder<
9865                '_,
9866                fidl::encoding::DefaultFuchsiaResourceDialect,
9867            >,
9868            offset: usize,
9869            _depth: fidl::encoding::Depth,
9870        ) -> fidl::Result<()> {
9871            encoder.debug_check_bounds::<FlatlandCreateView2Request>(offset);
9872            // Delegate to tuple encoding.
9873            fidl::encoding::Encode::<FlatlandCreateView2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9874                (
9875                    <fidl_fuchsia_ui_views::ViewCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
9876                    <fidl_fuchsia_ui_views::ViewIdentityOnCreation as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_identity),
9877                    <ViewBoundProtocols as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.protocols),
9878                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.parent_viewport_watcher),
9879                ),
9880                encoder, offset, _depth
9881            )
9882        }
9883    }
9884    unsafe impl<
9885        T0: fidl::encoding::Encode<
9886                fidl_fuchsia_ui_views::ViewCreationToken,
9887                fidl::encoding::DefaultFuchsiaResourceDialect,
9888            >,
9889        T1: fidl::encoding::Encode<
9890                fidl_fuchsia_ui_views::ViewIdentityOnCreation,
9891                fidl::encoding::DefaultFuchsiaResourceDialect,
9892            >,
9893        T2: fidl::encoding::Encode<ViewBoundProtocols, fidl::encoding::DefaultFuchsiaResourceDialect>,
9894        T3: fidl::encoding::Encode<
9895                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
9896                fidl::encoding::DefaultFuchsiaResourceDialect,
9897            >,
9898    >
9899        fidl::encoding::Encode<
9900            FlatlandCreateView2Request,
9901            fidl::encoding::DefaultFuchsiaResourceDialect,
9902        > for (T0, T1, T2, T3)
9903    {
9904        #[inline]
9905        unsafe fn encode(
9906            self,
9907            encoder: &mut fidl::encoding::Encoder<
9908                '_,
9909                fidl::encoding::DefaultFuchsiaResourceDialect,
9910            >,
9911            offset: usize,
9912            depth: fidl::encoding::Depth,
9913        ) -> fidl::Result<()> {
9914            encoder.debug_check_bounds::<FlatlandCreateView2Request>(offset);
9915            // Zero out padding regions. There's no need to apply masks
9916            // because the unmasked parts will be overwritten by fields.
9917            unsafe {
9918                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
9919                (ptr as *mut u64).write_unaligned(0);
9920            }
9921            unsafe {
9922                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
9923                (ptr as *mut u64).write_unaligned(0);
9924            }
9925            // Write the fields.
9926            self.0.encode(encoder, offset + 0, depth)?;
9927            self.1.encode(encoder, offset + 4, depth)?;
9928            self.2.encode(encoder, offset + 16, depth)?;
9929            self.3.encode(encoder, offset + 32, depth)?;
9930            Ok(())
9931        }
9932    }
9933
9934    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9935        for FlatlandCreateView2Request
9936    {
9937        #[inline(always)]
9938        fn new_empty() -> Self {
9939            Self {
9940                token: fidl::new_empty!(
9941                    fidl_fuchsia_ui_views::ViewCreationToken,
9942                    fidl::encoding::DefaultFuchsiaResourceDialect
9943                ),
9944                view_identity: fidl::new_empty!(
9945                    fidl_fuchsia_ui_views::ViewIdentityOnCreation,
9946                    fidl::encoding::DefaultFuchsiaResourceDialect
9947                ),
9948                protocols: fidl::new_empty!(
9949                    ViewBoundProtocols,
9950                    fidl::encoding::DefaultFuchsiaResourceDialect
9951                ),
9952                parent_viewport_watcher: fidl::new_empty!(
9953                    fidl::encoding::Endpoint<
9954                        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
9955                    >,
9956                    fidl::encoding::DefaultFuchsiaResourceDialect
9957                ),
9958            }
9959        }
9960
9961        #[inline]
9962        unsafe fn decode(
9963            &mut self,
9964            decoder: &mut fidl::encoding::Decoder<
9965                '_,
9966                fidl::encoding::DefaultFuchsiaResourceDialect,
9967            >,
9968            offset: usize,
9969            _depth: fidl::encoding::Depth,
9970        ) -> fidl::Result<()> {
9971            decoder.debug_check_bounds::<Self>(offset);
9972            // Verify that padding bytes are zero.
9973            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
9974            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9975            let mask = 0xffffffff00000000u64;
9976            let maskedval = padval & mask;
9977            if maskedval != 0 {
9978                return Err(fidl::Error::NonZeroPadding {
9979                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
9980                });
9981            }
9982            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
9983            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9984            let mask = 0xffffffff00000000u64;
9985            let maskedval = padval & mask;
9986            if maskedval != 0 {
9987                return Err(fidl::Error::NonZeroPadding {
9988                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
9989                });
9990            }
9991            fidl::decode!(
9992                fidl_fuchsia_ui_views::ViewCreationToken,
9993                fidl::encoding::DefaultFuchsiaResourceDialect,
9994                &mut self.token,
9995                decoder,
9996                offset + 0,
9997                _depth
9998            )?;
9999            fidl::decode!(
10000                fidl_fuchsia_ui_views::ViewIdentityOnCreation,
10001                fidl::encoding::DefaultFuchsiaResourceDialect,
10002                &mut self.view_identity,
10003                decoder,
10004                offset + 4,
10005                _depth
10006            )?;
10007            fidl::decode!(
10008                ViewBoundProtocols,
10009                fidl::encoding::DefaultFuchsiaResourceDialect,
10010                &mut self.protocols,
10011                decoder,
10012                offset + 16,
10013                _depth
10014            )?;
10015            fidl::decode!(
10016                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
10017                fidl::encoding::DefaultFuchsiaResourceDialect,
10018                &mut self.parent_viewport_watcher,
10019                decoder,
10020                offset + 32,
10021                _depth
10022            )?;
10023            Ok(())
10024        }
10025    }
10026
10027    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateViewRequest {
10028        type Borrowed<'a> = &'a mut Self;
10029        fn take_or_borrow<'a>(
10030            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10031        ) -> Self::Borrowed<'a> {
10032            value
10033        }
10034    }
10035
10036    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateViewRequest {
10037        type Owned = Self;
10038
10039        #[inline(always)]
10040        fn inline_align(_context: fidl::encoding::Context) -> usize {
10041            4
10042        }
10043
10044        #[inline(always)]
10045        fn inline_size(_context: fidl::encoding::Context) -> usize {
10046            8
10047        }
10048    }
10049
10050    unsafe impl
10051        fidl::encoding::Encode<
10052            FlatlandCreateViewRequest,
10053            fidl::encoding::DefaultFuchsiaResourceDialect,
10054        > for &mut FlatlandCreateViewRequest
10055    {
10056        #[inline]
10057        unsafe fn encode(
10058            self,
10059            encoder: &mut fidl::encoding::Encoder<
10060                '_,
10061                fidl::encoding::DefaultFuchsiaResourceDialect,
10062            >,
10063            offset: usize,
10064            _depth: fidl::encoding::Depth,
10065        ) -> fidl::Result<()> {
10066            encoder.debug_check_bounds::<FlatlandCreateViewRequest>(offset);
10067            // Delegate to tuple encoding.
10068            fidl::encoding::Encode::<FlatlandCreateViewRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10069                (
10070                    <fidl_fuchsia_ui_views::ViewCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
10071                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.parent_viewport_watcher),
10072                ),
10073                encoder, offset, _depth
10074            )
10075        }
10076    }
10077    unsafe impl<
10078        T0: fidl::encoding::Encode<
10079                fidl_fuchsia_ui_views::ViewCreationToken,
10080                fidl::encoding::DefaultFuchsiaResourceDialect,
10081            >,
10082        T1: fidl::encoding::Encode<
10083                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
10084                fidl::encoding::DefaultFuchsiaResourceDialect,
10085            >,
10086    >
10087        fidl::encoding::Encode<
10088            FlatlandCreateViewRequest,
10089            fidl::encoding::DefaultFuchsiaResourceDialect,
10090        > for (T0, T1)
10091    {
10092        #[inline]
10093        unsafe fn encode(
10094            self,
10095            encoder: &mut fidl::encoding::Encoder<
10096                '_,
10097                fidl::encoding::DefaultFuchsiaResourceDialect,
10098            >,
10099            offset: usize,
10100            depth: fidl::encoding::Depth,
10101        ) -> fidl::Result<()> {
10102            encoder.debug_check_bounds::<FlatlandCreateViewRequest>(offset);
10103            // Zero out padding regions. There's no need to apply masks
10104            // because the unmasked parts will be overwritten by fields.
10105            // Write the fields.
10106            self.0.encode(encoder, offset + 0, depth)?;
10107            self.1.encode(encoder, offset + 4, depth)?;
10108            Ok(())
10109        }
10110    }
10111
10112    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10113        for FlatlandCreateViewRequest
10114    {
10115        #[inline(always)]
10116        fn new_empty() -> Self {
10117            Self {
10118                token: fidl::new_empty!(
10119                    fidl_fuchsia_ui_views::ViewCreationToken,
10120                    fidl::encoding::DefaultFuchsiaResourceDialect
10121                ),
10122                parent_viewport_watcher: fidl::new_empty!(
10123                    fidl::encoding::Endpoint<
10124                        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
10125                    >,
10126                    fidl::encoding::DefaultFuchsiaResourceDialect
10127                ),
10128            }
10129        }
10130
10131        #[inline]
10132        unsafe fn decode(
10133            &mut self,
10134            decoder: &mut fidl::encoding::Decoder<
10135                '_,
10136                fidl::encoding::DefaultFuchsiaResourceDialect,
10137            >,
10138            offset: usize,
10139            _depth: fidl::encoding::Depth,
10140        ) -> fidl::Result<()> {
10141            decoder.debug_check_bounds::<Self>(offset);
10142            // Verify that padding bytes are zero.
10143            fidl::decode!(
10144                fidl_fuchsia_ui_views::ViewCreationToken,
10145                fidl::encoding::DefaultFuchsiaResourceDialect,
10146                &mut self.token,
10147                decoder,
10148                offset + 0,
10149                _depth
10150            )?;
10151            fidl::decode!(
10152                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
10153                fidl::encoding::DefaultFuchsiaResourceDialect,
10154                &mut self.parent_viewport_watcher,
10155                decoder,
10156                offset + 4,
10157                _depth
10158            )?;
10159            Ok(())
10160        }
10161    }
10162
10163    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateViewportRequest {
10164        type Borrowed<'a> = &'a mut Self;
10165        fn take_or_borrow<'a>(
10166            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10167        ) -> Self::Borrowed<'a> {
10168            value
10169        }
10170    }
10171
10172    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateViewportRequest {
10173        type Owned = Self;
10174
10175        #[inline(always)]
10176        fn inline_align(_context: fidl::encoding::Context) -> usize {
10177            8
10178        }
10179
10180        #[inline(always)]
10181        fn inline_size(_context: fidl::encoding::Context) -> usize {
10182            40
10183        }
10184    }
10185
10186    unsafe impl
10187        fidl::encoding::Encode<
10188            FlatlandCreateViewportRequest,
10189            fidl::encoding::DefaultFuchsiaResourceDialect,
10190        > for &mut FlatlandCreateViewportRequest
10191    {
10192        #[inline]
10193        unsafe fn encode(
10194            self,
10195            encoder: &mut fidl::encoding::Encoder<
10196                '_,
10197                fidl::encoding::DefaultFuchsiaResourceDialect,
10198            >,
10199            offset: usize,
10200            _depth: fidl::encoding::Depth,
10201        ) -> fidl::Result<()> {
10202            encoder.debug_check_bounds::<FlatlandCreateViewportRequest>(offset);
10203            // Delegate to tuple encoding.
10204            fidl::encoding::Encode::<FlatlandCreateViewportRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10205                (
10206                    <ContentId as fidl::encoding::ValueTypeMarker>::borrow(&self.viewport_id),
10207                    <fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
10208                    <ViewportProperties as fidl::encoding::ValueTypeMarker>::borrow(&self.properties),
10209                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.child_view_watcher),
10210                ),
10211                encoder, offset, _depth
10212            )
10213        }
10214    }
10215    unsafe impl<
10216        T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>,
10217        T1: fidl::encoding::Encode<
10218                fidl_fuchsia_ui_views::ViewportCreationToken,
10219                fidl::encoding::DefaultFuchsiaResourceDialect,
10220            >,
10221        T2: fidl::encoding::Encode<ViewportProperties, fidl::encoding::DefaultFuchsiaResourceDialect>,
10222        T3: fidl::encoding::Encode<
10223                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10224                fidl::encoding::DefaultFuchsiaResourceDialect,
10225            >,
10226    >
10227        fidl::encoding::Encode<
10228            FlatlandCreateViewportRequest,
10229            fidl::encoding::DefaultFuchsiaResourceDialect,
10230        > for (T0, T1, T2, T3)
10231    {
10232        #[inline]
10233        unsafe fn encode(
10234            self,
10235            encoder: &mut fidl::encoding::Encoder<
10236                '_,
10237                fidl::encoding::DefaultFuchsiaResourceDialect,
10238            >,
10239            offset: usize,
10240            depth: fidl::encoding::Depth,
10241        ) -> fidl::Result<()> {
10242            encoder.debug_check_bounds::<FlatlandCreateViewportRequest>(offset);
10243            // Zero out padding regions. There's no need to apply masks
10244            // because the unmasked parts will be overwritten by fields.
10245            unsafe {
10246                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
10247                (ptr as *mut u64).write_unaligned(0);
10248            }
10249            unsafe {
10250                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
10251                (ptr as *mut u64).write_unaligned(0);
10252            }
10253            // Write the fields.
10254            self.0.encode(encoder, offset + 0, depth)?;
10255            self.1.encode(encoder, offset + 8, depth)?;
10256            self.2.encode(encoder, offset + 16, depth)?;
10257            self.3.encode(encoder, offset + 32, depth)?;
10258            Ok(())
10259        }
10260    }
10261
10262    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10263        for FlatlandCreateViewportRequest
10264    {
10265        #[inline(always)]
10266        fn new_empty() -> Self {
10267            Self {
10268                viewport_id: fidl::new_empty!(
10269                    ContentId,
10270                    fidl::encoding::DefaultFuchsiaResourceDialect
10271                ),
10272                token: fidl::new_empty!(
10273                    fidl_fuchsia_ui_views::ViewportCreationToken,
10274                    fidl::encoding::DefaultFuchsiaResourceDialect
10275                ),
10276                properties: fidl::new_empty!(
10277                    ViewportProperties,
10278                    fidl::encoding::DefaultFuchsiaResourceDialect
10279                ),
10280                child_view_watcher: fidl::new_empty!(
10281                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10282                    fidl::encoding::DefaultFuchsiaResourceDialect
10283                ),
10284            }
10285        }
10286
10287        #[inline]
10288        unsafe fn decode(
10289            &mut self,
10290            decoder: &mut fidl::encoding::Decoder<
10291                '_,
10292                fidl::encoding::DefaultFuchsiaResourceDialect,
10293            >,
10294            offset: usize,
10295            _depth: fidl::encoding::Depth,
10296        ) -> fidl::Result<()> {
10297            decoder.debug_check_bounds::<Self>(offset);
10298            // Verify that padding bytes are zero.
10299            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
10300            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10301            let mask = 0xffffffff00000000u64;
10302            let maskedval = padval & mask;
10303            if maskedval != 0 {
10304                return Err(fidl::Error::NonZeroPadding {
10305                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
10306                });
10307            }
10308            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
10309            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10310            let mask = 0xffffffff00000000u64;
10311            let maskedval = padval & mask;
10312            if maskedval != 0 {
10313                return Err(fidl::Error::NonZeroPadding {
10314                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
10315                });
10316            }
10317            fidl::decode!(
10318                ContentId,
10319                fidl::encoding::DefaultFuchsiaResourceDialect,
10320                &mut self.viewport_id,
10321                decoder,
10322                offset + 0,
10323                _depth
10324            )?;
10325            fidl::decode!(
10326                fidl_fuchsia_ui_views::ViewportCreationToken,
10327                fidl::encoding::DefaultFuchsiaResourceDialect,
10328                &mut self.token,
10329                decoder,
10330                offset + 8,
10331                _depth
10332            )?;
10333            fidl::decode!(
10334                ViewportProperties,
10335                fidl::encoding::DefaultFuchsiaResourceDialect,
10336                &mut self.properties,
10337                decoder,
10338                offset + 16,
10339                _depth
10340            )?;
10341            fidl::decode!(
10342                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10343                fidl::encoding::DefaultFuchsiaResourceDialect,
10344                &mut self.child_view_watcher,
10345                decoder,
10346                offset + 32,
10347                _depth
10348            )?;
10349            Ok(())
10350        }
10351    }
10352
10353    impl fidl::encoding::ResourceTypeMarker for FlatlandDisplaySetContentRequest {
10354        type Borrowed<'a> = &'a mut Self;
10355        fn take_or_borrow<'a>(
10356            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10357        ) -> Self::Borrowed<'a> {
10358            value
10359        }
10360    }
10361
10362    unsafe impl fidl::encoding::TypeMarker for FlatlandDisplaySetContentRequest {
10363        type Owned = Self;
10364
10365        #[inline(always)]
10366        fn inline_align(_context: fidl::encoding::Context) -> usize {
10367            4
10368        }
10369
10370        #[inline(always)]
10371        fn inline_size(_context: fidl::encoding::Context) -> usize {
10372            8
10373        }
10374    }
10375
10376    unsafe impl
10377        fidl::encoding::Encode<
10378            FlatlandDisplaySetContentRequest,
10379            fidl::encoding::DefaultFuchsiaResourceDialect,
10380        > for &mut FlatlandDisplaySetContentRequest
10381    {
10382        #[inline]
10383        unsafe fn encode(
10384            self,
10385            encoder: &mut fidl::encoding::Encoder<
10386                '_,
10387                fidl::encoding::DefaultFuchsiaResourceDialect,
10388            >,
10389            offset: usize,
10390            _depth: fidl::encoding::Depth,
10391        ) -> fidl::Result<()> {
10392            encoder.debug_check_bounds::<FlatlandDisplaySetContentRequest>(offset);
10393            // Delegate to tuple encoding.
10394            fidl::encoding::Encode::<FlatlandDisplaySetContentRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10395                (
10396                    <fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
10397                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.child_view_watcher),
10398                ),
10399                encoder, offset, _depth
10400            )
10401        }
10402    }
10403    unsafe impl<
10404        T0: fidl::encoding::Encode<
10405                fidl_fuchsia_ui_views::ViewportCreationToken,
10406                fidl::encoding::DefaultFuchsiaResourceDialect,
10407            >,
10408        T1: fidl::encoding::Encode<
10409                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10410                fidl::encoding::DefaultFuchsiaResourceDialect,
10411            >,
10412    >
10413        fidl::encoding::Encode<
10414            FlatlandDisplaySetContentRequest,
10415            fidl::encoding::DefaultFuchsiaResourceDialect,
10416        > for (T0, T1)
10417    {
10418        #[inline]
10419        unsafe fn encode(
10420            self,
10421            encoder: &mut fidl::encoding::Encoder<
10422                '_,
10423                fidl::encoding::DefaultFuchsiaResourceDialect,
10424            >,
10425            offset: usize,
10426            depth: fidl::encoding::Depth,
10427        ) -> fidl::Result<()> {
10428            encoder.debug_check_bounds::<FlatlandDisplaySetContentRequest>(offset);
10429            // Zero out padding regions. There's no need to apply masks
10430            // because the unmasked parts will be overwritten by fields.
10431            // Write the fields.
10432            self.0.encode(encoder, offset + 0, depth)?;
10433            self.1.encode(encoder, offset + 4, depth)?;
10434            Ok(())
10435        }
10436    }
10437
10438    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10439        for FlatlandDisplaySetContentRequest
10440    {
10441        #[inline(always)]
10442        fn new_empty() -> Self {
10443            Self {
10444                token: fidl::new_empty!(
10445                    fidl_fuchsia_ui_views::ViewportCreationToken,
10446                    fidl::encoding::DefaultFuchsiaResourceDialect
10447                ),
10448                child_view_watcher: fidl::new_empty!(
10449                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10450                    fidl::encoding::DefaultFuchsiaResourceDialect
10451                ),
10452            }
10453        }
10454
10455        #[inline]
10456        unsafe fn decode(
10457            &mut self,
10458            decoder: &mut fidl::encoding::Decoder<
10459                '_,
10460                fidl::encoding::DefaultFuchsiaResourceDialect,
10461            >,
10462            offset: usize,
10463            _depth: fidl::encoding::Depth,
10464        ) -> fidl::Result<()> {
10465            decoder.debug_check_bounds::<Self>(offset);
10466            // Verify that padding bytes are zero.
10467            fidl::decode!(
10468                fidl_fuchsia_ui_views::ViewportCreationToken,
10469                fidl::encoding::DefaultFuchsiaResourceDialect,
10470                &mut self.token,
10471                decoder,
10472                offset + 0,
10473                _depth
10474            )?;
10475            fidl::decode!(
10476                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
10477                fidl::encoding::DefaultFuchsiaResourceDialect,
10478                &mut self.child_view_watcher,
10479                decoder,
10480                offset + 4,
10481                _depth
10482            )?;
10483            Ok(())
10484        }
10485    }
10486
10487    impl fidl::encoding::ResourceTypeMarker for FlatlandPresentRequest {
10488        type Borrowed<'a> = &'a mut Self;
10489        fn take_or_borrow<'a>(
10490            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10491        ) -> Self::Borrowed<'a> {
10492            value
10493        }
10494    }
10495
10496    unsafe impl fidl::encoding::TypeMarker for FlatlandPresentRequest {
10497        type Owned = Self;
10498
10499        #[inline(always)]
10500        fn inline_align(_context: fidl::encoding::Context) -> usize {
10501            8
10502        }
10503
10504        #[inline(always)]
10505        fn inline_size(_context: fidl::encoding::Context) -> usize {
10506            16
10507        }
10508    }
10509
10510    unsafe impl
10511        fidl::encoding::Encode<
10512            FlatlandPresentRequest,
10513            fidl::encoding::DefaultFuchsiaResourceDialect,
10514        > for &mut FlatlandPresentRequest
10515    {
10516        #[inline]
10517        unsafe fn encode(
10518            self,
10519            encoder: &mut fidl::encoding::Encoder<
10520                '_,
10521                fidl::encoding::DefaultFuchsiaResourceDialect,
10522            >,
10523            offset: usize,
10524            _depth: fidl::encoding::Depth,
10525        ) -> fidl::Result<()> {
10526            encoder.debug_check_bounds::<FlatlandPresentRequest>(offset);
10527            // Delegate to tuple encoding.
10528            fidl::encoding::Encode::<
10529                FlatlandPresentRequest,
10530                fidl::encoding::DefaultFuchsiaResourceDialect,
10531            >::encode(
10532                (<PresentArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10533                    &mut self.args,
10534                ),),
10535                encoder,
10536                offset,
10537                _depth,
10538            )
10539        }
10540    }
10541    unsafe impl<
10542        T0: fidl::encoding::Encode<PresentArgs, fidl::encoding::DefaultFuchsiaResourceDialect>,
10543    >
10544        fidl::encoding::Encode<
10545            FlatlandPresentRequest,
10546            fidl::encoding::DefaultFuchsiaResourceDialect,
10547        > for (T0,)
10548    {
10549        #[inline]
10550        unsafe fn encode(
10551            self,
10552            encoder: &mut fidl::encoding::Encoder<
10553                '_,
10554                fidl::encoding::DefaultFuchsiaResourceDialect,
10555            >,
10556            offset: usize,
10557            depth: fidl::encoding::Depth,
10558        ) -> fidl::Result<()> {
10559            encoder.debug_check_bounds::<FlatlandPresentRequest>(offset);
10560            // Zero out padding regions. There's no need to apply masks
10561            // because the unmasked parts will be overwritten by fields.
10562            // Write the fields.
10563            self.0.encode(encoder, offset + 0, depth)?;
10564            Ok(())
10565        }
10566    }
10567
10568    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10569        for FlatlandPresentRequest
10570    {
10571        #[inline(always)]
10572        fn new_empty() -> Self {
10573            Self {
10574                args: fidl::new_empty!(PresentArgs, fidl::encoding::DefaultFuchsiaResourceDialect),
10575            }
10576        }
10577
10578        #[inline]
10579        unsafe fn decode(
10580            &mut self,
10581            decoder: &mut fidl::encoding::Decoder<
10582                '_,
10583                fidl::encoding::DefaultFuchsiaResourceDialect,
10584            >,
10585            offset: usize,
10586            _depth: fidl::encoding::Depth,
10587        ) -> fidl::Result<()> {
10588            decoder.debug_check_bounds::<Self>(offset);
10589            // Verify that padding bytes are zero.
10590            fidl::decode!(
10591                PresentArgs,
10592                fidl::encoding::DefaultFuchsiaResourceDialect,
10593                &mut self.args,
10594                decoder,
10595                offset + 0,
10596                _depth
10597            )?;
10598            Ok(())
10599        }
10600    }
10601
10602    impl fidl::encoding::ResourceTypeMarker for FlatlandReleaseViewportResponse {
10603        type Borrowed<'a> = &'a mut Self;
10604        fn take_or_borrow<'a>(
10605            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10606        ) -> Self::Borrowed<'a> {
10607            value
10608        }
10609    }
10610
10611    unsafe impl fidl::encoding::TypeMarker for FlatlandReleaseViewportResponse {
10612        type Owned = Self;
10613
10614        #[inline(always)]
10615        fn inline_align(_context: fidl::encoding::Context) -> usize {
10616            4
10617        }
10618
10619        #[inline(always)]
10620        fn inline_size(_context: fidl::encoding::Context) -> usize {
10621            4
10622        }
10623    }
10624
10625    unsafe impl
10626        fidl::encoding::Encode<
10627            FlatlandReleaseViewportResponse,
10628            fidl::encoding::DefaultFuchsiaResourceDialect,
10629        > for &mut FlatlandReleaseViewportResponse
10630    {
10631        #[inline]
10632        unsafe fn encode(
10633            self,
10634            encoder: &mut fidl::encoding::Encoder<
10635                '_,
10636                fidl::encoding::DefaultFuchsiaResourceDialect,
10637            >,
10638            offset: usize,
10639            _depth: fidl::encoding::Depth,
10640        ) -> fidl::Result<()> {
10641            encoder.debug_check_bounds::<FlatlandReleaseViewportResponse>(offset);
10642            // Delegate to tuple encoding.
10643            fidl::encoding::Encode::<FlatlandReleaseViewportResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10644                (
10645                    <fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
10646                ),
10647                encoder, offset, _depth
10648            )
10649        }
10650    }
10651    unsafe impl<
10652        T0: fidl::encoding::Encode<
10653                fidl_fuchsia_ui_views::ViewportCreationToken,
10654                fidl::encoding::DefaultFuchsiaResourceDialect,
10655            >,
10656    >
10657        fidl::encoding::Encode<
10658            FlatlandReleaseViewportResponse,
10659            fidl::encoding::DefaultFuchsiaResourceDialect,
10660        > for (T0,)
10661    {
10662        #[inline]
10663        unsafe fn encode(
10664            self,
10665            encoder: &mut fidl::encoding::Encoder<
10666                '_,
10667                fidl::encoding::DefaultFuchsiaResourceDialect,
10668            >,
10669            offset: usize,
10670            depth: fidl::encoding::Depth,
10671        ) -> fidl::Result<()> {
10672            encoder.debug_check_bounds::<FlatlandReleaseViewportResponse>(offset);
10673            // Zero out padding regions. There's no need to apply masks
10674            // because the unmasked parts will be overwritten by fields.
10675            // Write the fields.
10676            self.0.encode(encoder, offset + 0, depth)?;
10677            Ok(())
10678        }
10679    }
10680
10681    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10682        for FlatlandReleaseViewportResponse
10683    {
10684        #[inline(always)]
10685        fn new_empty() -> Self {
10686            Self {
10687                token: fidl::new_empty!(
10688                    fidl_fuchsia_ui_views::ViewportCreationToken,
10689                    fidl::encoding::DefaultFuchsiaResourceDialect
10690                ),
10691            }
10692        }
10693
10694        #[inline]
10695        unsafe fn decode(
10696            &mut self,
10697            decoder: &mut fidl::encoding::Decoder<
10698                '_,
10699                fidl::encoding::DefaultFuchsiaResourceDialect,
10700            >,
10701            offset: usize,
10702            _depth: fidl::encoding::Depth,
10703        ) -> fidl::Result<()> {
10704            decoder.debug_check_bounds::<Self>(offset);
10705            // Verify that padding bytes are zero.
10706            fidl::decode!(
10707                fidl_fuchsia_ui_views::ViewportCreationToken,
10708                fidl::encoding::DefaultFuchsiaResourceDialect,
10709                &mut self.token,
10710                decoder,
10711                offset + 0,
10712                _depth
10713            )?;
10714            Ok(())
10715        }
10716    }
10717
10718    impl fidl::encoding::ResourceTypeMarker for FlatlandSetSolidFillRequest {
10719        type Borrowed<'a> = &'a mut Self;
10720        fn take_or_borrow<'a>(
10721            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10722        ) -> Self::Borrowed<'a> {
10723            value
10724        }
10725    }
10726
10727    unsafe impl fidl::encoding::TypeMarker for FlatlandSetSolidFillRequest {
10728        type Owned = Self;
10729
10730        #[inline(always)]
10731        fn inline_align(_context: fidl::encoding::Context) -> usize {
10732            8
10733        }
10734
10735        #[inline(always)]
10736        fn inline_size(_context: fidl::encoding::Context) -> usize {
10737            32
10738        }
10739    }
10740
10741    unsafe impl
10742        fidl::encoding::Encode<
10743            FlatlandSetSolidFillRequest,
10744            fidl::encoding::DefaultFuchsiaResourceDialect,
10745        > for &mut FlatlandSetSolidFillRequest
10746    {
10747        #[inline]
10748        unsafe fn encode(
10749            self,
10750            encoder: &mut fidl::encoding::Encoder<
10751                '_,
10752                fidl::encoding::DefaultFuchsiaResourceDialect,
10753            >,
10754            offset: usize,
10755            _depth: fidl::encoding::Depth,
10756        ) -> fidl::Result<()> {
10757            encoder.debug_check_bounds::<FlatlandSetSolidFillRequest>(offset);
10758            // Delegate to tuple encoding.
10759            fidl::encoding::Encode::<
10760                FlatlandSetSolidFillRequest,
10761                fidl::encoding::DefaultFuchsiaResourceDialect,
10762            >::encode(
10763                (
10764                    <ContentId as fidl::encoding::ValueTypeMarker>::borrow(&self.rect_id),
10765                    <ColorRgba as fidl::encoding::ValueTypeMarker>::borrow(&self.color),
10766                    <fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow(
10767                        &self.size,
10768                    ),
10769                ),
10770                encoder,
10771                offset,
10772                _depth,
10773            )
10774        }
10775    }
10776    unsafe impl<
10777        T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>,
10778        T1: fidl::encoding::Encode<ColorRgba, fidl::encoding::DefaultFuchsiaResourceDialect>,
10779        T2: fidl::encoding::Encode<
10780                fidl_fuchsia_math::SizeU,
10781                fidl::encoding::DefaultFuchsiaResourceDialect,
10782            >,
10783    >
10784        fidl::encoding::Encode<
10785            FlatlandSetSolidFillRequest,
10786            fidl::encoding::DefaultFuchsiaResourceDialect,
10787        > for (T0, T1, T2)
10788    {
10789        #[inline]
10790        unsafe fn encode(
10791            self,
10792            encoder: &mut fidl::encoding::Encoder<
10793                '_,
10794                fidl::encoding::DefaultFuchsiaResourceDialect,
10795            >,
10796            offset: usize,
10797            depth: fidl::encoding::Depth,
10798        ) -> fidl::Result<()> {
10799            encoder.debug_check_bounds::<FlatlandSetSolidFillRequest>(offset);
10800            // Zero out padding regions. There's no need to apply masks
10801            // because the unmasked parts will be overwritten by fields.
10802            // Write the fields.
10803            self.0.encode(encoder, offset + 0, depth)?;
10804            self.1.encode(encoder, offset + 8, depth)?;
10805            self.2.encode(encoder, offset + 24, depth)?;
10806            Ok(())
10807        }
10808    }
10809
10810    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10811        for FlatlandSetSolidFillRequest
10812    {
10813        #[inline(always)]
10814        fn new_empty() -> Self {
10815            Self {
10816                rect_id: fidl::new_empty!(ContentId, fidl::encoding::DefaultFuchsiaResourceDialect),
10817                color: fidl::new_empty!(ColorRgba, fidl::encoding::DefaultFuchsiaResourceDialect),
10818                size: fidl::new_empty!(
10819                    fidl_fuchsia_math::SizeU,
10820                    fidl::encoding::DefaultFuchsiaResourceDialect
10821                ),
10822            }
10823        }
10824
10825        #[inline]
10826        unsafe fn decode(
10827            &mut self,
10828            decoder: &mut fidl::encoding::Decoder<
10829                '_,
10830                fidl::encoding::DefaultFuchsiaResourceDialect,
10831            >,
10832            offset: usize,
10833            _depth: fidl::encoding::Depth,
10834        ) -> fidl::Result<()> {
10835            decoder.debug_check_bounds::<Self>(offset);
10836            // Verify that padding bytes are zero.
10837            fidl::decode!(
10838                ContentId,
10839                fidl::encoding::DefaultFuchsiaResourceDialect,
10840                &mut self.rect_id,
10841                decoder,
10842                offset + 0,
10843                _depth
10844            )?;
10845            fidl::decode!(
10846                ColorRgba,
10847                fidl::encoding::DefaultFuchsiaResourceDialect,
10848                &mut self.color,
10849                decoder,
10850                offset + 8,
10851                _depth
10852            )?;
10853            fidl::decode!(
10854                fidl_fuchsia_math::SizeU,
10855                fidl::encoding::DefaultFuchsiaResourceDialect,
10856                &mut self.size,
10857                decoder,
10858                offset + 24,
10859                _depth
10860            )?;
10861            Ok(())
10862        }
10863    }
10864
10865    impl fidl::encoding::ResourceTypeMarker for TrustedFlatlandFactoryCreateFlatlandRequest {
10866        type Borrowed<'a> = &'a mut Self;
10867        fn take_or_borrow<'a>(
10868            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10869        ) -> Self::Borrowed<'a> {
10870            value
10871        }
10872    }
10873
10874    unsafe impl fidl::encoding::TypeMarker for TrustedFlatlandFactoryCreateFlatlandRequest {
10875        type Owned = Self;
10876
10877        #[inline(always)]
10878        fn inline_align(_context: fidl::encoding::Context) -> usize {
10879            8
10880        }
10881
10882        #[inline(always)]
10883        fn inline_size(_context: fidl::encoding::Context) -> usize {
10884            24
10885        }
10886    }
10887
10888    unsafe impl
10889        fidl::encoding::Encode<
10890            TrustedFlatlandFactoryCreateFlatlandRequest,
10891            fidl::encoding::DefaultFuchsiaResourceDialect,
10892        > for &mut TrustedFlatlandFactoryCreateFlatlandRequest
10893    {
10894        #[inline]
10895        unsafe fn encode(
10896            self,
10897            encoder: &mut fidl::encoding::Encoder<
10898                '_,
10899                fidl::encoding::DefaultFuchsiaResourceDialect,
10900            >,
10901            offset: usize,
10902            _depth: fidl::encoding::Depth,
10903        ) -> fidl::Result<()> {
10904            encoder.debug_check_bounds::<TrustedFlatlandFactoryCreateFlatlandRequest>(offset);
10905            // Delegate to tuple encoding.
10906            fidl::encoding::Encode::<TrustedFlatlandFactoryCreateFlatlandRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
10907                (
10908                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FlatlandMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.server_end),
10909                    <TrustedFlatlandConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.config),
10910                ),
10911                encoder, offset, _depth
10912            )
10913        }
10914    }
10915    unsafe impl<
10916        T0: fidl::encoding::Encode<
10917                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FlatlandMarker>>,
10918                fidl::encoding::DefaultFuchsiaResourceDialect,
10919            >,
10920        T1: fidl::encoding::Encode<
10921                TrustedFlatlandConfig,
10922                fidl::encoding::DefaultFuchsiaResourceDialect,
10923            >,
10924    >
10925        fidl::encoding::Encode<
10926            TrustedFlatlandFactoryCreateFlatlandRequest,
10927            fidl::encoding::DefaultFuchsiaResourceDialect,
10928        > for (T0, T1)
10929    {
10930        #[inline]
10931        unsafe fn encode(
10932            self,
10933            encoder: &mut fidl::encoding::Encoder<
10934                '_,
10935                fidl::encoding::DefaultFuchsiaResourceDialect,
10936            >,
10937            offset: usize,
10938            depth: fidl::encoding::Depth,
10939        ) -> fidl::Result<()> {
10940            encoder.debug_check_bounds::<TrustedFlatlandFactoryCreateFlatlandRequest>(offset);
10941            // Zero out padding regions. There's no need to apply masks
10942            // because the unmasked parts will be overwritten by fields.
10943            unsafe {
10944                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
10945                (ptr as *mut u64).write_unaligned(0);
10946            }
10947            // Write the fields.
10948            self.0.encode(encoder, offset + 0, depth)?;
10949            self.1.encode(encoder, offset + 8, depth)?;
10950            Ok(())
10951        }
10952    }
10953
10954    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10955        for TrustedFlatlandFactoryCreateFlatlandRequest
10956    {
10957        #[inline(always)]
10958        fn new_empty() -> Self {
10959            Self {
10960                server_end: fidl::new_empty!(
10961                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FlatlandMarker>>,
10962                    fidl::encoding::DefaultFuchsiaResourceDialect
10963                ),
10964                config: fidl::new_empty!(
10965                    TrustedFlatlandConfig,
10966                    fidl::encoding::DefaultFuchsiaResourceDialect
10967                ),
10968            }
10969        }
10970
10971        #[inline]
10972        unsafe fn decode(
10973            &mut self,
10974            decoder: &mut fidl::encoding::Decoder<
10975                '_,
10976                fidl::encoding::DefaultFuchsiaResourceDialect,
10977            >,
10978            offset: usize,
10979            _depth: fidl::encoding::Depth,
10980        ) -> fidl::Result<()> {
10981            decoder.debug_check_bounds::<Self>(offset);
10982            // Verify that padding bytes are zero.
10983            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
10984            let padval = unsafe { (ptr as *const u64).read_unaligned() };
10985            let mask = 0xffffffff00000000u64;
10986            let maskedval = padval & mask;
10987            if maskedval != 0 {
10988                return Err(fidl::Error::NonZeroPadding {
10989                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
10990                });
10991            }
10992            fidl::decode!(
10993                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FlatlandMarker>>,
10994                fidl::encoding::DefaultFuchsiaResourceDialect,
10995                &mut self.server_end,
10996                decoder,
10997                offset + 0,
10998                _depth
10999            )?;
11000            fidl::decode!(
11001                TrustedFlatlandConfig,
11002                fidl::encoding::DefaultFuchsiaResourceDialect,
11003                &mut self.config,
11004                decoder,
11005                offset + 8,
11006                _depth
11007            )?;
11008            Ok(())
11009        }
11010    }
11011
11012    impl FrameInfo {
11013        #[inline(always)]
11014        fn max_ordinal_present(&self) -> u64 {
11015            if let Some(_) = self.buffer_id {
11016                return 1;
11017            }
11018            0
11019        }
11020    }
11021
11022    impl fidl::encoding::ResourceTypeMarker for FrameInfo {
11023        type Borrowed<'a> = &'a mut Self;
11024        fn take_or_borrow<'a>(
11025            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11026        ) -> Self::Borrowed<'a> {
11027            value
11028        }
11029    }
11030
11031    unsafe impl fidl::encoding::TypeMarker for FrameInfo {
11032        type Owned = Self;
11033
11034        #[inline(always)]
11035        fn inline_align(_context: fidl::encoding::Context) -> usize {
11036            8
11037        }
11038
11039        #[inline(always)]
11040        fn inline_size(_context: fidl::encoding::Context) -> usize {
11041            16
11042        }
11043    }
11044
11045    unsafe impl fidl::encoding::Encode<FrameInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
11046        for &mut FrameInfo
11047    {
11048        unsafe fn encode(
11049            self,
11050            encoder: &mut fidl::encoding::Encoder<
11051                '_,
11052                fidl::encoding::DefaultFuchsiaResourceDialect,
11053            >,
11054            offset: usize,
11055            mut depth: fidl::encoding::Depth,
11056        ) -> fidl::Result<()> {
11057            encoder.debug_check_bounds::<FrameInfo>(offset);
11058            // Vector header
11059            let max_ordinal: u64 = self.max_ordinal_present();
11060            encoder.write_num(max_ordinal, offset);
11061            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11062            // Calling encoder.out_of_line_offset(0) is not allowed.
11063            if max_ordinal == 0 {
11064                return Ok(());
11065            }
11066            depth.increment()?;
11067            let envelope_size = 8;
11068            let bytes_len = max_ordinal as usize * envelope_size;
11069            #[allow(unused_variables)]
11070            let offset = encoder.out_of_line_offset(bytes_len);
11071            let mut _prev_end_offset: usize = 0;
11072            if 1 > max_ordinal {
11073                return Ok(());
11074            }
11075
11076            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11077            // are envelope_size bytes.
11078            let cur_offset: usize = (1 - 1) * envelope_size;
11079
11080            // Zero reserved fields.
11081            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11082
11083            // Safety:
11084            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11085            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11086            //   envelope_size bytes, there is always sufficient room.
11087            fidl::encoding::encode_in_envelope_optional::<
11088                u32,
11089                fidl::encoding::DefaultFuchsiaResourceDialect,
11090            >(
11091                self.buffer_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
11092                encoder,
11093                offset + cur_offset,
11094                depth,
11095            )?;
11096
11097            _prev_end_offset = cur_offset + envelope_size;
11098
11099            Ok(())
11100        }
11101    }
11102
11103    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FrameInfo {
11104        #[inline(always)]
11105        fn new_empty() -> Self {
11106            Self::default()
11107        }
11108
11109        unsafe fn decode(
11110            &mut self,
11111            decoder: &mut fidl::encoding::Decoder<
11112                '_,
11113                fidl::encoding::DefaultFuchsiaResourceDialect,
11114            >,
11115            offset: usize,
11116            mut depth: fidl::encoding::Depth,
11117        ) -> fidl::Result<()> {
11118            decoder.debug_check_bounds::<Self>(offset);
11119            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11120                None => return Err(fidl::Error::NotNullable),
11121                Some(len) => len,
11122            };
11123            // Calling decoder.out_of_line_offset(0) is not allowed.
11124            if len == 0 {
11125                return Ok(());
11126            };
11127            depth.increment()?;
11128            let envelope_size = 8;
11129            let bytes_len = len * envelope_size;
11130            let offset = decoder.out_of_line_offset(bytes_len)?;
11131            // Decode the envelope for each type.
11132            let mut _next_ordinal_to_read = 0;
11133            let mut next_offset = offset;
11134            let end_offset = offset + bytes_len;
11135            _next_ordinal_to_read += 1;
11136            if next_offset >= end_offset {
11137                return Ok(());
11138            }
11139
11140            // Decode unknown envelopes for gaps in ordinals.
11141            while _next_ordinal_to_read < 1 {
11142                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11143                _next_ordinal_to_read += 1;
11144                next_offset += envelope_size;
11145            }
11146
11147            let next_out_of_line = decoder.next_out_of_line();
11148            let handles_before = decoder.remaining_handles();
11149            if let Some((inlined, num_bytes, num_handles)) =
11150                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11151            {
11152                let member_inline_size =
11153                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11154                if inlined != (member_inline_size <= 4) {
11155                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11156                }
11157                let inner_offset;
11158                let mut inner_depth = depth.clone();
11159                if inlined {
11160                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11161                    inner_offset = next_offset;
11162                } else {
11163                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11164                    inner_depth.increment()?;
11165                }
11166                let val_ref = self.buffer_id.get_or_insert_with(|| {
11167                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
11168                });
11169                fidl::decode!(
11170                    u32,
11171                    fidl::encoding::DefaultFuchsiaResourceDialect,
11172                    val_ref,
11173                    decoder,
11174                    inner_offset,
11175                    inner_depth
11176                )?;
11177                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11178                {
11179                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11180                }
11181                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11182                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11183                }
11184            }
11185
11186            next_offset += envelope_size;
11187
11188            // Decode the remaining unknown envelopes.
11189            while next_offset < end_offset {
11190                _next_ordinal_to_read += 1;
11191                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11192                next_offset += envelope_size;
11193            }
11194
11195            Ok(())
11196        }
11197    }
11198
11199    impl GetNextFrameArgs {
11200        #[inline(always)]
11201        fn max_ordinal_present(&self) -> u64 {
11202            if let Some(_) = self.event {
11203                return 1;
11204            }
11205            0
11206        }
11207    }
11208
11209    impl fidl::encoding::ResourceTypeMarker for GetNextFrameArgs {
11210        type Borrowed<'a> = &'a mut Self;
11211        fn take_or_borrow<'a>(
11212            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11213        ) -> Self::Borrowed<'a> {
11214            value
11215        }
11216    }
11217
11218    unsafe impl fidl::encoding::TypeMarker for GetNextFrameArgs {
11219        type Owned = Self;
11220
11221        #[inline(always)]
11222        fn inline_align(_context: fidl::encoding::Context) -> usize {
11223            8
11224        }
11225
11226        #[inline(always)]
11227        fn inline_size(_context: fidl::encoding::Context) -> usize {
11228            16
11229        }
11230    }
11231
11232    unsafe impl
11233        fidl::encoding::Encode<GetNextFrameArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
11234        for &mut GetNextFrameArgs
11235    {
11236        unsafe fn encode(
11237            self,
11238            encoder: &mut fidl::encoding::Encoder<
11239                '_,
11240                fidl::encoding::DefaultFuchsiaResourceDialect,
11241            >,
11242            offset: usize,
11243            mut depth: fidl::encoding::Depth,
11244        ) -> fidl::Result<()> {
11245            encoder.debug_check_bounds::<GetNextFrameArgs>(offset);
11246            // Vector header
11247            let max_ordinal: u64 = self.max_ordinal_present();
11248            encoder.write_num(max_ordinal, offset);
11249            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11250            // Calling encoder.out_of_line_offset(0) is not allowed.
11251            if max_ordinal == 0 {
11252                return Ok(());
11253            }
11254            depth.increment()?;
11255            let envelope_size = 8;
11256            let bytes_len = max_ordinal as usize * envelope_size;
11257            #[allow(unused_variables)]
11258            let offset = encoder.out_of_line_offset(bytes_len);
11259            let mut _prev_end_offset: usize = 0;
11260            if 1 > max_ordinal {
11261                return Ok(());
11262            }
11263
11264            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11265            // are envelope_size bytes.
11266            let cur_offset: usize = (1 - 1) * envelope_size;
11267
11268            // Zero reserved fields.
11269            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11270
11271            // Safety:
11272            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11273            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11274            //   envelope_size bytes, there is always sufficient room.
11275            fidl::encoding::encode_in_envelope_optional::<
11276                fidl::encoding::HandleType<
11277                    fidl::Event,
11278                    { fidl::ObjectType::EVENT.into_raw() },
11279                    2147483648,
11280                >,
11281                fidl::encoding::DefaultFuchsiaResourceDialect,
11282            >(
11283                self.event.as_mut().map(
11284                    <fidl::encoding::HandleType<
11285                        fidl::Event,
11286                        { fidl::ObjectType::EVENT.into_raw() },
11287                        2147483648,
11288                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11289                ),
11290                encoder,
11291                offset + cur_offset,
11292                depth,
11293            )?;
11294
11295            _prev_end_offset = cur_offset + envelope_size;
11296
11297            Ok(())
11298        }
11299    }
11300
11301    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11302        for GetNextFrameArgs
11303    {
11304        #[inline(always)]
11305        fn new_empty() -> Self {
11306            Self::default()
11307        }
11308
11309        unsafe fn decode(
11310            &mut self,
11311            decoder: &mut fidl::encoding::Decoder<
11312                '_,
11313                fidl::encoding::DefaultFuchsiaResourceDialect,
11314            >,
11315            offset: usize,
11316            mut depth: fidl::encoding::Depth,
11317        ) -> fidl::Result<()> {
11318            decoder.debug_check_bounds::<Self>(offset);
11319            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11320                None => return Err(fidl::Error::NotNullable),
11321                Some(len) => len,
11322            };
11323            // Calling decoder.out_of_line_offset(0) is not allowed.
11324            if len == 0 {
11325                return Ok(());
11326            };
11327            depth.increment()?;
11328            let envelope_size = 8;
11329            let bytes_len = len * envelope_size;
11330            let offset = decoder.out_of_line_offset(bytes_len)?;
11331            // Decode the envelope for each type.
11332            let mut _next_ordinal_to_read = 0;
11333            let mut next_offset = offset;
11334            let end_offset = offset + bytes_len;
11335            _next_ordinal_to_read += 1;
11336            if next_offset >= end_offset {
11337                return Ok(());
11338            }
11339
11340            // Decode unknown envelopes for gaps in ordinals.
11341            while _next_ordinal_to_read < 1 {
11342                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11343                _next_ordinal_to_read += 1;
11344                next_offset += envelope_size;
11345            }
11346
11347            let next_out_of_line = decoder.next_out_of_line();
11348            let handles_before = decoder.remaining_handles();
11349            if let Some((inlined, num_bytes, num_handles)) =
11350                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11351            {
11352                let member_inline_size = <fidl::encoding::HandleType<
11353                    fidl::Event,
11354                    { fidl::ObjectType::EVENT.into_raw() },
11355                    2147483648,
11356                > as fidl::encoding::TypeMarker>::inline_size(
11357                    decoder.context
11358                );
11359                if inlined != (member_inline_size <= 4) {
11360                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11361                }
11362                let inner_offset;
11363                let mut inner_depth = depth.clone();
11364                if inlined {
11365                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11366                    inner_offset = next_offset;
11367                } else {
11368                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11369                    inner_depth.increment()?;
11370                }
11371                let val_ref =
11372                self.event.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
11373                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
11374                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11375                {
11376                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11377                }
11378                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11379                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11380                }
11381            }
11382
11383            next_offset += envelope_size;
11384
11385            // Decode the remaining unknown envelopes.
11386            while next_offset < end_offset {
11387                _next_ordinal_to_read += 1;
11388                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11389                next_offset += envelope_size;
11390            }
11391
11392            Ok(())
11393        }
11394    }
11395
11396    impl PresentArgs {
11397        #[inline(always)]
11398        fn max_ordinal_present(&self) -> u64 {
11399            if let Some(_) = self.unsquashable {
11400                return 4;
11401            }
11402            if let Some(_) = self.release_fences {
11403                return 3;
11404            }
11405            if let Some(_) = self.acquire_fences {
11406                return 2;
11407            }
11408            if let Some(_) = self.requested_presentation_time {
11409                return 1;
11410            }
11411            0
11412        }
11413    }
11414
11415    impl fidl::encoding::ResourceTypeMarker for PresentArgs {
11416        type Borrowed<'a> = &'a mut Self;
11417        fn take_or_borrow<'a>(
11418            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11419        ) -> Self::Borrowed<'a> {
11420            value
11421        }
11422    }
11423
11424    unsafe impl fidl::encoding::TypeMarker for PresentArgs {
11425        type Owned = Self;
11426
11427        #[inline(always)]
11428        fn inline_align(_context: fidl::encoding::Context) -> usize {
11429            8
11430        }
11431
11432        #[inline(always)]
11433        fn inline_size(_context: fidl::encoding::Context) -> usize {
11434            16
11435        }
11436    }
11437
11438    unsafe impl fidl::encoding::Encode<PresentArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
11439        for &mut PresentArgs
11440    {
11441        unsafe fn encode(
11442            self,
11443            encoder: &mut fidl::encoding::Encoder<
11444                '_,
11445                fidl::encoding::DefaultFuchsiaResourceDialect,
11446            >,
11447            offset: usize,
11448            mut depth: fidl::encoding::Depth,
11449        ) -> fidl::Result<()> {
11450            encoder.debug_check_bounds::<PresentArgs>(offset);
11451            // Vector header
11452            let max_ordinal: u64 = self.max_ordinal_present();
11453            encoder.write_num(max_ordinal, offset);
11454            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11455            // Calling encoder.out_of_line_offset(0) is not allowed.
11456            if max_ordinal == 0 {
11457                return Ok(());
11458            }
11459            depth.increment()?;
11460            let envelope_size = 8;
11461            let bytes_len = max_ordinal as usize * envelope_size;
11462            #[allow(unused_variables)]
11463            let offset = encoder.out_of_line_offset(bytes_len);
11464            let mut _prev_end_offset: usize = 0;
11465            if 1 > max_ordinal {
11466                return Ok(());
11467            }
11468
11469            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11470            // are envelope_size bytes.
11471            let cur_offset: usize = (1 - 1) * envelope_size;
11472
11473            // Zero reserved fields.
11474            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11475
11476            // Safety:
11477            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11478            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11479            //   envelope_size bytes, there is always sufficient room.
11480            fidl::encoding::encode_in_envelope_optional::<
11481                i64,
11482                fidl::encoding::DefaultFuchsiaResourceDialect,
11483            >(
11484                self.requested_presentation_time
11485                    .as_ref()
11486                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
11487                encoder,
11488                offset + cur_offset,
11489                depth,
11490            )?;
11491
11492            _prev_end_offset = cur_offset + envelope_size;
11493            if 2 > max_ordinal {
11494                return Ok(());
11495            }
11496
11497            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11498            // are envelope_size bytes.
11499            let cur_offset: usize = (2 - 1) * envelope_size;
11500
11501            // Zero reserved fields.
11502            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11503
11504            // Safety:
11505            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11506            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11507            //   envelope_size bytes, there is always sufficient room.
11508            fidl::encoding::encode_in_envelope_optional::<
11509                fidl::encoding::Vector<
11510                    fidl::encoding::HandleType<
11511                        fidl::Event,
11512                        { fidl::ObjectType::EVENT.into_raw() },
11513                        2147483648,
11514                    >,
11515                    16,
11516                >,
11517                fidl::encoding::DefaultFuchsiaResourceDialect,
11518            >(
11519                self.acquire_fences.as_mut().map(
11520                    <fidl::encoding::Vector<
11521                        fidl::encoding::HandleType<
11522                            fidl::Event,
11523                            { fidl::ObjectType::EVENT.into_raw() },
11524                            2147483648,
11525                        >,
11526                        16,
11527                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11528                ),
11529                encoder,
11530                offset + cur_offset,
11531                depth,
11532            )?;
11533
11534            _prev_end_offset = cur_offset + envelope_size;
11535            if 3 > max_ordinal {
11536                return Ok(());
11537            }
11538
11539            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11540            // are envelope_size bytes.
11541            let cur_offset: usize = (3 - 1) * envelope_size;
11542
11543            // Zero reserved fields.
11544            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11545
11546            // Safety:
11547            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11548            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11549            //   envelope_size bytes, there is always sufficient room.
11550            fidl::encoding::encode_in_envelope_optional::<
11551                fidl::encoding::Vector<
11552                    fidl::encoding::HandleType<
11553                        fidl::Event,
11554                        { fidl::ObjectType::EVENT.into_raw() },
11555                        2147483648,
11556                    >,
11557                    16,
11558                >,
11559                fidl::encoding::DefaultFuchsiaResourceDialect,
11560            >(
11561                self.release_fences.as_mut().map(
11562                    <fidl::encoding::Vector<
11563                        fidl::encoding::HandleType<
11564                            fidl::Event,
11565                            { fidl::ObjectType::EVENT.into_raw() },
11566                            2147483648,
11567                        >,
11568                        16,
11569                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11570                ),
11571                encoder,
11572                offset + cur_offset,
11573                depth,
11574            )?;
11575
11576            _prev_end_offset = cur_offset + envelope_size;
11577            if 4 > max_ordinal {
11578                return Ok(());
11579            }
11580
11581            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11582            // are envelope_size bytes.
11583            let cur_offset: usize = (4 - 1) * envelope_size;
11584
11585            // Zero reserved fields.
11586            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11587
11588            // Safety:
11589            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11590            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11591            //   envelope_size bytes, there is always sufficient room.
11592            fidl::encoding::encode_in_envelope_optional::<
11593                bool,
11594                fidl::encoding::DefaultFuchsiaResourceDialect,
11595            >(
11596                self.unsquashable.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
11597                encoder,
11598                offset + cur_offset,
11599                depth,
11600            )?;
11601
11602            _prev_end_offset = cur_offset + envelope_size;
11603
11604            Ok(())
11605        }
11606    }
11607
11608    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for PresentArgs {
11609        #[inline(always)]
11610        fn new_empty() -> Self {
11611            Self::default()
11612        }
11613
11614        unsafe fn decode(
11615            &mut self,
11616            decoder: &mut fidl::encoding::Decoder<
11617                '_,
11618                fidl::encoding::DefaultFuchsiaResourceDialect,
11619            >,
11620            offset: usize,
11621            mut depth: fidl::encoding::Depth,
11622        ) -> fidl::Result<()> {
11623            decoder.debug_check_bounds::<Self>(offset);
11624            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11625                None => return Err(fidl::Error::NotNullable),
11626                Some(len) => len,
11627            };
11628            // Calling decoder.out_of_line_offset(0) is not allowed.
11629            if len == 0 {
11630                return Ok(());
11631            };
11632            depth.increment()?;
11633            let envelope_size = 8;
11634            let bytes_len = len * envelope_size;
11635            let offset = decoder.out_of_line_offset(bytes_len)?;
11636            // Decode the envelope for each type.
11637            let mut _next_ordinal_to_read = 0;
11638            let mut next_offset = offset;
11639            let end_offset = offset + bytes_len;
11640            _next_ordinal_to_read += 1;
11641            if next_offset >= end_offset {
11642                return Ok(());
11643            }
11644
11645            // Decode unknown envelopes for gaps in ordinals.
11646            while _next_ordinal_to_read < 1 {
11647                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11648                _next_ordinal_to_read += 1;
11649                next_offset += envelope_size;
11650            }
11651
11652            let next_out_of_line = decoder.next_out_of_line();
11653            let handles_before = decoder.remaining_handles();
11654            if let Some((inlined, num_bytes, num_handles)) =
11655                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11656            {
11657                let member_inline_size =
11658                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11659                if inlined != (member_inline_size <= 4) {
11660                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11661                }
11662                let inner_offset;
11663                let mut inner_depth = depth.clone();
11664                if inlined {
11665                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11666                    inner_offset = next_offset;
11667                } else {
11668                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11669                    inner_depth.increment()?;
11670                }
11671                let val_ref = self.requested_presentation_time.get_or_insert_with(|| {
11672                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
11673                });
11674                fidl::decode!(
11675                    i64,
11676                    fidl::encoding::DefaultFuchsiaResourceDialect,
11677                    val_ref,
11678                    decoder,
11679                    inner_offset,
11680                    inner_depth
11681                )?;
11682                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11683                {
11684                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11685                }
11686                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11687                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11688                }
11689            }
11690
11691            next_offset += envelope_size;
11692            _next_ordinal_to_read += 1;
11693            if next_offset >= end_offset {
11694                return Ok(());
11695            }
11696
11697            // Decode unknown envelopes for gaps in ordinals.
11698            while _next_ordinal_to_read < 2 {
11699                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11700                _next_ordinal_to_read += 1;
11701                next_offset += envelope_size;
11702            }
11703
11704            let next_out_of_line = decoder.next_out_of_line();
11705            let handles_before = decoder.remaining_handles();
11706            if let Some((inlined, num_bytes, num_handles)) =
11707                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11708            {
11709                let member_inline_size = <fidl::encoding::Vector<
11710                    fidl::encoding::HandleType<
11711                        fidl::Event,
11712                        { fidl::ObjectType::EVENT.into_raw() },
11713                        2147483648,
11714                    >,
11715                    16,
11716                > as fidl::encoding::TypeMarker>::inline_size(
11717                    decoder.context
11718                );
11719                if inlined != (member_inline_size <= 4) {
11720                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11721                }
11722                let inner_offset;
11723                let mut inner_depth = depth.clone();
11724                if inlined {
11725                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11726                    inner_offset = next_offset;
11727                } else {
11728                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11729                    inner_depth.increment()?;
11730                }
11731                let val_ref = self.acquire_fences.get_or_insert_with(|| {
11732                    fidl::new_empty!(
11733                        fidl::encoding::Vector<
11734                            fidl::encoding::HandleType<
11735                                fidl::Event,
11736                                { fidl::ObjectType::EVENT.into_raw() },
11737                                2147483648,
11738                            >,
11739                            16,
11740                        >,
11741                        fidl::encoding::DefaultFuchsiaResourceDialect
11742                    )
11743                });
11744                fidl::decode!(
11745                    fidl::encoding::Vector<
11746                        fidl::encoding::HandleType<
11747                            fidl::Event,
11748                            { fidl::ObjectType::EVENT.into_raw() },
11749                            2147483648,
11750                        >,
11751                        16,
11752                    >,
11753                    fidl::encoding::DefaultFuchsiaResourceDialect,
11754                    val_ref,
11755                    decoder,
11756                    inner_offset,
11757                    inner_depth
11758                )?;
11759                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11760                {
11761                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11762                }
11763                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11764                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11765                }
11766            }
11767
11768            next_offset += envelope_size;
11769            _next_ordinal_to_read += 1;
11770            if next_offset >= end_offset {
11771                return Ok(());
11772            }
11773
11774            // Decode unknown envelopes for gaps in ordinals.
11775            while _next_ordinal_to_read < 3 {
11776                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11777                _next_ordinal_to_read += 1;
11778                next_offset += envelope_size;
11779            }
11780
11781            let next_out_of_line = decoder.next_out_of_line();
11782            let handles_before = decoder.remaining_handles();
11783            if let Some((inlined, num_bytes, num_handles)) =
11784                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11785            {
11786                let member_inline_size = <fidl::encoding::Vector<
11787                    fidl::encoding::HandleType<
11788                        fidl::Event,
11789                        { fidl::ObjectType::EVENT.into_raw() },
11790                        2147483648,
11791                    >,
11792                    16,
11793                > as fidl::encoding::TypeMarker>::inline_size(
11794                    decoder.context
11795                );
11796                if inlined != (member_inline_size <= 4) {
11797                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11798                }
11799                let inner_offset;
11800                let mut inner_depth = depth.clone();
11801                if inlined {
11802                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11803                    inner_offset = next_offset;
11804                } else {
11805                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11806                    inner_depth.increment()?;
11807                }
11808                let val_ref = self.release_fences.get_or_insert_with(|| {
11809                    fidl::new_empty!(
11810                        fidl::encoding::Vector<
11811                            fidl::encoding::HandleType<
11812                                fidl::Event,
11813                                { fidl::ObjectType::EVENT.into_raw() },
11814                                2147483648,
11815                            >,
11816                            16,
11817                        >,
11818                        fidl::encoding::DefaultFuchsiaResourceDialect
11819                    )
11820                });
11821                fidl::decode!(
11822                    fidl::encoding::Vector<
11823                        fidl::encoding::HandleType<
11824                            fidl::Event,
11825                            { fidl::ObjectType::EVENT.into_raw() },
11826                            2147483648,
11827                        >,
11828                        16,
11829                    >,
11830                    fidl::encoding::DefaultFuchsiaResourceDialect,
11831                    val_ref,
11832                    decoder,
11833                    inner_offset,
11834                    inner_depth
11835                )?;
11836                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11837                {
11838                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11839                }
11840                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11841                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11842                }
11843            }
11844
11845            next_offset += envelope_size;
11846            _next_ordinal_to_read += 1;
11847            if next_offset >= end_offset {
11848                return Ok(());
11849            }
11850
11851            // Decode unknown envelopes for gaps in ordinals.
11852            while _next_ordinal_to_read < 4 {
11853                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11854                _next_ordinal_to_read += 1;
11855                next_offset += envelope_size;
11856            }
11857
11858            let next_out_of_line = decoder.next_out_of_line();
11859            let handles_before = decoder.remaining_handles();
11860            if let Some((inlined, num_bytes, num_handles)) =
11861                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11862            {
11863                let member_inline_size =
11864                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11865                if inlined != (member_inline_size <= 4) {
11866                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11867                }
11868                let inner_offset;
11869                let mut inner_depth = depth.clone();
11870                if inlined {
11871                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11872                    inner_offset = next_offset;
11873                } else {
11874                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11875                    inner_depth.increment()?;
11876                }
11877                let val_ref = self.unsquashable.get_or_insert_with(|| {
11878                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
11879                });
11880                fidl::decode!(
11881                    bool,
11882                    fidl::encoding::DefaultFuchsiaResourceDialect,
11883                    val_ref,
11884                    decoder,
11885                    inner_offset,
11886                    inner_depth
11887                )?;
11888                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11889                {
11890                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11891                }
11892                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11893                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11894                }
11895            }
11896
11897            next_offset += envelope_size;
11898
11899            // Decode the remaining unknown envelopes.
11900            while next_offset < end_offset {
11901                _next_ordinal_to_read += 1;
11902                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11903                next_offset += envelope_size;
11904            }
11905
11906            Ok(())
11907        }
11908    }
11909
11910    impl RegisterBufferCollectionArgs {
11911        #[inline(always)]
11912        fn max_ordinal_present(&self) -> u64 {
11913            if let Some(_) = self.buffer_collection_token2 {
11914                return 5;
11915            }
11916            if let Some(_) = self.usages {
11917                return 4;
11918            }
11919            if let Some(_) = self.usage {
11920                return 3;
11921            }
11922            if let Some(_) = self.buffer_collection_token {
11923                return 2;
11924            }
11925            if let Some(_) = self.export_token {
11926                return 1;
11927            }
11928            0
11929        }
11930    }
11931
11932    impl fidl::encoding::ResourceTypeMarker for RegisterBufferCollectionArgs {
11933        type Borrowed<'a> = &'a mut Self;
11934        fn take_or_borrow<'a>(
11935            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11936        ) -> Self::Borrowed<'a> {
11937            value
11938        }
11939    }
11940
11941    unsafe impl fidl::encoding::TypeMarker for RegisterBufferCollectionArgs {
11942        type Owned = Self;
11943
11944        #[inline(always)]
11945        fn inline_align(_context: fidl::encoding::Context) -> usize {
11946            8
11947        }
11948
11949        #[inline(always)]
11950        fn inline_size(_context: fidl::encoding::Context) -> usize {
11951            16
11952        }
11953    }
11954
11955    unsafe impl
11956        fidl::encoding::Encode<
11957            RegisterBufferCollectionArgs,
11958            fidl::encoding::DefaultFuchsiaResourceDialect,
11959        > for &mut RegisterBufferCollectionArgs
11960    {
11961        unsafe fn encode(
11962            self,
11963            encoder: &mut fidl::encoding::Encoder<
11964                '_,
11965                fidl::encoding::DefaultFuchsiaResourceDialect,
11966            >,
11967            offset: usize,
11968            mut depth: fidl::encoding::Depth,
11969        ) -> fidl::Result<()> {
11970            encoder.debug_check_bounds::<RegisterBufferCollectionArgs>(offset);
11971            // Vector header
11972            let max_ordinal: u64 = self.max_ordinal_present();
11973            encoder.write_num(max_ordinal, offset);
11974            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11975            // Calling encoder.out_of_line_offset(0) is not allowed.
11976            if max_ordinal == 0 {
11977                return Ok(());
11978            }
11979            depth.increment()?;
11980            let envelope_size = 8;
11981            let bytes_len = max_ordinal as usize * envelope_size;
11982            #[allow(unused_variables)]
11983            let offset = encoder.out_of_line_offset(bytes_len);
11984            let mut _prev_end_offset: usize = 0;
11985            if 1 > max_ordinal {
11986                return Ok(());
11987            }
11988
11989            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11990            // are envelope_size bytes.
11991            let cur_offset: usize = (1 - 1) * envelope_size;
11992
11993            // Zero reserved fields.
11994            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11995
11996            // Safety:
11997            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11998            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11999            //   envelope_size bytes, there is always sufficient room.
12000            fidl::encoding::encode_in_envelope_optional::<BufferCollectionExportToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
12001            self.export_token.as_mut().map(<BufferCollectionExportToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
12002            encoder, offset + cur_offset, depth
12003        )?;
12004
12005            _prev_end_offset = cur_offset + envelope_size;
12006            if 2 > max_ordinal {
12007                return Ok(());
12008            }
12009
12010            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12011            // are envelope_size bytes.
12012            let cur_offset: usize = (2 - 1) * envelope_size;
12013
12014            // Zero reserved fields.
12015            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12016
12017            // Safety:
12018            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12019            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12020            //   envelope_size bytes, there is always sufficient room.
12021            fidl::encoding::encode_in_envelope_optional::<
12022                fidl::encoding::Endpoint<
12023                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
12024                >,
12025                fidl::encoding::DefaultFuchsiaResourceDialect,
12026            >(
12027                self.buffer_collection_token.as_mut().map(
12028                    <fidl::encoding::Endpoint<
12029                        fidl::endpoints::ClientEnd<
12030                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
12031                        >,
12032                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12033                ),
12034                encoder,
12035                offset + cur_offset,
12036                depth,
12037            )?;
12038
12039            _prev_end_offset = cur_offset + envelope_size;
12040            if 3 > max_ordinal {
12041                return Ok(());
12042            }
12043
12044            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12045            // are envelope_size bytes.
12046            let cur_offset: usize = (3 - 1) * envelope_size;
12047
12048            // Zero reserved fields.
12049            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12050
12051            // Safety:
12052            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12053            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12054            //   envelope_size bytes, there is always sufficient room.
12055            fidl::encoding::encode_in_envelope_optional::<
12056                RegisterBufferCollectionUsage,
12057                fidl::encoding::DefaultFuchsiaResourceDialect,
12058            >(
12059                self.usage.as_ref().map(
12060                    <RegisterBufferCollectionUsage as fidl::encoding::ValueTypeMarker>::borrow,
12061                ),
12062                encoder,
12063                offset + cur_offset,
12064                depth,
12065            )?;
12066
12067            _prev_end_offset = cur_offset + envelope_size;
12068            if 4 > max_ordinal {
12069                return Ok(());
12070            }
12071
12072            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12073            // are envelope_size bytes.
12074            let cur_offset: usize = (4 - 1) * envelope_size;
12075
12076            // Zero reserved fields.
12077            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12078
12079            // Safety:
12080            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12081            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12082            //   envelope_size bytes, there is always sufficient room.
12083            fidl::encoding::encode_in_envelope_optional::<
12084                RegisterBufferCollectionUsages,
12085                fidl::encoding::DefaultFuchsiaResourceDialect,
12086            >(
12087                self.usages.as_ref().map(
12088                    <RegisterBufferCollectionUsages as fidl::encoding::ValueTypeMarker>::borrow,
12089                ),
12090                encoder,
12091                offset + cur_offset,
12092                depth,
12093            )?;
12094
12095            _prev_end_offset = cur_offset + envelope_size;
12096            if 5 > max_ordinal {
12097                return Ok(());
12098            }
12099
12100            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12101            // are envelope_size bytes.
12102            let cur_offset: usize = (5 - 1) * envelope_size;
12103
12104            // Zero reserved fields.
12105            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12106
12107            // Safety:
12108            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12109            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12110            //   envelope_size bytes, there is always sufficient room.
12111            fidl::encoding::encode_in_envelope_optional::<
12112                fidl::encoding::Endpoint<
12113                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
12114                >,
12115                fidl::encoding::DefaultFuchsiaResourceDialect,
12116            >(
12117                self.buffer_collection_token2.as_mut().map(
12118                    <fidl::encoding::Endpoint<
12119                        fidl::endpoints::ClientEnd<
12120                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
12121                        >,
12122                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12123                ),
12124                encoder,
12125                offset + cur_offset,
12126                depth,
12127            )?;
12128
12129            _prev_end_offset = cur_offset + envelope_size;
12130
12131            Ok(())
12132        }
12133    }
12134
12135    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12136        for RegisterBufferCollectionArgs
12137    {
12138        #[inline(always)]
12139        fn new_empty() -> Self {
12140            Self::default()
12141        }
12142
12143        unsafe fn decode(
12144            &mut self,
12145            decoder: &mut fidl::encoding::Decoder<
12146                '_,
12147                fidl::encoding::DefaultFuchsiaResourceDialect,
12148            >,
12149            offset: usize,
12150            mut depth: fidl::encoding::Depth,
12151        ) -> fidl::Result<()> {
12152            decoder.debug_check_bounds::<Self>(offset);
12153            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12154                None => return Err(fidl::Error::NotNullable),
12155                Some(len) => len,
12156            };
12157            // Calling decoder.out_of_line_offset(0) is not allowed.
12158            if len == 0 {
12159                return Ok(());
12160            };
12161            depth.increment()?;
12162            let envelope_size = 8;
12163            let bytes_len = len * envelope_size;
12164            let offset = decoder.out_of_line_offset(bytes_len)?;
12165            // Decode the envelope for each type.
12166            let mut _next_ordinal_to_read = 0;
12167            let mut next_offset = offset;
12168            let end_offset = offset + bytes_len;
12169            _next_ordinal_to_read += 1;
12170            if next_offset >= end_offset {
12171                return Ok(());
12172            }
12173
12174            // Decode unknown envelopes for gaps in ordinals.
12175            while _next_ordinal_to_read < 1 {
12176                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12177                _next_ordinal_to_read += 1;
12178                next_offset += envelope_size;
12179            }
12180
12181            let next_out_of_line = decoder.next_out_of_line();
12182            let handles_before = decoder.remaining_handles();
12183            if let Some((inlined, num_bytes, num_handles)) =
12184                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12185            {
12186                let member_inline_size =
12187                    <BufferCollectionExportToken as fidl::encoding::TypeMarker>::inline_size(
12188                        decoder.context,
12189                    );
12190                if inlined != (member_inline_size <= 4) {
12191                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12192                }
12193                let inner_offset;
12194                let mut inner_depth = depth.clone();
12195                if inlined {
12196                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12197                    inner_offset = next_offset;
12198                } else {
12199                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12200                    inner_depth.increment()?;
12201                }
12202                let val_ref = self.export_token.get_or_insert_with(|| {
12203                    fidl::new_empty!(
12204                        BufferCollectionExportToken,
12205                        fidl::encoding::DefaultFuchsiaResourceDialect
12206                    )
12207                });
12208                fidl::decode!(
12209                    BufferCollectionExportToken,
12210                    fidl::encoding::DefaultFuchsiaResourceDialect,
12211                    val_ref,
12212                    decoder,
12213                    inner_offset,
12214                    inner_depth
12215                )?;
12216                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12217                {
12218                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12219                }
12220                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12221                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12222                }
12223            }
12224
12225            next_offset += envelope_size;
12226            _next_ordinal_to_read += 1;
12227            if next_offset >= end_offset {
12228                return Ok(());
12229            }
12230
12231            // Decode unknown envelopes for gaps in ordinals.
12232            while _next_ordinal_to_read < 2 {
12233                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12234                _next_ordinal_to_read += 1;
12235                next_offset += envelope_size;
12236            }
12237
12238            let next_out_of_line = decoder.next_out_of_line();
12239            let handles_before = decoder.remaining_handles();
12240            if let Some((inlined, num_bytes, num_handles)) =
12241                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12242            {
12243                let member_inline_size = <fidl::encoding::Endpoint<
12244                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
12245                > as fidl::encoding::TypeMarker>::inline_size(
12246                    decoder.context
12247                );
12248                if inlined != (member_inline_size <= 4) {
12249                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12250                }
12251                let inner_offset;
12252                let mut inner_depth = depth.clone();
12253                if inlined {
12254                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12255                    inner_offset = next_offset;
12256                } else {
12257                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12258                    inner_depth.increment()?;
12259                }
12260                let val_ref = self.buffer_collection_token.get_or_insert_with(|| {
12261                    fidl::new_empty!(
12262                        fidl::encoding::Endpoint<
12263                            fidl::endpoints::ClientEnd<
12264                                fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
12265                            >,
12266                        >,
12267                        fidl::encoding::DefaultFuchsiaResourceDialect
12268                    )
12269                });
12270                fidl::decode!(
12271                    fidl::encoding::Endpoint<
12272                        fidl::endpoints::ClientEnd<
12273                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
12274                        >,
12275                    >,
12276                    fidl::encoding::DefaultFuchsiaResourceDialect,
12277                    val_ref,
12278                    decoder,
12279                    inner_offset,
12280                    inner_depth
12281                )?;
12282                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12283                {
12284                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12285                }
12286                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12287                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12288                }
12289            }
12290
12291            next_offset += envelope_size;
12292            _next_ordinal_to_read += 1;
12293            if next_offset >= end_offset {
12294                return Ok(());
12295            }
12296
12297            // Decode unknown envelopes for gaps in ordinals.
12298            while _next_ordinal_to_read < 3 {
12299                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12300                _next_ordinal_to_read += 1;
12301                next_offset += envelope_size;
12302            }
12303
12304            let next_out_of_line = decoder.next_out_of_line();
12305            let handles_before = decoder.remaining_handles();
12306            if let Some((inlined, num_bytes, num_handles)) =
12307                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12308            {
12309                let member_inline_size =
12310                    <RegisterBufferCollectionUsage as fidl::encoding::TypeMarker>::inline_size(
12311                        decoder.context,
12312                    );
12313                if inlined != (member_inline_size <= 4) {
12314                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12315                }
12316                let inner_offset;
12317                let mut inner_depth = depth.clone();
12318                if inlined {
12319                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12320                    inner_offset = next_offset;
12321                } else {
12322                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12323                    inner_depth.increment()?;
12324                }
12325                let val_ref = self.usage.get_or_insert_with(|| {
12326                    fidl::new_empty!(
12327                        RegisterBufferCollectionUsage,
12328                        fidl::encoding::DefaultFuchsiaResourceDialect
12329                    )
12330                });
12331                fidl::decode!(
12332                    RegisterBufferCollectionUsage,
12333                    fidl::encoding::DefaultFuchsiaResourceDialect,
12334                    val_ref,
12335                    decoder,
12336                    inner_offset,
12337                    inner_depth
12338                )?;
12339                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12340                {
12341                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12342                }
12343                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12344                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12345                }
12346            }
12347
12348            next_offset += envelope_size;
12349            _next_ordinal_to_read += 1;
12350            if next_offset >= end_offset {
12351                return Ok(());
12352            }
12353
12354            // Decode unknown envelopes for gaps in ordinals.
12355            while _next_ordinal_to_read < 4 {
12356                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12357                _next_ordinal_to_read += 1;
12358                next_offset += envelope_size;
12359            }
12360
12361            let next_out_of_line = decoder.next_out_of_line();
12362            let handles_before = decoder.remaining_handles();
12363            if let Some((inlined, num_bytes, num_handles)) =
12364                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12365            {
12366                let member_inline_size =
12367                    <RegisterBufferCollectionUsages as fidl::encoding::TypeMarker>::inline_size(
12368                        decoder.context,
12369                    );
12370                if inlined != (member_inline_size <= 4) {
12371                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12372                }
12373                let inner_offset;
12374                let mut inner_depth = depth.clone();
12375                if inlined {
12376                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12377                    inner_offset = next_offset;
12378                } else {
12379                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12380                    inner_depth.increment()?;
12381                }
12382                let val_ref = self.usages.get_or_insert_with(|| {
12383                    fidl::new_empty!(
12384                        RegisterBufferCollectionUsages,
12385                        fidl::encoding::DefaultFuchsiaResourceDialect
12386                    )
12387                });
12388                fidl::decode!(
12389                    RegisterBufferCollectionUsages,
12390                    fidl::encoding::DefaultFuchsiaResourceDialect,
12391                    val_ref,
12392                    decoder,
12393                    inner_offset,
12394                    inner_depth
12395                )?;
12396                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12397                {
12398                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12399                }
12400                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12401                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12402                }
12403            }
12404
12405            next_offset += envelope_size;
12406            _next_ordinal_to_read += 1;
12407            if next_offset >= end_offset {
12408                return Ok(());
12409            }
12410
12411            // Decode unknown envelopes for gaps in ordinals.
12412            while _next_ordinal_to_read < 5 {
12413                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12414                _next_ordinal_to_read += 1;
12415                next_offset += envelope_size;
12416            }
12417
12418            let next_out_of_line = decoder.next_out_of_line();
12419            let handles_before = decoder.remaining_handles();
12420            if let Some((inlined, num_bytes, num_handles)) =
12421                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12422            {
12423                let member_inline_size = <fidl::encoding::Endpoint<
12424                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
12425                > as fidl::encoding::TypeMarker>::inline_size(
12426                    decoder.context
12427                );
12428                if inlined != (member_inline_size <= 4) {
12429                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12430                }
12431                let inner_offset;
12432                let mut inner_depth = depth.clone();
12433                if inlined {
12434                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12435                    inner_offset = next_offset;
12436                } else {
12437                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12438                    inner_depth.increment()?;
12439                }
12440                let val_ref = self.buffer_collection_token2.get_or_insert_with(|| {
12441                    fidl::new_empty!(
12442                        fidl::encoding::Endpoint<
12443                            fidl::endpoints::ClientEnd<
12444                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
12445                            >,
12446                        >,
12447                        fidl::encoding::DefaultFuchsiaResourceDialect
12448                    )
12449                });
12450                fidl::decode!(
12451                    fidl::encoding::Endpoint<
12452                        fidl::endpoints::ClientEnd<
12453                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
12454                        >,
12455                    >,
12456                    fidl::encoding::DefaultFuchsiaResourceDialect,
12457                    val_ref,
12458                    decoder,
12459                    inner_offset,
12460                    inner_depth
12461                )?;
12462                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12463                {
12464                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12465                }
12466                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12467                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12468                }
12469            }
12470
12471            next_offset += envelope_size;
12472
12473            // Decode the remaining unknown envelopes.
12474            while next_offset < end_offset {
12475                _next_ordinal_to_read += 1;
12476                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12477                next_offset += envelope_size;
12478            }
12479
12480            Ok(())
12481        }
12482    }
12483
12484    impl ScreenCaptureConfig {
12485        #[inline(always)]
12486        fn max_ordinal_present(&self) -> u64 {
12487            if let Some(_) = self.rotation {
12488                return 4;
12489            }
12490            if let Some(_) = self.buffer_count {
12491                return 3;
12492            }
12493            if let Some(_) = self.size {
12494                return 2;
12495            }
12496            if let Some(_) = self.import_token {
12497                return 1;
12498            }
12499            0
12500        }
12501    }
12502
12503    impl fidl::encoding::ResourceTypeMarker for ScreenCaptureConfig {
12504        type Borrowed<'a> = &'a mut Self;
12505        fn take_or_borrow<'a>(
12506            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12507        ) -> Self::Borrowed<'a> {
12508            value
12509        }
12510    }
12511
12512    unsafe impl fidl::encoding::TypeMarker for ScreenCaptureConfig {
12513        type Owned = Self;
12514
12515        #[inline(always)]
12516        fn inline_align(_context: fidl::encoding::Context) -> usize {
12517            8
12518        }
12519
12520        #[inline(always)]
12521        fn inline_size(_context: fidl::encoding::Context) -> usize {
12522            16
12523        }
12524    }
12525
12526    unsafe impl
12527        fidl::encoding::Encode<ScreenCaptureConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
12528        for &mut ScreenCaptureConfig
12529    {
12530        unsafe fn encode(
12531            self,
12532            encoder: &mut fidl::encoding::Encoder<
12533                '_,
12534                fidl::encoding::DefaultFuchsiaResourceDialect,
12535            >,
12536            offset: usize,
12537            mut depth: fidl::encoding::Depth,
12538        ) -> fidl::Result<()> {
12539            encoder.debug_check_bounds::<ScreenCaptureConfig>(offset);
12540            // Vector header
12541            let max_ordinal: u64 = self.max_ordinal_present();
12542            encoder.write_num(max_ordinal, offset);
12543            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12544            // Calling encoder.out_of_line_offset(0) is not allowed.
12545            if max_ordinal == 0 {
12546                return Ok(());
12547            }
12548            depth.increment()?;
12549            let envelope_size = 8;
12550            let bytes_len = max_ordinal as usize * envelope_size;
12551            #[allow(unused_variables)]
12552            let offset = encoder.out_of_line_offset(bytes_len);
12553            let mut _prev_end_offset: usize = 0;
12554            if 1 > max_ordinal {
12555                return Ok(());
12556            }
12557
12558            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12559            // are envelope_size bytes.
12560            let cur_offset: usize = (1 - 1) * envelope_size;
12561
12562            // Zero reserved fields.
12563            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12564
12565            // Safety:
12566            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12567            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12568            //   envelope_size bytes, there is always sufficient room.
12569            fidl::encoding::encode_in_envelope_optional::<BufferCollectionImportToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
12570            self.import_token.as_mut().map(<BufferCollectionImportToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
12571            encoder, offset + cur_offset, depth
12572        )?;
12573
12574            _prev_end_offset = cur_offset + envelope_size;
12575            if 2 > max_ordinal {
12576                return Ok(());
12577            }
12578
12579            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12580            // are envelope_size bytes.
12581            let cur_offset: usize = (2 - 1) * envelope_size;
12582
12583            // Zero reserved fields.
12584            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12585
12586            // Safety:
12587            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12588            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12589            //   envelope_size bytes, there is always sufficient room.
12590            fidl::encoding::encode_in_envelope_optional::<
12591                fidl_fuchsia_math::SizeU,
12592                fidl::encoding::DefaultFuchsiaResourceDialect,
12593            >(
12594                self.size
12595                    .as_ref()
12596                    .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
12597                encoder,
12598                offset + cur_offset,
12599                depth,
12600            )?;
12601
12602            _prev_end_offset = cur_offset + envelope_size;
12603            if 3 > max_ordinal {
12604                return Ok(());
12605            }
12606
12607            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12608            // are envelope_size bytes.
12609            let cur_offset: usize = (3 - 1) * envelope_size;
12610
12611            // Zero reserved fields.
12612            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12613
12614            // Safety:
12615            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12616            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12617            //   envelope_size bytes, there is always sufficient room.
12618            fidl::encoding::encode_in_envelope_optional::<
12619                u32,
12620                fidl::encoding::DefaultFuchsiaResourceDialect,
12621            >(
12622                self.buffer_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
12623                encoder,
12624                offset + cur_offset,
12625                depth,
12626            )?;
12627
12628            _prev_end_offset = cur_offset + envelope_size;
12629            if 4 > max_ordinal {
12630                return Ok(());
12631            }
12632
12633            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12634            // are envelope_size bytes.
12635            let cur_offset: usize = (4 - 1) * envelope_size;
12636
12637            // Zero reserved fields.
12638            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12639
12640            // Safety:
12641            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12642            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12643            //   envelope_size bytes, there is always sufficient room.
12644            fidl::encoding::encode_in_envelope_optional::<
12645                Rotation,
12646                fidl::encoding::DefaultFuchsiaResourceDialect,
12647            >(
12648                self.rotation.as_ref().map(<Rotation as fidl::encoding::ValueTypeMarker>::borrow),
12649                encoder,
12650                offset + cur_offset,
12651                depth,
12652            )?;
12653
12654            _prev_end_offset = cur_offset + envelope_size;
12655
12656            Ok(())
12657        }
12658    }
12659
12660    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12661        for ScreenCaptureConfig
12662    {
12663        #[inline(always)]
12664        fn new_empty() -> Self {
12665            Self::default()
12666        }
12667
12668        unsafe fn decode(
12669            &mut self,
12670            decoder: &mut fidl::encoding::Decoder<
12671                '_,
12672                fidl::encoding::DefaultFuchsiaResourceDialect,
12673            >,
12674            offset: usize,
12675            mut depth: fidl::encoding::Depth,
12676        ) -> fidl::Result<()> {
12677            decoder.debug_check_bounds::<Self>(offset);
12678            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12679                None => return Err(fidl::Error::NotNullable),
12680                Some(len) => len,
12681            };
12682            // Calling decoder.out_of_line_offset(0) is not allowed.
12683            if len == 0 {
12684                return Ok(());
12685            };
12686            depth.increment()?;
12687            let envelope_size = 8;
12688            let bytes_len = len * envelope_size;
12689            let offset = decoder.out_of_line_offset(bytes_len)?;
12690            // Decode the envelope for each type.
12691            let mut _next_ordinal_to_read = 0;
12692            let mut next_offset = offset;
12693            let end_offset = offset + bytes_len;
12694            _next_ordinal_to_read += 1;
12695            if next_offset >= end_offset {
12696                return Ok(());
12697            }
12698
12699            // Decode unknown envelopes for gaps in ordinals.
12700            while _next_ordinal_to_read < 1 {
12701                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12702                _next_ordinal_to_read += 1;
12703                next_offset += envelope_size;
12704            }
12705
12706            let next_out_of_line = decoder.next_out_of_line();
12707            let handles_before = decoder.remaining_handles();
12708            if let Some((inlined, num_bytes, num_handles)) =
12709                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12710            {
12711                let member_inline_size =
12712                    <BufferCollectionImportToken as fidl::encoding::TypeMarker>::inline_size(
12713                        decoder.context,
12714                    );
12715                if inlined != (member_inline_size <= 4) {
12716                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12717                }
12718                let inner_offset;
12719                let mut inner_depth = depth.clone();
12720                if inlined {
12721                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12722                    inner_offset = next_offset;
12723                } else {
12724                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12725                    inner_depth.increment()?;
12726                }
12727                let val_ref = self.import_token.get_or_insert_with(|| {
12728                    fidl::new_empty!(
12729                        BufferCollectionImportToken,
12730                        fidl::encoding::DefaultFuchsiaResourceDialect
12731                    )
12732                });
12733                fidl::decode!(
12734                    BufferCollectionImportToken,
12735                    fidl::encoding::DefaultFuchsiaResourceDialect,
12736                    val_ref,
12737                    decoder,
12738                    inner_offset,
12739                    inner_depth
12740                )?;
12741                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12742                {
12743                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12744                }
12745                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12746                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12747                }
12748            }
12749
12750            next_offset += envelope_size;
12751            _next_ordinal_to_read += 1;
12752            if next_offset >= end_offset {
12753                return Ok(());
12754            }
12755
12756            // Decode unknown envelopes for gaps in ordinals.
12757            while _next_ordinal_to_read < 2 {
12758                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12759                _next_ordinal_to_read += 1;
12760                next_offset += envelope_size;
12761            }
12762
12763            let next_out_of_line = decoder.next_out_of_line();
12764            let handles_before = decoder.remaining_handles();
12765            if let Some((inlined, num_bytes, num_handles)) =
12766                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12767            {
12768                let member_inline_size =
12769                    <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
12770                        decoder.context,
12771                    );
12772                if inlined != (member_inline_size <= 4) {
12773                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12774                }
12775                let inner_offset;
12776                let mut inner_depth = depth.clone();
12777                if inlined {
12778                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12779                    inner_offset = next_offset;
12780                } else {
12781                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12782                    inner_depth.increment()?;
12783                }
12784                let val_ref = self.size.get_or_insert_with(|| {
12785                    fidl::new_empty!(
12786                        fidl_fuchsia_math::SizeU,
12787                        fidl::encoding::DefaultFuchsiaResourceDialect
12788                    )
12789                });
12790                fidl::decode!(
12791                    fidl_fuchsia_math::SizeU,
12792                    fidl::encoding::DefaultFuchsiaResourceDialect,
12793                    val_ref,
12794                    decoder,
12795                    inner_offset,
12796                    inner_depth
12797                )?;
12798                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12799                {
12800                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12801                }
12802                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12803                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12804                }
12805            }
12806
12807            next_offset += envelope_size;
12808            _next_ordinal_to_read += 1;
12809            if next_offset >= end_offset {
12810                return Ok(());
12811            }
12812
12813            // Decode unknown envelopes for gaps in ordinals.
12814            while _next_ordinal_to_read < 3 {
12815                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12816                _next_ordinal_to_read += 1;
12817                next_offset += envelope_size;
12818            }
12819
12820            let next_out_of_line = decoder.next_out_of_line();
12821            let handles_before = decoder.remaining_handles();
12822            if let Some((inlined, num_bytes, num_handles)) =
12823                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12824            {
12825                let member_inline_size =
12826                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12827                if inlined != (member_inline_size <= 4) {
12828                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12829                }
12830                let inner_offset;
12831                let mut inner_depth = depth.clone();
12832                if inlined {
12833                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12834                    inner_offset = next_offset;
12835                } else {
12836                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12837                    inner_depth.increment()?;
12838                }
12839                let val_ref = self.buffer_count.get_or_insert_with(|| {
12840                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
12841                });
12842                fidl::decode!(
12843                    u32,
12844                    fidl::encoding::DefaultFuchsiaResourceDialect,
12845                    val_ref,
12846                    decoder,
12847                    inner_offset,
12848                    inner_depth
12849                )?;
12850                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12851                {
12852                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12853                }
12854                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12855                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12856                }
12857            }
12858
12859            next_offset += envelope_size;
12860            _next_ordinal_to_read += 1;
12861            if next_offset >= end_offset {
12862                return Ok(());
12863            }
12864
12865            // Decode unknown envelopes for gaps in ordinals.
12866            while _next_ordinal_to_read < 4 {
12867                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12868                _next_ordinal_to_read += 1;
12869                next_offset += envelope_size;
12870            }
12871
12872            let next_out_of_line = decoder.next_out_of_line();
12873            let handles_before = decoder.remaining_handles();
12874            if let Some((inlined, num_bytes, num_handles)) =
12875                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12876            {
12877                let member_inline_size =
12878                    <Rotation as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12879                if inlined != (member_inline_size <= 4) {
12880                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12881                }
12882                let inner_offset;
12883                let mut inner_depth = depth.clone();
12884                if inlined {
12885                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12886                    inner_offset = next_offset;
12887                } else {
12888                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12889                    inner_depth.increment()?;
12890                }
12891                let val_ref = self.rotation.get_or_insert_with(|| {
12892                    fidl::new_empty!(Rotation, fidl::encoding::DefaultFuchsiaResourceDialect)
12893                });
12894                fidl::decode!(
12895                    Rotation,
12896                    fidl::encoding::DefaultFuchsiaResourceDialect,
12897                    val_ref,
12898                    decoder,
12899                    inner_offset,
12900                    inner_depth
12901                )?;
12902                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12903                {
12904                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12905                }
12906                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12907                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12908                }
12909            }
12910
12911            next_offset += envelope_size;
12912
12913            // Decode the remaining unknown envelopes.
12914            while next_offset < end_offset {
12915                _next_ordinal_to_read += 1;
12916                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12917                next_offset += envelope_size;
12918            }
12919
12920            Ok(())
12921        }
12922    }
12923
12924    impl ScreenshotTakeFileRequest {
12925        #[inline(always)]
12926        fn max_ordinal_present(&self) -> u64 {
12927            if let Some(_) = self.format {
12928                return 1;
12929            }
12930            0
12931        }
12932    }
12933
12934    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeFileRequest {
12935        type Borrowed<'a> = &'a mut Self;
12936        fn take_or_borrow<'a>(
12937            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12938        ) -> Self::Borrowed<'a> {
12939            value
12940        }
12941    }
12942
12943    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeFileRequest {
12944        type Owned = Self;
12945
12946        #[inline(always)]
12947        fn inline_align(_context: fidl::encoding::Context) -> usize {
12948            8
12949        }
12950
12951        #[inline(always)]
12952        fn inline_size(_context: fidl::encoding::Context) -> usize {
12953            16
12954        }
12955    }
12956
12957    unsafe impl
12958        fidl::encoding::Encode<
12959            ScreenshotTakeFileRequest,
12960            fidl::encoding::DefaultFuchsiaResourceDialect,
12961        > for &mut ScreenshotTakeFileRequest
12962    {
12963        unsafe fn encode(
12964            self,
12965            encoder: &mut fidl::encoding::Encoder<
12966                '_,
12967                fidl::encoding::DefaultFuchsiaResourceDialect,
12968            >,
12969            offset: usize,
12970            mut depth: fidl::encoding::Depth,
12971        ) -> fidl::Result<()> {
12972            encoder.debug_check_bounds::<ScreenshotTakeFileRequest>(offset);
12973            // Vector header
12974            let max_ordinal: u64 = self.max_ordinal_present();
12975            encoder.write_num(max_ordinal, offset);
12976            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12977            // Calling encoder.out_of_line_offset(0) is not allowed.
12978            if max_ordinal == 0 {
12979                return Ok(());
12980            }
12981            depth.increment()?;
12982            let envelope_size = 8;
12983            let bytes_len = max_ordinal as usize * envelope_size;
12984            #[allow(unused_variables)]
12985            let offset = encoder.out_of_line_offset(bytes_len);
12986            let mut _prev_end_offset: usize = 0;
12987            if 1 > max_ordinal {
12988                return Ok(());
12989            }
12990
12991            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12992            // are envelope_size bytes.
12993            let cur_offset: usize = (1 - 1) * envelope_size;
12994
12995            // Zero reserved fields.
12996            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12997
12998            // Safety:
12999            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13000            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13001            //   envelope_size bytes, there is always sufficient room.
13002            fidl::encoding::encode_in_envelope_optional::<
13003                ScreenshotFormat,
13004                fidl::encoding::DefaultFuchsiaResourceDialect,
13005            >(
13006                self.format
13007                    .as_ref()
13008                    .map(<ScreenshotFormat as fidl::encoding::ValueTypeMarker>::borrow),
13009                encoder,
13010                offset + cur_offset,
13011                depth,
13012            )?;
13013
13014            _prev_end_offset = cur_offset + envelope_size;
13015
13016            Ok(())
13017        }
13018    }
13019
13020    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13021        for ScreenshotTakeFileRequest
13022    {
13023        #[inline(always)]
13024        fn new_empty() -> Self {
13025            Self::default()
13026        }
13027
13028        unsafe fn decode(
13029            &mut self,
13030            decoder: &mut fidl::encoding::Decoder<
13031                '_,
13032                fidl::encoding::DefaultFuchsiaResourceDialect,
13033            >,
13034            offset: usize,
13035            mut depth: fidl::encoding::Depth,
13036        ) -> fidl::Result<()> {
13037            decoder.debug_check_bounds::<Self>(offset);
13038            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13039                None => return Err(fidl::Error::NotNullable),
13040                Some(len) => len,
13041            };
13042            // Calling decoder.out_of_line_offset(0) is not allowed.
13043            if len == 0 {
13044                return Ok(());
13045            };
13046            depth.increment()?;
13047            let envelope_size = 8;
13048            let bytes_len = len * envelope_size;
13049            let offset = decoder.out_of_line_offset(bytes_len)?;
13050            // Decode the envelope for each type.
13051            let mut _next_ordinal_to_read = 0;
13052            let mut next_offset = offset;
13053            let end_offset = offset + bytes_len;
13054            _next_ordinal_to_read += 1;
13055            if next_offset >= end_offset {
13056                return Ok(());
13057            }
13058
13059            // Decode unknown envelopes for gaps in ordinals.
13060            while _next_ordinal_to_read < 1 {
13061                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13062                _next_ordinal_to_read += 1;
13063                next_offset += envelope_size;
13064            }
13065
13066            let next_out_of_line = decoder.next_out_of_line();
13067            let handles_before = decoder.remaining_handles();
13068            if let Some((inlined, num_bytes, num_handles)) =
13069                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13070            {
13071                let member_inline_size =
13072                    <ScreenshotFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13073                if inlined != (member_inline_size <= 4) {
13074                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13075                }
13076                let inner_offset;
13077                let mut inner_depth = depth.clone();
13078                if inlined {
13079                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13080                    inner_offset = next_offset;
13081                } else {
13082                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13083                    inner_depth.increment()?;
13084                }
13085                let val_ref = self.format.get_or_insert_with(|| {
13086                    fidl::new_empty!(
13087                        ScreenshotFormat,
13088                        fidl::encoding::DefaultFuchsiaResourceDialect
13089                    )
13090                });
13091                fidl::decode!(
13092                    ScreenshotFormat,
13093                    fidl::encoding::DefaultFuchsiaResourceDialect,
13094                    val_ref,
13095                    decoder,
13096                    inner_offset,
13097                    inner_depth
13098                )?;
13099                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13100                {
13101                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13102                }
13103                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13104                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13105                }
13106            }
13107
13108            next_offset += envelope_size;
13109
13110            // Decode the remaining unknown envelopes.
13111            while next_offset < end_offset {
13112                _next_ordinal_to_read += 1;
13113                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13114                next_offset += envelope_size;
13115            }
13116
13117            Ok(())
13118        }
13119    }
13120
13121    impl ScreenshotTakeFileResponse {
13122        #[inline(always)]
13123        fn max_ordinal_present(&self) -> u64 {
13124            if let Some(_) = self.size {
13125                return 2;
13126            }
13127            if let Some(_) = self.file {
13128                return 1;
13129            }
13130            0
13131        }
13132    }
13133
13134    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeFileResponse {
13135        type Borrowed<'a> = &'a mut Self;
13136        fn take_or_borrow<'a>(
13137            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13138        ) -> Self::Borrowed<'a> {
13139            value
13140        }
13141    }
13142
13143    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeFileResponse {
13144        type Owned = Self;
13145
13146        #[inline(always)]
13147        fn inline_align(_context: fidl::encoding::Context) -> usize {
13148            8
13149        }
13150
13151        #[inline(always)]
13152        fn inline_size(_context: fidl::encoding::Context) -> usize {
13153            16
13154        }
13155    }
13156
13157    unsafe impl
13158        fidl::encoding::Encode<
13159            ScreenshotTakeFileResponse,
13160            fidl::encoding::DefaultFuchsiaResourceDialect,
13161        > for &mut ScreenshotTakeFileResponse
13162    {
13163        unsafe fn encode(
13164            self,
13165            encoder: &mut fidl::encoding::Encoder<
13166                '_,
13167                fidl::encoding::DefaultFuchsiaResourceDialect,
13168            >,
13169            offset: usize,
13170            mut depth: fidl::encoding::Depth,
13171        ) -> fidl::Result<()> {
13172            encoder.debug_check_bounds::<ScreenshotTakeFileResponse>(offset);
13173            // Vector header
13174            let max_ordinal: u64 = self.max_ordinal_present();
13175            encoder.write_num(max_ordinal, offset);
13176            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13177            // Calling encoder.out_of_line_offset(0) is not allowed.
13178            if max_ordinal == 0 {
13179                return Ok(());
13180            }
13181            depth.increment()?;
13182            let envelope_size = 8;
13183            let bytes_len = max_ordinal as usize * envelope_size;
13184            #[allow(unused_variables)]
13185            let offset = encoder.out_of_line_offset(bytes_len);
13186            let mut _prev_end_offset: usize = 0;
13187            if 1 > max_ordinal {
13188                return Ok(());
13189            }
13190
13191            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13192            // are envelope_size bytes.
13193            let cur_offset: usize = (1 - 1) * envelope_size;
13194
13195            // Zero reserved fields.
13196            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13197
13198            // Safety:
13199            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13200            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13201            //   envelope_size bytes, there is always sufficient room.
13202            fidl::encoding::encode_in_envelope_optional::<
13203                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
13204                fidl::encoding::DefaultFuchsiaResourceDialect,
13205            >(
13206                self.file.as_mut().map(
13207                    <fidl::encoding::Endpoint<
13208                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13209                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13210                ),
13211                encoder,
13212                offset + cur_offset,
13213                depth,
13214            )?;
13215
13216            _prev_end_offset = cur_offset + envelope_size;
13217            if 2 > max_ordinal {
13218                return Ok(());
13219            }
13220
13221            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13222            // are envelope_size bytes.
13223            let cur_offset: usize = (2 - 1) * envelope_size;
13224
13225            // Zero reserved fields.
13226            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13227
13228            // Safety:
13229            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13230            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13231            //   envelope_size bytes, there is always sufficient room.
13232            fidl::encoding::encode_in_envelope_optional::<
13233                fidl_fuchsia_math::SizeU,
13234                fidl::encoding::DefaultFuchsiaResourceDialect,
13235            >(
13236                self.size
13237                    .as_ref()
13238                    .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
13239                encoder,
13240                offset + cur_offset,
13241                depth,
13242            )?;
13243
13244            _prev_end_offset = cur_offset + envelope_size;
13245
13246            Ok(())
13247        }
13248    }
13249
13250    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13251        for ScreenshotTakeFileResponse
13252    {
13253        #[inline(always)]
13254        fn new_empty() -> Self {
13255            Self::default()
13256        }
13257
13258        unsafe fn decode(
13259            &mut self,
13260            decoder: &mut fidl::encoding::Decoder<
13261                '_,
13262                fidl::encoding::DefaultFuchsiaResourceDialect,
13263            >,
13264            offset: usize,
13265            mut depth: fidl::encoding::Depth,
13266        ) -> fidl::Result<()> {
13267            decoder.debug_check_bounds::<Self>(offset);
13268            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13269                None => return Err(fidl::Error::NotNullable),
13270                Some(len) => len,
13271            };
13272            // Calling decoder.out_of_line_offset(0) is not allowed.
13273            if len == 0 {
13274                return Ok(());
13275            };
13276            depth.increment()?;
13277            let envelope_size = 8;
13278            let bytes_len = len * envelope_size;
13279            let offset = decoder.out_of_line_offset(bytes_len)?;
13280            // Decode the envelope for each type.
13281            let mut _next_ordinal_to_read = 0;
13282            let mut next_offset = offset;
13283            let end_offset = offset + bytes_len;
13284            _next_ordinal_to_read += 1;
13285            if next_offset >= end_offset {
13286                return Ok(());
13287            }
13288
13289            // Decode unknown envelopes for gaps in ordinals.
13290            while _next_ordinal_to_read < 1 {
13291                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13292                _next_ordinal_to_read += 1;
13293                next_offset += envelope_size;
13294            }
13295
13296            let next_out_of_line = decoder.next_out_of_line();
13297            let handles_before = decoder.remaining_handles();
13298            if let Some((inlined, num_bytes, num_handles)) =
13299                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13300            {
13301                let member_inline_size = <fidl::encoding::Endpoint<
13302                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13303                > as fidl::encoding::TypeMarker>::inline_size(
13304                    decoder.context
13305                );
13306                if inlined != (member_inline_size <= 4) {
13307                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13308                }
13309                let inner_offset;
13310                let mut inner_depth = depth.clone();
13311                if inlined {
13312                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13313                    inner_offset = next_offset;
13314                } else {
13315                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13316                    inner_depth.increment()?;
13317                }
13318                let val_ref = self.file.get_or_insert_with(|| {
13319                    fidl::new_empty!(
13320                        fidl::encoding::Endpoint<
13321                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13322                        >,
13323                        fidl::encoding::DefaultFuchsiaResourceDialect
13324                    )
13325                });
13326                fidl::decode!(
13327                    fidl::encoding::Endpoint<
13328                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
13329                    >,
13330                    fidl::encoding::DefaultFuchsiaResourceDialect,
13331                    val_ref,
13332                    decoder,
13333                    inner_offset,
13334                    inner_depth
13335                )?;
13336                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13337                {
13338                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13339                }
13340                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13341                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13342                }
13343            }
13344
13345            next_offset += envelope_size;
13346            _next_ordinal_to_read += 1;
13347            if next_offset >= end_offset {
13348                return Ok(());
13349            }
13350
13351            // Decode unknown envelopes for gaps in ordinals.
13352            while _next_ordinal_to_read < 2 {
13353                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13354                _next_ordinal_to_read += 1;
13355                next_offset += envelope_size;
13356            }
13357
13358            let next_out_of_line = decoder.next_out_of_line();
13359            let handles_before = decoder.remaining_handles();
13360            if let Some((inlined, num_bytes, num_handles)) =
13361                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13362            {
13363                let member_inline_size =
13364                    <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
13365                        decoder.context,
13366                    );
13367                if inlined != (member_inline_size <= 4) {
13368                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13369                }
13370                let inner_offset;
13371                let mut inner_depth = depth.clone();
13372                if inlined {
13373                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13374                    inner_offset = next_offset;
13375                } else {
13376                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13377                    inner_depth.increment()?;
13378                }
13379                let val_ref = self.size.get_or_insert_with(|| {
13380                    fidl::new_empty!(
13381                        fidl_fuchsia_math::SizeU,
13382                        fidl::encoding::DefaultFuchsiaResourceDialect
13383                    )
13384                });
13385                fidl::decode!(
13386                    fidl_fuchsia_math::SizeU,
13387                    fidl::encoding::DefaultFuchsiaResourceDialect,
13388                    val_ref,
13389                    decoder,
13390                    inner_offset,
13391                    inner_depth
13392                )?;
13393                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13394                {
13395                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13396                }
13397                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13398                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13399                }
13400            }
13401
13402            next_offset += envelope_size;
13403
13404            // Decode the remaining unknown envelopes.
13405            while next_offset < end_offset {
13406                _next_ordinal_to_read += 1;
13407                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13408                next_offset += envelope_size;
13409            }
13410
13411            Ok(())
13412        }
13413    }
13414
13415    impl ScreenshotTakeRequest {
13416        #[inline(always)]
13417        fn max_ordinal_present(&self) -> u64 {
13418            if let Some(_) = self.format {
13419                return 1;
13420            }
13421            0
13422        }
13423    }
13424
13425    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeRequest {
13426        type Borrowed<'a> = &'a mut Self;
13427        fn take_or_borrow<'a>(
13428            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13429        ) -> Self::Borrowed<'a> {
13430            value
13431        }
13432    }
13433
13434    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeRequest {
13435        type Owned = Self;
13436
13437        #[inline(always)]
13438        fn inline_align(_context: fidl::encoding::Context) -> usize {
13439            8
13440        }
13441
13442        #[inline(always)]
13443        fn inline_size(_context: fidl::encoding::Context) -> usize {
13444            16
13445        }
13446    }
13447
13448    unsafe impl
13449        fidl::encoding::Encode<ScreenshotTakeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13450        for &mut ScreenshotTakeRequest
13451    {
13452        unsafe fn encode(
13453            self,
13454            encoder: &mut fidl::encoding::Encoder<
13455                '_,
13456                fidl::encoding::DefaultFuchsiaResourceDialect,
13457            >,
13458            offset: usize,
13459            mut depth: fidl::encoding::Depth,
13460        ) -> fidl::Result<()> {
13461            encoder.debug_check_bounds::<ScreenshotTakeRequest>(offset);
13462            // Vector header
13463            let max_ordinal: u64 = self.max_ordinal_present();
13464            encoder.write_num(max_ordinal, offset);
13465            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13466            // Calling encoder.out_of_line_offset(0) is not allowed.
13467            if max_ordinal == 0 {
13468                return Ok(());
13469            }
13470            depth.increment()?;
13471            let envelope_size = 8;
13472            let bytes_len = max_ordinal as usize * envelope_size;
13473            #[allow(unused_variables)]
13474            let offset = encoder.out_of_line_offset(bytes_len);
13475            let mut _prev_end_offset: usize = 0;
13476            if 1 > max_ordinal {
13477                return Ok(());
13478            }
13479
13480            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13481            // are envelope_size bytes.
13482            let cur_offset: usize = (1 - 1) * envelope_size;
13483
13484            // Zero reserved fields.
13485            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13486
13487            // Safety:
13488            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13489            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13490            //   envelope_size bytes, there is always sufficient room.
13491            fidl::encoding::encode_in_envelope_optional::<
13492                ScreenshotFormat,
13493                fidl::encoding::DefaultFuchsiaResourceDialect,
13494            >(
13495                self.format
13496                    .as_ref()
13497                    .map(<ScreenshotFormat as fidl::encoding::ValueTypeMarker>::borrow),
13498                encoder,
13499                offset + cur_offset,
13500                depth,
13501            )?;
13502
13503            _prev_end_offset = cur_offset + envelope_size;
13504
13505            Ok(())
13506        }
13507    }
13508
13509    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13510        for ScreenshotTakeRequest
13511    {
13512        #[inline(always)]
13513        fn new_empty() -> Self {
13514            Self::default()
13515        }
13516
13517        unsafe fn decode(
13518            &mut self,
13519            decoder: &mut fidl::encoding::Decoder<
13520                '_,
13521                fidl::encoding::DefaultFuchsiaResourceDialect,
13522            >,
13523            offset: usize,
13524            mut depth: fidl::encoding::Depth,
13525        ) -> fidl::Result<()> {
13526            decoder.debug_check_bounds::<Self>(offset);
13527            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13528                None => return Err(fidl::Error::NotNullable),
13529                Some(len) => len,
13530            };
13531            // Calling decoder.out_of_line_offset(0) is not allowed.
13532            if len == 0 {
13533                return Ok(());
13534            };
13535            depth.increment()?;
13536            let envelope_size = 8;
13537            let bytes_len = len * envelope_size;
13538            let offset = decoder.out_of_line_offset(bytes_len)?;
13539            // Decode the envelope for each type.
13540            let mut _next_ordinal_to_read = 0;
13541            let mut next_offset = offset;
13542            let end_offset = offset + bytes_len;
13543            _next_ordinal_to_read += 1;
13544            if next_offset >= end_offset {
13545                return Ok(());
13546            }
13547
13548            // Decode unknown envelopes for gaps in ordinals.
13549            while _next_ordinal_to_read < 1 {
13550                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13551                _next_ordinal_to_read += 1;
13552                next_offset += envelope_size;
13553            }
13554
13555            let next_out_of_line = decoder.next_out_of_line();
13556            let handles_before = decoder.remaining_handles();
13557            if let Some((inlined, num_bytes, num_handles)) =
13558                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13559            {
13560                let member_inline_size =
13561                    <ScreenshotFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
13562                if inlined != (member_inline_size <= 4) {
13563                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13564                }
13565                let inner_offset;
13566                let mut inner_depth = depth.clone();
13567                if inlined {
13568                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13569                    inner_offset = next_offset;
13570                } else {
13571                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13572                    inner_depth.increment()?;
13573                }
13574                let val_ref = self.format.get_or_insert_with(|| {
13575                    fidl::new_empty!(
13576                        ScreenshotFormat,
13577                        fidl::encoding::DefaultFuchsiaResourceDialect
13578                    )
13579                });
13580                fidl::decode!(
13581                    ScreenshotFormat,
13582                    fidl::encoding::DefaultFuchsiaResourceDialect,
13583                    val_ref,
13584                    decoder,
13585                    inner_offset,
13586                    inner_depth
13587                )?;
13588                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13589                {
13590                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13591                }
13592                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13593                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13594                }
13595            }
13596
13597            next_offset += envelope_size;
13598
13599            // Decode the remaining unknown envelopes.
13600            while next_offset < end_offset {
13601                _next_ordinal_to_read += 1;
13602                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13603                next_offset += envelope_size;
13604            }
13605
13606            Ok(())
13607        }
13608    }
13609
13610    impl ScreenshotTakeResponse {
13611        #[inline(always)]
13612        fn max_ordinal_present(&self) -> u64 {
13613            if let Some(_) = self.size {
13614                return 2;
13615            }
13616            if let Some(_) = self.vmo {
13617                return 1;
13618            }
13619            0
13620        }
13621    }
13622
13623    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeResponse {
13624        type Borrowed<'a> = &'a mut Self;
13625        fn take_or_borrow<'a>(
13626            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13627        ) -> Self::Borrowed<'a> {
13628            value
13629        }
13630    }
13631
13632    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeResponse {
13633        type Owned = Self;
13634
13635        #[inline(always)]
13636        fn inline_align(_context: fidl::encoding::Context) -> usize {
13637            8
13638        }
13639
13640        #[inline(always)]
13641        fn inline_size(_context: fidl::encoding::Context) -> usize {
13642            16
13643        }
13644    }
13645
13646    unsafe impl
13647        fidl::encoding::Encode<
13648            ScreenshotTakeResponse,
13649            fidl::encoding::DefaultFuchsiaResourceDialect,
13650        > for &mut ScreenshotTakeResponse
13651    {
13652        unsafe fn encode(
13653            self,
13654            encoder: &mut fidl::encoding::Encoder<
13655                '_,
13656                fidl::encoding::DefaultFuchsiaResourceDialect,
13657            >,
13658            offset: usize,
13659            mut depth: fidl::encoding::Depth,
13660        ) -> fidl::Result<()> {
13661            encoder.debug_check_bounds::<ScreenshotTakeResponse>(offset);
13662            // Vector header
13663            let max_ordinal: u64 = self.max_ordinal_present();
13664            encoder.write_num(max_ordinal, offset);
13665            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13666            // Calling encoder.out_of_line_offset(0) is not allowed.
13667            if max_ordinal == 0 {
13668                return Ok(());
13669            }
13670            depth.increment()?;
13671            let envelope_size = 8;
13672            let bytes_len = max_ordinal as usize * envelope_size;
13673            #[allow(unused_variables)]
13674            let offset = encoder.out_of_line_offset(bytes_len);
13675            let mut _prev_end_offset: usize = 0;
13676            if 1 > max_ordinal {
13677                return Ok(());
13678            }
13679
13680            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13681            // are envelope_size bytes.
13682            let cur_offset: usize = (1 - 1) * envelope_size;
13683
13684            // Zero reserved fields.
13685            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13686
13687            // Safety:
13688            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13689            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13690            //   envelope_size bytes, there is always sufficient room.
13691            fidl::encoding::encode_in_envelope_optional::<
13692                fidl::encoding::HandleType<
13693                    fidl::Vmo,
13694                    { fidl::ObjectType::VMO.into_raw() },
13695                    2147483648,
13696                >,
13697                fidl::encoding::DefaultFuchsiaResourceDialect,
13698            >(
13699                self.vmo.as_mut().map(
13700                    <fidl::encoding::HandleType<
13701                        fidl::Vmo,
13702                        { fidl::ObjectType::VMO.into_raw() },
13703                        2147483648,
13704                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13705                ),
13706                encoder,
13707                offset + cur_offset,
13708                depth,
13709            )?;
13710
13711            _prev_end_offset = cur_offset + envelope_size;
13712            if 2 > max_ordinal {
13713                return Ok(());
13714            }
13715
13716            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13717            // are envelope_size bytes.
13718            let cur_offset: usize = (2 - 1) * envelope_size;
13719
13720            // Zero reserved fields.
13721            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13722
13723            // Safety:
13724            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13725            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13726            //   envelope_size bytes, there is always sufficient room.
13727            fidl::encoding::encode_in_envelope_optional::<
13728                fidl_fuchsia_math::SizeU,
13729                fidl::encoding::DefaultFuchsiaResourceDialect,
13730            >(
13731                self.size
13732                    .as_ref()
13733                    .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
13734                encoder,
13735                offset + cur_offset,
13736                depth,
13737            )?;
13738
13739            _prev_end_offset = cur_offset + envelope_size;
13740
13741            Ok(())
13742        }
13743    }
13744
13745    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13746        for ScreenshotTakeResponse
13747    {
13748        #[inline(always)]
13749        fn new_empty() -> Self {
13750            Self::default()
13751        }
13752
13753        unsafe fn decode(
13754            &mut self,
13755            decoder: &mut fidl::encoding::Decoder<
13756                '_,
13757                fidl::encoding::DefaultFuchsiaResourceDialect,
13758            >,
13759            offset: usize,
13760            mut depth: fidl::encoding::Depth,
13761        ) -> fidl::Result<()> {
13762            decoder.debug_check_bounds::<Self>(offset);
13763            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13764                None => return Err(fidl::Error::NotNullable),
13765                Some(len) => len,
13766            };
13767            // Calling decoder.out_of_line_offset(0) is not allowed.
13768            if len == 0 {
13769                return Ok(());
13770            };
13771            depth.increment()?;
13772            let envelope_size = 8;
13773            let bytes_len = len * envelope_size;
13774            let offset = decoder.out_of_line_offset(bytes_len)?;
13775            // Decode the envelope for each type.
13776            let mut _next_ordinal_to_read = 0;
13777            let mut next_offset = offset;
13778            let end_offset = offset + bytes_len;
13779            _next_ordinal_to_read += 1;
13780            if next_offset >= end_offset {
13781                return Ok(());
13782            }
13783
13784            // Decode unknown envelopes for gaps in ordinals.
13785            while _next_ordinal_to_read < 1 {
13786                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13787                _next_ordinal_to_read += 1;
13788                next_offset += envelope_size;
13789            }
13790
13791            let next_out_of_line = decoder.next_out_of_line();
13792            let handles_before = decoder.remaining_handles();
13793            if let Some((inlined, num_bytes, num_handles)) =
13794                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13795            {
13796                let member_inline_size = <fidl::encoding::HandleType<
13797                    fidl::Vmo,
13798                    { fidl::ObjectType::VMO.into_raw() },
13799                    2147483648,
13800                > as fidl::encoding::TypeMarker>::inline_size(
13801                    decoder.context
13802                );
13803                if inlined != (member_inline_size <= 4) {
13804                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13805                }
13806                let inner_offset;
13807                let mut inner_depth = depth.clone();
13808                if inlined {
13809                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13810                    inner_offset = next_offset;
13811                } else {
13812                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13813                    inner_depth.increment()?;
13814                }
13815                let val_ref =
13816                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
13817                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
13818                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13819                {
13820                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13821                }
13822                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13823                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13824                }
13825            }
13826
13827            next_offset += envelope_size;
13828            _next_ordinal_to_read += 1;
13829            if next_offset >= end_offset {
13830                return Ok(());
13831            }
13832
13833            // Decode unknown envelopes for gaps in ordinals.
13834            while _next_ordinal_to_read < 2 {
13835                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13836                _next_ordinal_to_read += 1;
13837                next_offset += envelope_size;
13838            }
13839
13840            let next_out_of_line = decoder.next_out_of_line();
13841            let handles_before = decoder.remaining_handles();
13842            if let Some((inlined, num_bytes, num_handles)) =
13843                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13844            {
13845                let member_inline_size =
13846                    <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
13847                        decoder.context,
13848                    );
13849                if inlined != (member_inline_size <= 4) {
13850                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13851                }
13852                let inner_offset;
13853                let mut inner_depth = depth.clone();
13854                if inlined {
13855                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13856                    inner_offset = next_offset;
13857                } else {
13858                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13859                    inner_depth.increment()?;
13860                }
13861                let val_ref = self.size.get_or_insert_with(|| {
13862                    fidl::new_empty!(
13863                        fidl_fuchsia_math::SizeU,
13864                        fidl::encoding::DefaultFuchsiaResourceDialect
13865                    )
13866                });
13867                fidl::decode!(
13868                    fidl_fuchsia_math::SizeU,
13869                    fidl::encoding::DefaultFuchsiaResourceDialect,
13870                    val_ref,
13871                    decoder,
13872                    inner_offset,
13873                    inner_depth
13874                )?;
13875                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13876                {
13877                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13878                }
13879                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13880                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13881                }
13882            }
13883
13884            next_offset += envelope_size;
13885
13886            // Decode the remaining unknown envelopes.
13887            while next_offset < end_offset {
13888                _next_ordinal_to_read += 1;
13889                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13890                next_offset += envelope_size;
13891            }
13892
13893            Ok(())
13894        }
13895    }
13896
13897    impl TrustedFlatlandConfig {
13898        #[inline(always)]
13899        fn max_ordinal_present(&self) -> u64 {
13900            if let Some(_) = self.skips_present_credits {
13901                return 3;
13902            }
13903            if let Some(_) = self.pass_acquire_fences {
13904                return 2;
13905            }
13906            if let Some(_) = self.schedule_asap {
13907                return 1;
13908            }
13909            0
13910        }
13911    }
13912
13913    impl fidl::encoding::ResourceTypeMarker for TrustedFlatlandConfig {
13914        type Borrowed<'a> = &'a mut Self;
13915        fn take_or_borrow<'a>(
13916            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13917        ) -> Self::Borrowed<'a> {
13918            value
13919        }
13920    }
13921
13922    unsafe impl fidl::encoding::TypeMarker for TrustedFlatlandConfig {
13923        type Owned = Self;
13924
13925        #[inline(always)]
13926        fn inline_align(_context: fidl::encoding::Context) -> usize {
13927            8
13928        }
13929
13930        #[inline(always)]
13931        fn inline_size(_context: fidl::encoding::Context) -> usize {
13932            16
13933        }
13934    }
13935
13936    unsafe impl
13937        fidl::encoding::Encode<TrustedFlatlandConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
13938        for &mut TrustedFlatlandConfig
13939    {
13940        unsafe fn encode(
13941            self,
13942            encoder: &mut fidl::encoding::Encoder<
13943                '_,
13944                fidl::encoding::DefaultFuchsiaResourceDialect,
13945            >,
13946            offset: usize,
13947            mut depth: fidl::encoding::Depth,
13948        ) -> fidl::Result<()> {
13949            encoder.debug_check_bounds::<TrustedFlatlandConfig>(offset);
13950            // Vector header
13951            let max_ordinal: u64 = self.max_ordinal_present();
13952            encoder.write_num(max_ordinal, offset);
13953            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13954            // Calling encoder.out_of_line_offset(0) is not allowed.
13955            if max_ordinal == 0 {
13956                return Ok(());
13957            }
13958            depth.increment()?;
13959            let envelope_size = 8;
13960            let bytes_len = max_ordinal as usize * envelope_size;
13961            #[allow(unused_variables)]
13962            let offset = encoder.out_of_line_offset(bytes_len);
13963            let mut _prev_end_offset: usize = 0;
13964            if 1 > max_ordinal {
13965                return Ok(());
13966            }
13967
13968            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13969            // are envelope_size bytes.
13970            let cur_offset: usize = (1 - 1) * envelope_size;
13971
13972            // Zero reserved fields.
13973            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13974
13975            // Safety:
13976            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13977            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13978            //   envelope_size bytes, there is always sufficient room.
13979            fidl::encoding::encode_in_envelope_optional::<
13980                bool,
13981                fidl::encoding::DefaultFuchsiaResourceDialect,
13982            >(
13983                self.schedule_asap.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
13984                encoder,
13985                offset + cur_offset,
13986                depth,
13987            )?;
13988
13989            _prev_end_offset = cur_offset + envelope_size;
13990            if 2 > max_ordinal {
13991                return Ok(());
13992            }
13993
13994            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13995            // are envelope_size bytes.
13996            let cur_offset: usize = (2 - 1) * envelope_size;
13997
13998            // Zero reserved fields.
13999            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14000
14001            // Safety:
14002            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14003            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14004            //   envelope_size bytes, there is always sufficient room.
14005            fidl::encoding::encode_in_envelope_optional::<
14006                bool,
14007                fidl::encoding::DefaultFuchsiaResourceDialect,
14008            >(
14009                self.pass_acquire_fences
14010                    .as_ref()
14011                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14012                encoder,
14013                offset + cur_offset,
14014                depth,
14015            )?;
14016
14017            _prev_end_offset = cur_offset + envelope_size;
14018            if 3 > max_ordinal {
14019                return Ok(());
14020            }
14021
14022            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14023            // are envelope_size bytes.
14024            let cur_offset: usize = (3 - 1) * envelope_size;
14025
14026            // Zero reserved fields.
14027            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14028
14029            // Safety:
14030            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14031            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14032            //   envelope_size bytes, there is always sufficient room.
14033            fidl::encoding::encode_in_envelope_optional::<
14034                bool,
14035                fidl::encoding::DefaultFuchsiaResourceDialect,
14036            >(
14037                self.skips_present_credits
14038                    .as_ref()
14039                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14040                encoder,
14041                offset + cur_offset,
14042                depth,
14043            )?;
14044
14045            _prev_end_offset = cur_offset + envelope_size;
14046
14047            Ok(())
14048        }
14049    }
14050
14051    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14052        for TrustedFlatlandConfig
14053    {
14054        #[inline(always)]
14055        fn new_empty() -> Self {
14056            Self::default()
14057        }
14058
14059        unsafe fn decode(
14060            &mut self,
14061            decoder: &mut fidl::encoding::Decoder<
14062                '_,
14063                fidl::encoding::DefaultFuchsiaResourceDialect,
14064            >,
14065            offset: usize,
14066            mut depth: fidl::encoding::Depth,
14067        ) -> fidl::Result<()> {
14068            decoder.debug_check_bounds::<Self>(offset);
14069            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14070                None => return Err(fidl::Error::NotNullable),
14071                Some(len) => len,
14072            };
14073            // Calling decoder.out_of_line_offset(0) is not allowed.
14074            if len == 0 {
14075                return Ok(());
14076            };
14077            depth.increment()?;
14078            let envelope_size = 8;
14079            let bytes_len = len * envelope_size;
14080            let offset = decoder.out_of_line_offset(bytes_len)?;
14081            // Decode the envelope for each type.
14082            let mut _next_ordinal_to_read = 0;
14083            let mut next_offset = offset;
14084            let end_offset = offset + bytes_len;
14085            _next_ordinal_to_read += 1;
14086            if next_offset >= end_offset {
14087                return Ok(());
14088            }
14089
14090            // Decode unknown envelopes for gaps in ordinals.
14091            while _next_ordinal_to_read < 1 {
14092                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14093                _next_ordinal_to_read += 1;
14094                next_offset += envelope_size;
14095            }
14096
14097            let next_out_of_line = decoder.next_out_of_line();
14098            let handles_before = decoder.remaining_handles();
14099            if let Some((inlined, num_bytes, num_handles)) =
14100                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14101            {
14102                let member_inline_size =
14103                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14104                if inlined != (member_inline_size <= 4) {
14105                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14106                }
14107                let inner_offset;
14108                let mut inner_depth = depth.clone();
14109                if inlined {
14110                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14111                    inner_offset = next_offset;
14112                } else {
14113                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14114                    inner_depth.increment()?;
14115                }
14116                let val_ref = self.schedule_asap.get_or_insert_with(|| {
14117                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
14118                });
14119                fidl::decode!(
14120                    bool,
14121                    fidl::encoding::DefaultFuchsiaResourceDialect,
14122                    val_ref,
14123                    decoder,
14124                    inner_offset,
14125                    inner_depth
14126                )?;
14127                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14128                {
14129                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14130                }
14131                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14132                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14133                }
14134            }
14135
14136            next_offset += envelope_size;
14137            _next_ordinal_to_read += 1;
14138            if next_offset >= end_offset {
14139                return Ok(());
14140            }
14141
14142            // Decode unknown envelopes for gaps in ordinals.
14143            while _next_ordinal_to_read < 2 {
14144                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14145                _next_ordinal_to_read += 1;
14146                next_offset += envelope_size;
14147            }
14148
14149            let next_out_of_line = decoder.next_out_of_line();
14150            let handles_before = decoder.remaining_handles();
14151            if let Some((inlined, num_bytes, num_handles)) =
14152                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14153            {
14154                let member_inline_size =
14155                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14156                if inlined != (member_inline_size <= 4) {
14157                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14158                }
14159                let inner_offset;
14160                let mut inner_depth = depth.clone();
14161                if inlined {
14162                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14163                    inner_offset = next_offset;
14164                } else {
14165                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14166                    inner_depth.increment()?;
14167                }
14168                let val_ref = self.pass_acquire_fences.get_or_insert_with(|| {
14169                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
14170                });
14171                fidl::decode!(
14172                    bool,
14173                    fidl::encoding::DefaultFuchsiaResourceDialect,
14174                    val_ref,
14175                    decoder,
14176                    inner_offset,
14177                    inner_depth
14178                )?;
14179                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14180                {
14181                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14182                }
14183                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14184                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14185                }
14186            }
14187
14188            next_offset += envelope_size;
14189            _next_ordinal_to_read += 1;
14190            if next_offset >= end_offset {
14191                return Ok(());
14192            }
14193
14194            // Decode unknown envelopes for gaps in ordinals.
14195            while _next_ordinal_to_read < 3 {
14196                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14197                _next_ordinal_to_read += 1;
14198                next_offset += envelope_size;
14199            }
14200
14201            let next_out_of_line = decoder.next_out_of_line();
14202            let handles_before = decoder.remaining_handles();
14203            if let Some((inlined, num_bytes, num_handles)) =
14204                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14205            {
14206                let member_inline_size =
14207                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14208                if inlined != (member_inline_size <= 4) {
14209                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14210                }
14211                let inner_offset;
14212                let mut inner_depth = depth.clone();
14213                if inlined {
14214                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14215                    inner_offset = next_offset;
14216                } else {
14217                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14218                    inner_depth.increment()?;
14219                }
14220                let val_ref = self.skips_present_credits.get_or_insert_with(|| {
14221                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
14222                });
14223                fidl::decode!(
14224                    bool,
14225                    fidl::encoding::DefaultFuchsiaResourceDialect,
14226                    val_ref,
14227                    decoder,
14228                    inner_offset,
14229                    inner_depth
14230                )?;
14231                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14232                {
14233                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14234                }
14235                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14236                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14237                }
14238            }
14239
14240            next_offset += envelope_size;
14241
14242            // Decode the remaining unknown envelopes.
14243            while next_offset < end_offset {
14244                _next_ordinal_to_read += 1;
14245                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14246                next_offset += envelope_size;
14247            }
14248
14249            Ok(())
14250        }
14251    }
14252
14253    impl ViewBoundProtocols {
14254        #[inline(always)]
14255        fn max_ordinal_present(&self) -> u64 {
14256            if let Some(_) = self.mouse_source {
14257                return 4;
14258            }
14259            if let Some(_) = self.touch_source {
14260                return 3;
14261            }
14262            if let Some(_) = self.view_focuser {
14263                return 2;
14264            }
14265            if let Some(_) = self.view_ref_focused {
14266                return 1;
14267            }
14268            0
14269        }
14270    }
14271
14272    impl fidl::encoding::ResourceTypeMarker for ViewBoundProtocols {
14273        type Borrowed<'a> = &'a mut Self;
14274        fn take_or_borrow<'a>(
14275            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14276        ) -> Self::Borrowed<'a> {
14277            value
14278        }
14279    }
14280
14281    unsafe impl fidl::encoding::TypeMarker for ViewBoundProtocols {
14282        type Owned = Self;
14283
14284        #[inline(always)]
14285        fn inline_align(_context: fidl::encoding::Context) -> usize {
14286            8
14287        }
14288
14289        #[inline(always)]
14290        fn inline_size(_context: fidl::encoding::Context) -> usize {
14291            16
14292        }
14293    }
14294
14295    unsafe impl
14296        fidl::encoding::Encode<ViewBoundProtocols, fidl::encoding::DefaultFuchsiaResourceDialect>
14297        for &mut ViewBoundProtocols
14298    {
14299        unsafe fn encode(
14300            self,
14301            encoder: &mut fidl::encoding::Encoder<
14302                '_,
14303                fidl::encoding::DefaultFuchsiaResourceDialect,
14304            >,
14305            offset: usize,
14306            mut depth: fidl::encoding::Depth,
14307        ) -> fidl::Result<()> {
14308            encoder.debug_check_bounds::<ViewBoundProtocols>(offset);
14309            // Vector header
14310            let max_ordinal: u64 = self.max_ordinal_present();
14311            encoder.write_num(max_ordinal, offset);
14312            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14313            // Calling encoder.out_of_line_offset(0) is not allowed.
14314            if max_ordinal == 0 {
14315                return Ok(());
14316            }
14317            depth.increment()?;
14318            let envelope_size = 8;
14319            let bytes_len = max_ordinal as usize * envelope_size;
14320            #[allow(unused_variables)]
14321            let offset = encoder.out_of_line_offset(bytes_len);
14322            let mut _prev_end_offset: usize = 0;
14323            if 1 > max_ordinal {
14324                return Ok(());
14325            }
14326
14327            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14328            // are envelope_size bytes.
14329            let cur_offset: usize = (1 - 1) * envelope_size;
14330
14331            // Zero reserved fields.
14332            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14333
14334            // Safety:
14335            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14336            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14337            //   envelope_size bytes, there is always sufficient room.
14338            fidl::encoding::encode_in_envelope_optional::<
14339                fidl::encoding::Endpoint<
14340                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
14341                >,
14342                fidl::encoding::DefaultFuchsiaResourceDialect,
14343            >(
14344                self.view_ref_focused.as_mut().map(
14345                    <fidl::encoding::Endpoint<
14346                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
14347                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14348                ),
14349                encoder,
14350                offset + cur_offset,
14351                depth,
14352            )?;
14353
14354            _prev_end_offset = cur_offset + envelope_size;
14355            if 2 > max_ordinal {
14356                return Ok(());
14357            }
14358
14359            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14360            // are envelope_size bytes.
14361            let cur_offset: usize = (2 - 1) * envelope_size;
14362
14363            // Zero reserved fields.
14364            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14365
14366            // Safety:
14367            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14368            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14369            //   envelope_size bytes, there is always sufficient room.
14370            fidl::encoding::encode_in_envelope_optional::<
14371                fidl::encoding::Endpoint<
14372                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
14373                >,
14374                fidl::encoding::DefaultFuchsiaResourceDialect,
14375            >(
14376                self.view_focuser.as_mut().map(
14377                    <fidl::encoding::Endpoint<
14378                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
14379                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14380                ),
14381                encoder,
14382                offset + cur_offset,
14383                depth,
14384            )?;
14385
14386            _prev_end_offset = cur_offset + envelope_size;
14387            if 3 > max_ordinal {
14388                return Ok(());
14389            }
14390
14391            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14392            // are envelope_size bytes.
14393            let cur_offset: usize = (3 - 1) * envelope_size;
14394
14395            // Zero reserved fields.
14396            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14397
14398            // Safety:
14399            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14400            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14401            //   envelope_size bytes, there is always sufficient room.
14402            fidl::encoding::encode_in_envelope_optional::<
14403                fidl::encoding::Endpoint<
14404                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
14405                >,
14406                fidl::encoding::DefaultFuchsiaResourceDialect,
14407            >(
14408                self.touch_source.as_mut().map(
14409                    <fidl::encoding::Endpoint<
14410                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
14411                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14412                ),
14413                encoder,
14414                offset + cur_offset,
14415                depth,
14416            )?;
14417
14418            _prev_end_offset = cur_offset + envelope_size;
14419            if 4 > max_ordinal {
14420                return Ok(());
14421            }
14422
14423            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14424            // are envelope_size bytes.
14425            let cur_offset: usize = (4 - 1) * envelope_size;
14426
14427            // Zero reserved fields.
14428            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14429
14430            // Safety:
14431            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14432            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14433            //   envelope_size bytes, there is always sufficient room.
14434            fidl::encoding::encode_in_envelope_optional::<
14435                fidl::encoding::Endpoint<
14436                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14437                >,
14438                fidl::encoding::DefaultFuchsiaResourceDialect,
14439            >(
14440                self.mouse_source.as_mut().map(
14441                    <fidl::encoding::Endpoint<
14442                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14443                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14444                ),
14445                encoder,
14446                offset + cur_offset,
14447                depth,
14448            )?;
14449
14450            _prev_end_offset = cur_offset + envelope_size;
14451
14452            Ok(())
14453        }
14454    }
14455
14456    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14457        for ViewBoundProtocols
14458    {
14459        #[inline(always)]
14460        fn new_empty() -> Self {
14461            Self::default()
14462        }
14463
14464        unsafe fn decode(
14465            &mut self,
14466            decoder: &mut fidl::encoding::Decoder<
14467                '_,
14468                fidl::encoding::DefaultFuchsiaResourceDialect,
14469            >,
14470            offset: usize,
14471            mut depth: fidl::encoding::Depth,
14472        ) -> fidl::Result<()> {
14473            decoder.debug_check_bounds::<Self>(offset);
14474            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14475                None => return Err(fidl::Error::NotNullable),
14476                Some(len) => len,
14477            };
14478            // Calling decoder.out_of_line_offset(0) is not allowed.
14479            if len == 0 {
14480                return Ok(());
14481            };
14482            depth.increment()?;
14483            let envelope_size = 8;
14484            let bytes_len = len * envelope_size;
14485            let offset = decoder.out_of_line_offset(bytes_len)?;
14486            // Decode the envelope for each type.
14487            let mut _next_ordinal_to_read = 0;
14488            let mut next_offset = offset;
14489            let end_offset = offset + bytes_len;
14490            _next_ordinal_to_read += 1;
14491            if next_offset >= end_offset {
14492                return Ok(());
14493            }
14494
14495            // Decode unknown envelopes for gaps in ordinals.
14496            while _next_ordinal_to_read < 1 {
14497                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14498                _next_ordinal_to_read += 1;
14499                next_offset += envelope_size;
14500            }
14501
14502            let next_out_of_line = decoder.next_out_of_line();
14503            let handles_before = decoder.remaining_handles();
14504            if let Some((inlined, num_bytes, num_handles)) =
14505                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14506            {
14507                let member_inline_size = <fidl::encoding::Endpoint<
14508                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
14509                > as fidl::encoding::TypeMarker>::inline_size(
14510                    decoder.context
14511                );
14512                if inlined != (member_inline_size <= 4) {
14513                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14514                }
14515                let inner_offset;
14516                let mut inner_depth = depth.clone();
14517                if inlined {
14518                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14519                    inner_offset = next_offset;
14520                } else {
14521                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14522                    inner_depth.increment()?;
14523                }
14524                let val_ref = self.view_ref_focused.get_or_insert_with(|| {
14525                    fidl::new_empty!(
14526                        fidl::encoding::Endpoint<
14527                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
14528                        >,
14529                        fidl::encoding::DefaultFuchsiaResourceDialect
14530                    )
14531                });
14532                fidl::decode!(
14533                    fidl::encoding::Endpoint<
14534                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
14535                    >,
14536                    fidl::encoding::DefaultFuchsiaResourceDialect,
14537                    val_ref,
14538                    decoder,
14539                    inner_offset,
14540                    inner_depth
14541                )?;
14542                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14543                {
14544                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14545                }
14546                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14547                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14548                }
14549            }
14550
14551            next_offset += envelope_size;
14552            _next_ordinal_to_read += 1;
14553            if next_offset >= end_offset {
14554                return Ok(());
14555            }
14556
14557            // Decode unknown envelopes for gaps in ordinals.
14558            while _next_ordinal_to_read < 2 {
14559                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14560                _next_ordinal_to_read += 1;
14561                next_offset += envelope_size;
14562            }
14563
14564            let next_out_of_line = decoder.next_out_of_line();
14565            let handles_before = decoder.remaining_handles();
14566            if let Some((inlined, num_bytes, num_handles)) =
14567                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14568            {
14569                let member_inline_size = <fidl::encoding::Endpoint<
14570                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
14571                > as fidl::encoding::TypeMarker>::inline_size(
14572                    decoder.context
14573                );
14574                if inlined != (member_inline_size <= 4) {
14575                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14576                }
14577                let inner_offset;
14578                let mut inner_depth = depth.clone();
14579                if inlined {
14580                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14581                    inner_offset = next_offset;
14582                } else {
14583                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14584                    inner_depth.increment()?;
14585                }
14586                let val_ref = self.view_focuser.get_or_insert_with(|| {
14587                    fidl::new_empty!(
14588                        fidl::encoding::Endpoint<
14589                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
14590                        >,
14591                        fidl::encoding::DefaultFuchsiaResourceDialect
14592                    )
14593                });
14594                fidl::decode!(
14595                    fidl::encoding::Endpoint<
14596                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
14597                    >,
14598                    fidl::encoding::DefaultFuchsiaResourceDialect,
14599                    val_ref,
14600                    decoder,
14601                    inner_offset,
14602                    inner_depth
14603                )?;
14604                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14605                {
14606                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14607                }
14608                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14609                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14610                }
14611            }
14612
14613            next_offset += envelope_size;
14614            _next_ordinal_to_read += 1;
14615            if next_offset >= end_offset {
14616                return Ok(());
14617            }
14618
14619            // Decode unknown envelopes for gaps in ordinals.
14620            while _next_ordinal_to_read < 3 {
14621                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14622                _next_ordinal_to_read += 1;
14623                next_offset += envelope_size;
14624            }
14625
14626            let next_out_of_line = decoder.next_out_of_line();
14627            let handles_before = decoder.remaining_handles();
14628            if let Some((inlined, num_bytes, num_handles)) =
14629                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14630            {
14631                let member_inline_size = <fidl::encoding::Endpoint<
14632                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
14633                > as fidl::encoding::TypeMarker>::inline_size(
14634                    decoder.context
14635                );
14636                if inlined != (member_inline_size <= 4) {
14637                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14638                }
14639                let inner_offset;
14640                let mut inner_depth = depth.clone();
14641                if inlined {
14642                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14643                    inner_offset = next_offset;
14644                } else {
14645                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14646                    inner_depth.increment()?;
14647                }
14648                let val_ref = self.touch_source.get_or_insert_with(|| {
14649                    fidl::new_empty!(
14650                        fidl::encoding::Endpoint<
14651                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
14652                        >,
14653                        fidl::encoding::DefaultFuchsiaResourceDialect
14654                    )
14655                });
14656                fidl::decode!(
14657                    fidl::encoding::Endpoint<
14658                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
14659                    >,
14660                    fidl::encoding::DefaultFuchsiaResourceDialect,
14661                    val_ref,
14662                    decoder,
14663                    inner_offset,
14664                    inner_depth
14665                )?;
14666                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14667                {
14668                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14669                }
14670                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14671                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14672                }
14673            }
14674
14675            next_offset += envelope_size;
14676            _next_ordinal_to_read += 1;
14677            if next_offset >= end_offset {
14678                return Ok(());
14679            }
14680
14681            // Decode unknown envelopes for gaps in ordinals.
14682            while _next_ordinal_to_read < 4 {
14683                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14684                _next_ordinal_to_read += 1;
14685                next_offset += envelope_size;
14686            }
14687
14688            let next_out_of_line = decoder.next_out_of_line();
14689            let handles_before = decoder.remaining_handles();
14690            if let Some((inlined, num_bytes, num_handles)) =
14691                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14692            {
14693                let member_inline_size = <fidl::encoding::Endpoint<
14694                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14695                > as fidl::encoding::TypeMarker>::inline_size(
14696                    decoder.context
14697                );
14698                if inlined != (member_inline_size <= 4) {
14699                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14700                }
14701                let inner_offset;
14702                let mut inner_depth = depth.clone();
14703                if inlined {
14704                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14705                    inner_offset = next_offset;
14706                } else {
14707                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14708                    inner_depth.increment()?;
14709                }
14710                let val_ref = self.mouse_source.get_or_insert_with(|| {
14711                    fidl::new_empty!(
14712                        fidl::encoding::Endpoint<
14713                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14714                        >,
14715                        fidl::encoding::DefaultFuchsiaResourceDialect
14716                    )
14717                });
14718                fidl::decode!(
14719                    fidl::encoding::Endpoint<
14720                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
14721                    >,
14722                    fidl::encoding::DefaultFuchsiaResourceDialect,
14723                    val_ref,
14724                    decoder,
14725                    inner_offset,
14726                    inner_depth
14727                )?;
14728                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14729                {
14730                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14731                }
14732                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14733                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14734                }
14735            }
14736
14737            next_offset += envelope_size;
14738
14739            // Decode the remaining unknown envelopes.
14740            while next_offset < end_offset {
14741                _next_ordinal_to_read += 1;
14742                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14743                next_offset += envelope_size;
14744            }
14745
14746            Ok(())
14747        }
14748    }
14749}