fidl_fuchsia_images/
fidl_fuchsia_images.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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13pub const MAX_ACQUIRE_RELEASE_FENCE_COUNT: i32 = 16;
14
15/// Specifies how alpha information should be interpreted.
16#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
17#[repr(u32)]
18pub enum AlphaFormat {
19    /// Image is considered to be opaque.  Alpha channel is ignored.
20    /// Blend function is: src.RGB
21    Opaque = 0,
22    /// Color channels have been premultiplied by alpha.
23    /// Blend function is: src.RGB + (dest.RGB * (1 - src.A))
24    Premultiplied = 1,
25    /// Color channels have not been premultiplied by alpha.
26    /// Blend function is: (src.RGB * src.A) + (dest.RGB * (1 - src.A))
27    NonPremultiplied = 2,
28}
29
30impl AlphaFormat {
31    #[inline]
32    pub fn from_primitive(prim: u32) -> Option<Self> {
33        match prim {
34            0 => Some(Self::Opaque),
35            1 => Some(Self::Premultiplied),
36            2 => Some(Self::NonPremultiplied),
37            _ => None,
38        }
39    }
40
41    #[inline]
42    pub const fn into_primitive(self) -> u32 {
43        self as u32
44    }
45
46    #[deprecated = "Strict enums should not use `is_unknown`"]
47    #[inline]
48    pub fn is_unknown(&self) -> bool {
49        false
50    }
51}
52
53/// Specifies how pixel color information should be interpreted.
54#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
55#[repr(u32)]
56pub enum ColorSpace {
57    Srgb = 0,
58}
59
60impl ColorSpace {
61    #[inline]
62    pub fn from_primitive(prim: u32) -> Option<Self> {
63        match prim {
64            0 => Some(Self::Srgb),
65            _ => None,
66        }
67    }
68
69    #[inline]
70    pub const fn into_primitive(self) -> u32 {
71        self as u32
72    }
73
74    #[deprecated = "Strict enums should not use `is_unknown`"]
75    #[inline]
76    pub fn is_unknown(&self) -> bool {
77        false
78    }
79}
80
81/// Specifies the type of VMO's memory.
82#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
83#[repr(u32)]
84pub enum MemoryType {
85    /// VMO is regular host CPU memory.
86    HostMemory = 0,
87    /// VMO can be imported as a VkDeviceMemory by calling VkAllocateMemory with a
88    /// VkImportMemoryFuchsiaHandleInfoKHR wrapped in a VkMemoryAllocateInfo.
89    VkDeviceMemory = 1,
90}
91
92impl MemoryType {
93    #[inline]
94    pub fn from_primitive(prim: u32) -> Option<Self> {
95        match prim {
96            0 => Some(Self::HostMemory),
97            1 => Some(Self::VkDeviceMemory),
98            _ => None,
99        }
100    }
101
102    #[inline]
103    pub const fn into_primitive(self) -> u32 {
104        self as u32
105    }
106
107    #[deprecated = "Strict enums should not use `is_unknown`"]
108    #[inline]
109    pub fn is_unknown(&self) -> bool {
110        false
111    }
112}
113
114/// Specifies how pixels are represented in the image buffer.
115#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
116#[repr(u32)]
117pub enum PixelFormat {
118    /// BGRA_8
119    ///
120    /// A 32-bit four-component unsigned integer format.
121    /// Byte order: B, G, R, A (little-endian ARGB packed 32-bit word).
122    /// Equivalent to Skia `kBGRA_8888_SkColorType` color type.
123    /// Equivalent to Zircon `ARGB_8888` pixel format on little-endian arch.
124    Bgra8 = 0,
125    /// YUY2
126    ///
127    /// 4:2:2 (2x down-sampled UV horizontally; full res UV vertically)
128    ///
129    /// A 32-bit component that contains information for 2 pixels:
130    /// Byte order: Y1, U, Y2, V
131    /// Unpacks to 2 RGB pixels, where RGB1 = func(Y1, U, V)
132    /// and RGB2 = func(Y2, U, V)
133    /// Equivalent to YUV422
134    Yuy2 = 1,
135    /// NV12
136    ///
137    /// 4:2:0 (2x down-sampled UV in both directions)
138    ///
139    /// Offset 0:
140    /// 8 bit per pixel Y plane with bytes YYY.
141    /// Offset height * stride:
142    /// 8 bit UV data interleaved bytes as UVUVUV.
143    ///
144    /// Y plane has line stride >= width.
145    ///
146    /// In this context, both width and height are required to be even.
147    ///
148    /// The UV data is separated into "lines", with each "line" having same byte
149    /// width as a line of Y data, and same "line" stride as Y data's line stride.
150    /// The UV data has height / 2 "lines".
151    ///
152    /// In converting to RGB, the UV data gets up-scaled by 2x in both directions
153    /// overall.  This comment is intentionally silent on exactly how UV up-scaling
154    /// phase/filtering/signal processing works, as it's a complicated topic that
155    /// can vary by implementation, typically trading off speed and quality of the
156    /// up-scaling.  See comments in relevant conversion code for approach taken
157    /// by any given convert path.  The precise relative phase of the UV data is
158    /// not presently conveyed.
159    Nv12 = 2,
160    /// YV12
161    ///
162    /// Like I420, except with V and U swapped.
163    ///
164    /// 4:2:0 (2x down-sampled UV in both directions)
165    ///
166    /// Offset 0:
167    /// 8 bit per pixel Y plane with bytes YYY.
168    /// Offset height * stride:
169    /// 8 bit V data with uv_stride = stride / 2
170    /// Offset height * stride + uv_stride * height / 2:
171    /// 8 bit U data with uv_stride = stride / 2
172    ///
173    /// Y plane has line stride >= width.
174    ///
175    /// Both width and height are required to be even.
176    Yv12 = 3,
177    /// R8G8B8A8
178    ///
179    /// A 32-bit four-component unsigned integer format.
180    /// Byte order: R, G, B, A (little-endian ABGR packed 32-bit word).
181    /// Equivalent to Skia `kRGBA_8888_SkColorType` color type.
182    /// Equivalent to Zircon `ABGR_8888` pixel format on little-endian arch.
183    ///
184    /// This format can only be used with VK_DEVICE_MEMORY.
185    R8G8B8A8 = 4,
186}
187
188impl PixelFormat {
189    #[inline]
190    pub fn from_primitive(prim: u32) -> Option<Self> {
191        match prim {
192            0 => Some(Self::Bgra8),
193            1 => Some(Self::Yuy2),
194            2 => Some(Self::Nv12),
195            3 => Some(Self::Yv12),
196            4 => Some(Self::R8G8B8A8),
197            _ => None,
198        }
199    }
200
201    #[inline]
202    pub const fn into_primitive(self) -> u32 {
203        self as u32
204    }
205
206    #[deprecated = "Strict enums should not use `is_unknown`"]
207    #[inline]
208    pub fn is_unknown(&self) -> bool {
209        false
210    }
211}
212
213/// Specifies how pixels are arranged in memory.
214#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
215#[repr(u32)]
216pub enum Tiling {
217    /// Pixels are packed linearly.
218    /// Equivalent to `VK_IMAGE_TILING_LINEAR`.
219    Linear = 0,
220    /// Pixels are packed in a GPU-dependent optimal format.
221    /// Equivalent to `VK_IMAGE_TILING_OPTIMAL`.
222    GpuOptimal = 1,
223}
224
225impl Tiling {
226    #[inline]
227    pub fn from_primitive(prim: u32) -> Option<Self> {
228        match prim {
229            0 => Some(Self::Linear),
230            1 => Some(Self::GpuOptimal),
231            _ => None,
232        }
233    }
234
235    #[inline]
236    pub const fn into_primitive(self) -> u32 {
237        self as u32
238    }
239
240    #[deprecated = "Strict enums should not use `is_unknown`"]
241    #[inline]
242    pub fn is_unknown(&self) -> bool {
243        false
244    }
245}
246
247#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
248#[repr(u32)]
249pub enum Transform {
250    /// Pixels are displayed normally.
251    Normal = 0,
252    /// Pixels are mirrored left-right.
253    FlipHorizontal = 1,
254    /// Pixels are flipped vertically.
255    FlipVertical = 2,
256    /// Pixels are flipped vertically and mirrored left-right.
257    FlipVerticalAndHorizontal = 3,
258}
259
260impl Transform {
261    #[inline]
262    pub fn from_primitive(prim: u32) -> Option<Self> {
263        match prim {
264            0 => Some(Self::Normal),
265            1 => Some(Self::FlipHorizontal),
266            2 => Some(Self::FlipVertical),
267            3 => Some(Self::FlipVerticalAndHorizontal),
268            _ => None,
269        }
270    }
271
272    #[inline]
273    pub const fn into_primitive(self) -> u32 {
274        self as u32
275    }
276
277    #[deprecated = "Strict enums should not use `is_unknown`"]
278    #[inline]
279    pub fn is_unknown(&self) -> bool {
280        false
281    }
282}
283
284/// Information about a graphical image (texture) including its format and size.
285#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
286pub struct ImageInfo {
287    /// Specifies if the image should be mirrored before displaying.
288    pub transform: Transform,
289    /// The width and height of the image in pixels.
290    pub width: u32,
291    pub height: u32,
292    /// The number of bytes per row in the image buffer.
293    pub stride: u32,
294    /// The pixel format of the image.
295    pub pixel_format: PixelFormat,
296    /// The pixel color space.
297    pub color_space: ColorSpace,
298    /// The pixel arrangement in memory.
299    pub tiling: Tiling,
300    /// Specifies the interpretion of the alpha channel, if one exists.
301    pub alpha_format: AlphaFormat,
302}
303
304impl fidl::Persistable for ImageInfo {}
305
306#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
307pub struct ImagePipe2AddBufferCollection2Request {
308    pub buffer_collection_id: u32,
309    pub buffer_collection_token:
310        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
311}
312
313impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
314    for ImagePipe2AddBufferCollection2Request
315{
316}
317
318#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
319pub struct ImagePipe2AddBufferCollectionRequest {
320    pub buffer_collection_id: u32,
321    pub buffer_collection_token:
322        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
323}
324
325impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
326    for ImagePipe2AddBufferCollectionRequest
327{
328}
329
330#[derive(Clone, Debug, PartialEq)]
331pub struct ImagePipe2AddImageRequest {
332    pub image_id: u32,
333    pub buffer_collection_id: u32,
334    pub buffer_collection_index: u32,
335    pub image_format: fidl_fuchsia_sysmem::ImageFormat2,
336}
337
338impl fidl::Persistable for ImagePipe2AddImageRequest {}
339
340#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
341pub struct ImagePipe2PresentImageRequest {
342    pub image_id: u32,
343    pub presentation_time: u64,
344    pub acquire_fences: Vec<fidl::Event>,
345    pub release_fences: Vec<fidl::Event>,
346}
347
348impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
349    for ImagePipe2PresentImageRequest
350{
351}
352
353#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
354#[repr(C)]
355pub struct ImagePipe2PresentImageResponse {
356    pub presentation_info: PresentationInfo,
357}
358
359impl fidl::Persistable for ImagePipe2PresentImageResponse {}
360
361#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
362#[repr(C)]
363pub struct ImagePipe2RemoveBufferCollectionRequest {
364    pub buffer_collection_id: u32,
365}
366
367impl fidl::Persistable for ImagePipe2RemoveBufferCollectionRequest {}
368
369#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
370#[repr(C)]
371pub struct ImagePipe2RemoveImageRequest {
372    pub image_id: u32,
373}
374
375impl fidl::Persistable for ImagePipe2RemoveImageRequest {}
376
377/// Information returned by methods such as `ImagePipe.PresentImage()` and
378/// `Session.Present()`, when the consumer begins preparing the first frame
379/// which includes the presented content.
380#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
381#[repr(C)]
382pub struct PresentationInfo {
383    /// The actual time at which the enqueued operations are anticipated to take
384    /// visible effect, expressed in nanoseconds in the `CLOCK_MONOTONIC`
385    /// timebase.
386    ///
387    /// This value increases monotonically with each new frame, typically in
388    /// increments of the `presentation_interval`.
389    pub presentation_time: u64,
390    /// The nominal amount of time which is anticipated to elapse between
391    /// successively presented frames, expressed in nanoseconds.  When rendering
392    /// to a display, the interval will typically be derived from the display
393    /// refresh rate.
394    ///
395    /// This value is non-zero.  It may vary from time to time, such as when
396    /// changing display modes.
397    pub presentation_interval: u64,
398}
399
400impl fidl::Persistable for PresentationInfo {}
401
402#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
403pub struct ImagePipe2Marker;
404
405impl fidl::endpoints::ProtocolMarker for ImagePipe2Marker {
406    type Proxy = ImagePipe2Proxy;
407    type RequestStream = ImagePipe2RequestStream;
408    #[cfg(target_os = "fuchsia")]
409    type SynchronousProxy = ImagePipe2SynchronousProxy;
410
411    const DEBUG_NAME: &'static str = "(anonymous) ImagePipe2";
412}
413
414pub trait ImagePipe2ProxyInterface: Send + Sync {
415    fn r#add_buffer_collection2(
416        &self,
417        buffer_collection_id: u32,
418        buffer_collection_token: fidl::endpoints::ClientEnd<
419            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
420        >,
421    ) -> Result<(), fidl::Error>;
422    fn r#add_buffer_collection(
423        &self,
424        buffer_collection_id: u32,
425        buffer_collection_token: fidl::endpoints::ClientEnd<
426            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
427        >,
428    ) -> Result<(), fidl::Error>;
429    fn r#add_image(
430        &self,
431        image_id: u32,
432        buffer_collection_id: u32,
433        buffer_collection_index: u32,
434        image_format: &fidl_fuchsia_sysmem::ImageFormat2,
435    ) -> Result<(), fidl::Error>;
436    fn r#remove_buffer_collection(&self, buffer_collection_id: u32) -> Result<(), fidl::Error>;
437    fn r#remove_image(&self, image_id: u32) -> Result<(), fidl::Error>;
438    type PresentImageResponseFut: std::future::Future<Output = Result<PresentationInfo, fidl::Error>>
439        + Send;
440    fn r#present_image(
441        &self,
442        image_id: u32,
443        presentation_time: u64,
444        acquire_fences: Vec<fidl::Event>,
445        release_fences: Vec<fidl::Event>,
446    ) -> Self::PresentImageResponseFut;
447}
448#[derive(Debug)]
449#[cfg(target_os = "fuchsia")]
450pub struct ImagePipe2SynchronousProxy {
451    client: fidl::client::sync::Client,
452}
453
454#[cfg(target_os = "fuchsia")]
455impl fidl::endpoints::SynchronousProxy for ImagePipe2SynchronousProxy {
456    type Proxy = ImagePipe2Proxy;
457    type Protocol = ImagePipe2Marker;
458
459    fn from_channel(inner: fidl::Channel) -> Self {
460        Self::new(inner)
461    }
462
463    fn into_channel(self) -> fidl::Channel {
464        self.client.into_channel()
465    }
466
467    fn as_channel(&self) -> &fidl::Channel {
468        self.client.as_channel()
469    }
470}
471
472#[cfg(target_os = "fuchsia")]
473impl ImagePipe2SynchronousProxy {
474    pub fn new(channel: fidl::Channel) -> Self {
475        let protocol_name = <ImagePipe2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
476        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
477    }
478
479    pub fn into_channel(self) -> fidl::Channel {
480        self.client.into_channel()
481    }
482
483    /// Waits until an event arrives and returns it. It is safe for other
484    /// threads to make concurrent requests while waiting for an event.
485    pub fn wait_for_event(
486        &self,
487        deadline: zx::MonotonicInstant,
488    ) -> Result<ImagePipe2Event, fidl::Error> {
489        ImagePipe2Event::decode(self.client.wait_for_event(deadline)?)
490    }
491
492    /// Adds a BufferCollection resource to the image pipe.
493    ///
494    /// The producer is expected to set constraints on this resource for images added
495    /// via `AddImage()`. The consumer can set its constraints on
496    /// `buffer_collection_token` before or after. Note that the buffers won't be
497    /// allocated until all BufferCollectionToken instances are used to set
498    /// constraints, on both the producer and consumer side. See collection.fidl for
499    /// details.
500    ///
501    /// The following errors will cause the connection to be closed:
502    /// - `buffer_collection_id` is already registered
503    pub fn r#add_buffer_collection2(
504        &self,
505        mut buffer_collection_id: u32,
506        mut buffer_collection_token: fidl::endpoints::ClientEnd<
507            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
508        >,
509    ) -> Result<(), fidl::Error> {
510        self.client.send::<ImagePipe2AddBufferCollection2Request>(
511            (buffer_collection_id, buffer_collection_token),
512            0x181c72c935b0b4ee,
513            fidl::encoding::DynamicFlags::empty(),
514        )
515    }
516
517    pub fn r#add_buffer_collection(
518        &self,
519        mut buffer_collection_id: u32,
520        mut buffer_collection_token: fidl::endpoints::ClientEnd<
521            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
522        >,
523    ) -> Result<(), fidl::Error> {
524        self.client.send::<ImagePipe2AddBufferCollectionRequest>(
525            (buffer_collection_id, buffer_collection_token),
526            0x663ec76e20c87c05,
527            fidl::encoding::DynamicFlags::empty(),
528        )
529    }
530
531    /// Adds an image resource to image pipe.
532    ///
533    /// `buffer_collection_id` refers to the BufferCollectionToken instance that is
534    /// registered via `AddBufferCollection()`. The underlying memory objects allocated
535    /// are used to address to the image data. `buffer_collection_index` refers to the
536    /// index of the memory object allocated in BufferCollection.
537    ///
538    /// `image_format` specifiies image properties. `coded_width` and `coded_height` are
539    /// used to set image dimensions.
540    ///
541    /// It is valid to create multiple images backed by the same memory object; they
542    /// may even overlap.  Consumers must detect this and handle it accordingly.
543    ///
544    /// The following errors will cause the connection to be closed:
545    /// - `image_id` is already registered
546    /// - `buffer_collection_id` refers to an unregistered BufferCollection.
547    /// - `buffer_collection_index` points to a resource index out of the initialized
548    ///     BufferCollection bounds
549    /// - No resource is allocated in the registered BufferCollection.
550    pub fn r#add_image(
551        &self,
552        mut image_id: u32,
553        mut buffer_collection_id: u32,
554        mut buffer_collection_index: u32,
555        mut image_format: &fidl_fuchsia_sysmem::ImageFormat2,
556    ) -> Result<(), fidl::Error> {
557        self.client.send::<ImagePipe2AddImageRequest>(
558            (image_id, buffer_collection_id, buffer_collection_index, image_format),
559            0x23566808b13af395,
560            fidl::encoding::DynamicFlags::empty(),
561        )
562    }
563
564    /// Removes a BufferCollection resource from the pipe.
565    ///
566    /// The `buffer_collection_id` resource is detached as well as all Images that are
567    /// associated with that BufferCollection. Leads to the same results as calling
568    /// `RemoveImage()` on all Images for `buffer_collection_id`.
569    ///
570    /// The producer must wait for all release fences associated with the Images to
571    /// be signaled before freeing or modifying the underlying memory object since
572    /// the image may still be in use in the presentation queue.
573    ///
574    /// The following errors will cause the connection to be closed:
575    /// - `buffer_collection_id` does not reference a currently registered BufferCollection
576    pub fn r#remove_buffer_collection(
577        &self,
578        mut buffer_collection_id: u32,
579    ) -> Result<(), fidl::Error> {
580        self.client.send::<ImagePipe2RemoveBufferCollectionRequest>(
581            (buffer_collection_id,),
582            0x16bebb759a932299,
583            fidl::encoding::DynamicFlags::empty(),
584        )
585    }
586
587    /// Removes an image resource from the pipe.
588    ///
589    /// The `image_id` is detached from the image resource and is free to be
590    /// reused to add a new image resource.
591    ///
592    /// Removing an image from the image pipe does not affect the presentation
593    /// queue or the currently presented image.
594    ///
595    /// The producer must wait for all release fences associated with the image to
596    /// be signaled before freeing or modifying the underlying memory object since
597    /// the image may still be in use in the presentation queue.
598    ///
599    /// The following errors will cause the connection to be closed:
600    /// - `image_id` does not reference a currently registered image resource
601    pub fn r#remove_image(&self, mut image_id: u32) -> Result<(), fidl::Error> {
602        self.client.send::<ImagePipe2RemoveImageRequest>(
603            (image_id,),
604            0x16e8edd0f4d50f68,
605            fidl::encoding::DynamicFlags::empty(),
606        )
607    }
608
609    /// Enqueues the specified image for presentation by the consumer.
610    ///
611    /// The `acquire_fences` are a set of fences which must all be signaled by
612    /// the producer before the consumer presents the image.
613    /// The `release_fences` are a set of fences which inform the producer that
614    /// it's safe to free or modify the `image_id` image, and it's safe to
615    /// re-use the fences in `acquire_fences`. The consumer must signal all the
616    /// fences in `release_fences` after `image_id` is no longer being
617    /// presented. The producer may reuse resources after any of the
618    /// `release_fences` is signaled.
619    ///
620    /// This design allows a producer to distribute image processing across
621    /// multiple threads / processes without unnecessary coordination delay.
622    /// Each thread / process signals its own fence in `acquire_fences` when
623    /// it's done rendering its piece of `image_id`, and waits on its own fence
624    /// in `release_fences` to render new content in `image_id`.
625    ///
626    /// `presentation_time` specifies the time on or after which the
627    /// client would like the enqueued operations should take visible effect
628    /// (light up pixels on the screen), expressed in nanoseconds in the
629    /// `CLOCK_MONOTONIC` timebase.  Desired presentation times must be
630    /// monotonically non-decreasing.
631    ///
632    /// `presentation_info` returns timing information about the submitted frame
633    /// and future frames (see presentation_info.fidl).
634    ///
635    /// The producer may decide not to signal `acquire_fences` for an image.
636    /// In that case, if a later image is enqueued and later image's
637    /// `presentation_time` is reached, the consumer presents the later image when
638    /// later image's `acquire_fences` are signaled. The consumer also signals
639    /// earlier image's `release_fences` and removes it from the presentation queue.
640    /// This sequence works as a cancellation mechanism.
641    ///
642    /// The following errors will cause the connection to be closed:
643    /// - `image_id` does not reference a currently registered image resource
644    pub fn r#present_image(
645        &self,
646        mut image_id: u32,
647        mut presentation_time: u64,
648        mut acquire_fences: Vec<fidl::Event>,
649        mut release_fences: Vec<fidl::Event>,
650        ___deadline: zx::MonotonicInstant,
651    ) -> Result<PresentationInfo, fidl::Error> {
652        let _response = self
653            .client
654            .send_query::<ImagePipe2PresentImageRequest, ImagePipe2PresentImageResponse>(
655                (image_id, presentation_time, acquire_fences.as_mut(), release_fences.as_mut()),
656                0x73cfb50f577c143a,
657                fidl::encoding::DynamicFlags::empty(),
658                ___deadline,
659            )?;
660        Ok(_response.presentation_info)
661    }
662}
663
664#[derive(Debug, Clone)]
665pub struct ImagePipe2Proxy {
666    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
667}
668
669impl fidl::endpoints::Proxy for ImagePipe2Proxy {
670    type Protocol = ImagePipe2Marker;
671
672    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
673        Self::new(inner)
674    }
675
676    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
677        self.client.into_channel().map_err(|client| Self { client })
678    }
679
680    fn as_channel(&self) -> &::fidl::AsyncChannel {
681        self.client.as_channel()
682    }
683}
684
685impl ImagePipe2Proxy {
686    /// Create a new Proxy for fuchsia.images/ImagePipe2.
687    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
688        let protocol_name = <ImagePipe2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
689        Self { client: fidl::client::Client::new(channel, protocol_name) }
690    }
691
692    /// Get a Stream of events from the remote end of the protocol.
693    ///
694    /// # Panics
695    ///
696    /// Panics if the event stream was already taken.
697    pub fn take_event_stream(&self) -> ImagePipe2EventStream {
698        ImagePipe2EventStream { event_receiver: self.client.take_event_receiver() }
699    }
700
701    /// Adds a BufferCollection resource to the image pipe.
702    ///
703    /// The producer is expected to set constraints on this resource for images added
704    /// via `AddImage()`. The consumer can set its constraints on
705    /// `buffer_collection_token` before or after. Note that the buffers won't be
706    /// allocated until all BufferCollectionToken instances are used to set
707    /// constraints, on both the producer and consumer side. See collection.fidl for
708    /// details.
709    ///
710    /// The following errors will cause the connection to be closed:
711    /// - `buffer_collection_id` is already registered
712    pub fn r#add_buffer_collection2(
713        &self,
714        mut buffer_collection_id: u32,
715        mut buffer_collection_token: fidl::endpoints::ClientEnd<
716            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
717        >,
718    ) -> Result<(), fidl::Error> {
719        ImagePipe2ProxyInterface::r#add_buffer_collection2(
720            self,
721            buffer_collection_id,
722            buffer_collection_token,
723        )
724    }
725
726    pub fn r#add_buffer_collection(
727        &self,
728        mut buffer_collection_id: u32,
729        mut buffer_collection_token: fidl::endpoints::ClientEnd<
730            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
731        >,
732    ) -> Result<(), fidl::Error> {
733        ImagePipe2ProxyInterface::r#add_buffer_collection(
734            self,
735            buffer_collection_id,
736            buffer_collection_token,
737        )
738    }
739
740    /// Adds an image resource to image pipe.
741    ///
742    /// `buffer_collection_id` refers to the BufferCollectionToken instance that is
743    /// registered via `AddBufferCollection()`. The underlying memory objects allocated
744    /// are used to address to the image data. `buffer_collection_index` refers to the
745    /// index of the memory object allocated in BufferCollection.
746    ///
747    /// `image_format` specifiies image properties. `coded_width` and `coded_height` are
748    /// used to set image dimensions.
749    ///
750    /// It is valid to create multiple images backed by the same memory object; they
751    /// may even overlap.  Consumers must detect this and handle it accordingly.
752    ///
753    /// The following errors will cause the connection to be closed:
754    /// - `image_id` is already registered
755    /// - `buffer_collection_id` refers to an unregistered BufferCollection.
756    /// - `buffer_collection_index` points to a resource index out of the initialized
757    ///     BufferCollection bounds
758    /// - No resource is allocated in the registered BufferCollection.
759    pub fn r#add_image(
760        &self,
761        mut image_id: u32,
762        mut buffer_collection_id: u32,
763        mut buffer_collection_index: u32,
764        mut image_format: &fidl_fuchsia_sysmem::ImageFormat2,
765    ) -> Result<(), fidl::Error> {
766        ImagePipe2ProxyInterface::r#add_image(
767            self,
768            image_id,
769            buffer_collection_id,
770            buffer_collection_index,
771            image_format,
772        )
773    }
774
775    /// Removes a BufferCollection resource from the pipe.
776    ///
777    /// The `buffer_collection_id` resource is detached as well as all Images that are
778    /// associated with that BufferCollection. Leads to the same results as calling
779    /// `RemoveImage()` on all Images for `buffer_collection_id`.
780    ///
781    /// The producer must wait for all release fences associated with the Images to
782    /// be signaled before freeing or modifying the underlying memory object since
783    /// the image may still be in use in the presentation queue.
784    ///
785    /// The following errors will cause the connection to be closed:
786    /// - `buffer_collection_id` does not reference a currently registered BufferCollection
787    pub fn r#remove_buffer_collection(
788        &self,
789        mut buffer_collection_id: u32,
790    ) -> Result<(), fidl::Error> {
791        ImagePipe2ProxyInterface::r#remove_buffer_collection(self, buffer_collection_id)
792    }
793
794    /// Removes an image resource from the pipe.
795    ///
796    /// The `image_id` is detached from the image resource and is free to be
797    /// reused to add a new image resource.
798    ///
799    /// Removing an image from the image pipe does not affect the presentation
800    /// queue or the currently presented image.
801    ///
802    /// The producer must wait for all release fences associated with the image to
803    /// be signaled before freeing or modifying the underlying memory object since
804    /// the image may still be in use in the presentation queue.
805    ///
806    /// The following errors will cause the connection to be closed:
807    /// - `image_id` does not reference a currently registered image resource
808    pub fn r#remove_image(&self, mut image_id: u32) -> Result<(), fidl::Error> {
809        ImagePipe2ProxyInterface::r#remove_image(self, image_id)
810    }
811
812    /// Enqueues the specified image for presentation by the consumer.
813    ///
814    /// The `acquire_fences` are a set of fences which must all be signaled by
815    /// the producer before the consumer presents the image.
816    /// The `release_fences` are a set of fences which inform the producer that
817    /// it's safe to free or modify the `image_id` image, and it's safe to
818    /// re-use the fences in `acquire_fences`. The consumer must signal all the
819    /// fences in `release_fences` after `image_id` is no longer being
820    /// presented. The producer may reuse resources after any of the
821    /// `release_fences` is signaled.
822    ///
823    /// This design allows a producer to distribute image processing across
824    /// multiple threads / processes without unnecessary coordination delay.
825    /// Each thread / process signals its own fence in `acquire_fences` when
826    /// it's done rendering its piece of `image_id`, and waits on its own fence
827    /// in `release_fences` to render new content in `image_id`.
828    ///
829    /// `presentation_time` specifies the time on or after which the
830    /// client would like the enqueued operations should take visible effect
831    /// (light up pixels on the screen), expressed in nanoseconds in the
832    /// `CLOCK_MONOTONIC` timebase.  Desired presentation times must be
833    /// monotonically non-decreasing.
834    ///
835    /// `presentation_info` returns timing information about the submitted frame
836    /// and future frames (see presentation_info.fidl).
837    ///
838    /// The producer may decide not to signal `acquire_fences` for an image.
839    /// In that case, if a later image is enqueued and later image's
840    /// `presentation_time` is reached, the consumer presents the later image when
841    /// later image's `acquire_fences` are signaled. The consumer also signals
842    /// earlier image's `release_fences` and removes it from the presentation queue.
843    /// This sequence works as a cancellation mechanism.
844    ///
845    /// The following errors will cause the connection to be closed:
846    /// - `image_id` does not reference a currently registered image resource
847    pub fn r#present_image(
848        &self,
849        mut image_id: u32,
850        mut presentation_time: u64,
851        mut acquire_fences: Vec<fidl::Event>,
852        mut release_fences: Vec<fidl::Event>,
853    ) -> fidl::client::QueryResponseFut<
854        PresentationInfo,
855        fidl::encoding::DefaultFuchsiaResourceDialect,
856    > {
857        ImagePipe2ProxyInterface::r#present_image(
858            self,
859            image_id,
860            presentation_time,
861            acquire_fences,
862            release_fences,
863        )
864    }
865}
866
867impl ImagePipe2ProxyInterface for ImagePipe2Proxy {
868    fn r#add_buffer_collection2(
869        &self,
870        mut buffer_collection_id: u32,
871        mut buffer_collection_token: fidl::endpoints::ClientEnd<
872            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
873        >,
874    ) -> Result<(), fidl::Error> {
875        self.client.send::<ImagePipe2AddBufferCollection2Request>(
876            (buffer_collection_id, buffer_collection_token),
877            0x181c72c935b0b4ee,
878            fidl::encoding::DynamicFlags::empty(),
879        )
880    }
881
882    fn r#add_buffer_collection(
883        &self,
884        mut buffer_collection_id: u32,
885        mut buffer_collection_token: fidl::endpoints::ClientEnd<
886            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
887        >,
888    ) -> Result<(), fidl::Error> {
889        self.client.send::<ImagePipe2AddBufferCollectionRequest>(
890            (buffer_collection_id, buffer_collection_token),
891            0x663ec76e20c87c05,
892            fidl::encoding::DynamicFlags::empty(),
893        )
894    }
895
896    fn r#add_image(
897        &self,
898        mut image_id: u32,
899        mut buffer_collection_id: u32,
900        mut buffer_collection_index: u32,
901        mut image_format: &fidl_fuchsia_sysmem::ImageFormat2,
902    ) -> Result<(), fidl::Error> {
903        self.client.send::<ImagePipe2AddImageRequest>(
904            (image_id, buffer_collection_id, buffer_collection_index, image_format),
905            0x23566808b13af395,
906            fidl::encoding::DynamicFlags::empty(),
907        )
908    }
909
910    fn r#remove_buffer_collection(&self, mut buffer_collection_id: u32) -> Result<(), fidl::Error> {
911        self.client.send::<ImagePipe2RemoveBufferCollectionRequest>(
912            (buffer_collection_id,),
913            0x16bebb759a932299,
914            fidl::encoding::DynamicFlags::empty(),
915        )
916    }
917
918    fn r#remove_image(&self, mut image_id: u32) -> Result<(), fidl::Error> {
919        self.client.send::<ImagePipe2RemoveImageRequest>(
920            (image_id,),
921            0x16e8edd0f4d50f68,
922            fidl::encoding::DynamicFlags::empty(),
923        )
924    }
925
926    type PresentImageResponseFut = fidl::client::QueryResponseFut<
927        PresentationInfo,
928        fidl::encoding::DefaultFuchsiaResourceDialect,
929    >;
930    fn r#present_image(
931        &self,
932        mut image_id: u32,
933        mut presentation_time: u64,
934        mut acquire_fences: Vec<fidl::Event>,
935        mut release_fences: Vec<fidl::Event>,
936    ) -> Self::PresentImageResponseFut {
937        fn _decode(
938            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
939        ) -> Result<PresentationInfo, fidl::Error> {
940            let _response = fidl::client::decode_transaction_body::<
941                ImagePipe2PresentImageResponse,
942                fidl::encoding::DefaultFuchsiaResourceDialect,
943                0x73cfb50f577c143a,
944            >(_buf?)?;
945            Ok(_response.presentation_info)
946        }
947        self.client.send_query_and_decode::<ImagePipe2PresentImageRequest, PresentationInfo>(
948            (image_id, presentation_time, acquire_fences.as_mut(), release_fences.as_mut()),
949            0x73cfb50f577c143a,
950            fidl::encoding::DynamicFlags::empty(),
951            _decode,
952        )
953    }
954}
955
956pub struct ImagePipe2EventStream {
957    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
958}
959
960impl std::marker::Unpin for ImagePipe2EventStream {}
961
962impl futures::stream::FusedStream for ImagePipe2EventStream {
963    fn is_terminated(&self) -> bool {
964        self.event_receiver.is_terminated()
965    }
966}
967
968impl futures::Stream for ImagePipe2EventStream {
969    type Item = Result<ImagePipe2Event, fidl::Error>;
970
971    fn poll_next(
972        mut self: std::pin::Pin<&mut Self>,
973        cx: &mut std::task::Context<'_>,
974    ) -> std::task::Poll<Option<Self::Item>> {
975        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
976            &mut self.event_receiver,
977            cx
978        )?) {
979            Some(buf) => std::task::Poll::Ready(Some(ImagePipe2Event::decode(buf))),
980            None => std::task::Poll::Ready(None),
981        }
982    }
983}
984
985#[derive(Debug)]
986pub enum ImagePipe2Event {}
987
988impl ImagePipe2Event {
989    /// Decodes a message buffer as a [`ImagePipe2Event`].
990    fn decode(
991        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
992    ) -> Result<ImagePipe2Event, fidl::Error> {
993        let (bytes, _handles) = buf.split_mut();
994        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
995        debug_assert_eq!(tx_header.tx_id, 0);
996        match tx_header.ordinal {
997            _ => Err(fidl::Error::UnknownOrdinal {
998                ordinal: tx_header.ordinal,
999                protocol_name: <ImagePipe2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1000            }),
1001        }
1002    }
1003}
1004
1005/// A Stream of incoming requests for fuchsia.images/ImagePipe2.
1006pub struct ImagePipe2RequestStream {
1007    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1008    is_terminated: bool,
1009}
1010
1011impl std::marker::Unpin for ImagePipe2RequestStream {}
1012
1013impl futures::stream::FusedStream for ImagePipe2RequestStream {
1014    fn is_terminated(&self) -> bool {
1015        self.is_terminated
1016    }
1017}
1018
1019impl fidl::endpoints::RequestStream for ImagePipe2RequestStream {
1020    type Protocol = ImagePipe2Marker;
1021    type ControlHandle = ImagePipe2ControlHandle;
1022
1023    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1024        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1025    }
1026
1027    fn control_handle(&self) -> Self::ControlHandle {
1028        ImagePipe2ControlHandle { inner: self.inner.clone() }
1029    }
1030
1031    fn into_inner(
1032        self,
1033    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1034    {
1035        (self.inner, self.is_terminated)
1036    }
1037
1038    fn from_inner(
1039        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1040        is_terminated: bool,
1041    ) -> Self {
1042        Self { inner, is_terminated }
1043    }
1044}
1045
1046impl futures::Stream for ImagePipe2RequestStream {
1047    type Item = Result<ImagePipe2Request, fidl::Error>;
1048
1049    fn poll_next(
1050        mut self: std::pin::Pin<&mut Self>,
1051        cx: &mut std::task::Context<'_>,
1052    ) -> std::task::Poll<Option<Self::Item>> {
1053        let this = &mut *self;
1054        if this.inner.check_shutdown(cx) {
1055            this.is_terminated = true;
1056            return std::task::Poll::Ready(None);
1057        }
1058        if this.is_terminated {
1059            panic!("polled ImagePipe2RequestStream after completion");
1060        }
1061        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1062            |bytes, handles| {
1063                match this.inner.channel().read_etc(cx, bytes, handles) {
1064                    std::task::Poll::Ready(Ok(())) => {}
1065                    std::task::Poll::Pending => return std::task::Poll::Pending,
1066                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1067                        this.is_terminated = true;
1068                        return std::task::Poll::Ready(None);
1069                    }
1070                    std::task::Poll::Ready(Err(e)) => {
1071                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1072                            e.into(),
1073                        ))))
1074                    }
1075                }
1076
1077                // A message has been received from the channel
1078                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1079
1080                std::task::Poll::Ready(Some(match header.ordinal {
1081                    0x181c72c935b0b4ee => {
1082                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1083                        let mut req = fidl::new_empty!(
1084                            ImagePipe2AddBufferCollection2Request,
1085                            fidl::encoding::DefaultFuchsiaResourceDialect
1086                        );
1087                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ImagePipe2AddBufferCollection2Request>(&header, _body_bytes, handles, &mut req)?;
1088                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
1089                        Ok(ImagePipe2Request::AddBufferCollection2 {
1090                            buffer_collection_id: req.buffer_collection_id,
1091                            buffer_collection_token: req.buffer_collection_token,
1092
1093                            control_handle,
1094                        })
1095                    }
1096                    0x663ec76e20c87c05 => {
1097                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1098                        let mut req = fidl::new_empty!(
1099                            ImagePipe2AddBufferCollectionRequest,
1100                            fidl::encoding::DefaultFuchsiaResourceDialect
1101                        );
1102                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ImagePipe2AddBufferCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
1103                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
1104                        Ok(ImagePipe2Request::AddBufferCollection {
1105                            buffer_collection_id: req.buffer_collection_id,
1106                            buffer_collection_token: req.buffer_collection_token,
1107
1108                            control_handle,
1109                        })
1110                    }
1111                    0x23566808b13af395 => {
1112                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1113                        let mut req = fidl::new_empty!(
1114                            ImagePipe2AddImageRequest,
1115                            fidl::encoding::DefaultFuchsiaResourceDialect
1116                        );
1117                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ImagePipe2AddImageRequest>(&header, _body_bytes, handles, &mut req)?;
1118                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
1119                        Ok(ImagePipe2Request::AddImage {
1120                            image_id: req.image_id,
1121                            buffer_collection_id: req.buffer_collection_id,
1122                            buffer_collection_index: req.buffer_collection_index,
1123                            image_format: req.image_format,
1124
1125                            control_handle,
1126                        })
1127                    }
1128                    0x16bebb759a932299 => {
1129                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1130                        let mut req = fidl::new_empty!(
1131                            ImagePipe2RemoveBufferCollectionRequest,
1132                            fidl::encoding::DefaultFuchsiaResourceDialect
1133                        );
1134                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ImagePipe2RemoveBufferCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
1135                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
1136                        Ok(ImagePipe2Request::RemoveBufferCollection {
1137                            buffer_collection_id: req.buffer_collection_id,
1138
1139                            control_handle,
1140                        })
1141                    }
1142                    0x16e8edd0f4d50f68 => {
1143                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1144                        let mut req = fidl::new_empty!(
1145                            ImagePipe2RemoveImageRequest,
1146                            fidl::encoding::DefaultFuchsiaResourceDialect
1147                        );
1148                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ImagePipe2RemoveImageRequest>(&header, _body_bytes, handles, &mut req)?;
1149                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
1150                        Ok(ImagePipe2Request::RemoveImage {
1151                            image_id: req.image_id,
1152
1153                            control_handle,
1154                        })
1155                    }
1156                    0x73cfb50f577c143a => {
1157                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1158                        let mut req = fidl::new_empty!(
1159                            ImagePipe2PresentImageRequest,
1160                            fidl::encoding::DefaultFuchsiaResourceDialect
1161                        );
1162                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ImagePipe2PresentImageRequest>(&header, _body_bytes, handles, &mut req)?;
1163                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
1164                        Ok(ImagePipe2Request::PresentImage {
1165                            image_id: req.image_id,
1166                            presentation_time: req.presentation_time,
1167                            acquire_fences: req.acquire_fences,
1168                            release_fences: req.release_fences,
1169
1170                            responder: ImagePipe2PresentImageResponder {
1171                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1172                                tx_id: header.tx_id,
1173                            },
1174                        })
1175                    }
1176                    _ => Err(fidl::Error::UnknownOrdinal {
1177                        ordinal: header.ordinal,
1178                        protocol_name:
1179                            <ImagePipe2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1180                    }),
1181                }))
1182            },
1183        )
1184    }
1185}
1186
1187/// ImagePipe is a mechanism for streaming shared images between a producer
1188/// and a consumer which may be running in different processes.
1189///
1190/// Conceptually, the image pipe maintains a table of image resources supplied
1191/// by the producer into which graphical content may be stored as well as a
1192/// presentation queue containing a sequence of images which the producer has
1193/// asked the consumer to present.
1194///
1195/// The presentation queue is initially empty.
1196///
1197/// Each entry in the presentation queue consists of an image together with a
1198/// pair of optional synchronization fences:
1199/// - Acquire fence: signaled by the producer when the image is ready to be consumed
1200/// - Release fence: signaled by the consumer when the image is free to be freed or
1201///   modified by the producer
1202///
1203/// The producer performs the following sequence of steps to present content:
1204/// - Allocate and add some number of BufferCollections to the image pipe to allow
1205/// consumer to set constraints.
1206/// - Allocate and add some number of images (often 2 or 3) to the image pipe
1207///   to establish a pool using `AddImage()`.
1208/// - Obtain the next available image from the pool.
1209/// - Ask the consumer to enqueue an image for presentation and provide fences
1210///   using `PresentImage()`.
1211/// - Start rendering the image.
1212/// - Signal the image's acquire fence when rendering is complete.
1213/// - Loop to present more image, listen for signals on release fences to recycle
1214///   images back into the pool.
1215///
1216/// The consumer performs the following sequence of steps for each image which
1217/// is enqueued in the presentation queue:
1218/// - Await signals on the image's acquire fence.
1219/// - If the fence wait cannot be satisfied or if some other error is detected,
1220///   close the image pipe.
1221///   Otherwise, begin presenting the image's content.
1222/// - Retire the previously presented image (if any) from the presentation queue
1223///   and signal its release fence when no longer needed.
1224/// - Continue presenting the same image until the next one is ready.  Loop.
1225///
1226/// If the producer wants to close the image pipe, it should:
1227/// - Close its side of the connection.
1228/// - Wait on all release fences for buffers that it has submitted with
1229///   `PresentImage()`.
1230/// - Proceed with resource cleanup.
1231///
1232/// When the consumer detects the image pipe has closed, it should:
1233/// - Stop using/presenting any images from the pipe.
1234/// - Unmap all memory objects associated with the images in the pipe.
1235/// - Close all BufferCollection resources.
1236/// - Signal all release fences for presented and queued buffers.
1237/// - Close all handles to fences.
1238/// - Close its side of the connection.
1239///
1240/// When either party detects that a fence has been abandoned (remotely closed
1241/// without being signaled) it should assume that the associated image is in
1242/// an indeterminate state.  This will typically happen when the other party
1243/// (or one of its delegates) has crashed.  The safest course of action is to
1244/// close the image pipe, release all resources which were shared with the
1245/// other party, and re-establish the connection to recover.
1246#[derive(Debug)]
1247pub enum ImagePipe2Request {
1248    /// Adds a BufferCollection resource to the image pipe.
1249    ///
1250    /// The producer is expected to set constraints on this resource for images added
1251    /// via `AddImage()`. The consumer can set its constraints on
1252    /// `buffer_collection_token` before or after. Note that the buffers won't be
1253    /// allocated until all BufferCollectionToken instances are used to set
1254    /// constraints, on both the producer and consumer side. See collection.fidl for
1255    /// details.
1256    ///
1257    /// The following errors will cause the connection to be closed:
1258    /// - `buffer_collection_id` is already registered
1259    AddBufferCollection2 {
1260        buffer_collection_id: u32,
1261        buffer_collection_token:
1262            fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
1263        control_handle: ImagePipe2ControlHandle,
1264    },
1265    AddBufferCollection {
1266        buffer_collection_id: u32,
1267        buffer_collection_token:
1268            fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
1269        control_handle: ImagePipe2ControlHandle,
1270    },
1271    /// Adds an image resource to image pipe.
1272    ///
1273    /// `buffer_collection_id` refers to the BufferCollectionToken instance that is
1274    /// registered via `AddBufferCollection()`. The underlying memory objects allocated
1275    /// are used to address to the image data. `buffer_collection_index` refers to the
1276    /// index of the memory object allocated in BufferCollection.
1277    ///
1278    /// `image_format` specifiies image properties. `coded_width` and `coded_height` are
1279    /// used to set image dimensions.
1280    ///
1281    /// It is valid to create multiple images backed by the same memory object; they
1282    /// may even overlap.  Consumers must detect this and handle it accordingly.
1283    ///
1284    /// The following errors will cause the connection to be closed:
1285    /// - `image_id` is already registered
1286    /// - `buffer_collection_id` refers to an unregistered BufferCollection.
1287    /// - `buffer_collection_index` points to a resource index out of the initialized
1288    ///     BufferCollection bounds
1289    /// - No resource is allocated in the registered BufferCollection.
1290    AddImage {
1291        image_id: u32,
1292        buffer_collection_id: u32,
1293        buffer_collection_index: u32,
1294        image_format: fidl_fuchsia_sysmem::ImageFormat2,
1295        control_handle: ImagePipe2ControlHandle,
1296    },
1297    /// Removes a BufferCollection resource from the pipe.
1298    ///
1299    /// The `buffer_collection_id` resource is detached as well as all Images that are
1300    /// associated with that BufferCollection. Leads to the same results as calling
1301    /// `RemoveImage()` on all Images for `buffer_collection_id`.
1302    ///
1303    /// The producer must wait for all release fences associated with the Images to
1304    /// be signaled before freeing or modifying the underlying memory object since
1305    /// the image may still be in use in the presentation queue.
1306    ///
1307    /// The following errors will cause the connection to be closed:
1308    /// - `buffer_collection_id` does not reference a currently registered BufferCollection
1309    RemoveBufferCollection { buffer_collection_id: u32, control_handle: ImagePipe2ControlHandle },
1310    /// Removes an image resource from the pipe.
1311    ///
1312    /// The `image_id` is detached from the image resource and is free to be
1313    /// reused to add a new image resource.
1314    ///
1315    /// Removing an image from the image pipe does not affect the presentation
1316    /// queue or the currently presented image.
1317    ///
1318    /// The producer must wait for all release fences associated with the image to
1319    /// be signaled before freeing or modifying the underlying memory object since
1320    /// the image may still be in use in the presentation queue.
1321    ///
1322    /// The following errors will cause the connection to be closed:
1323    /// - `image_id` does not reference a currently registered image resource
1324    RemoveImage { image_id: u32, control_handle: ImagePipe2ControlHandle },
1325    /// Enqueues the specified image for presentation by the consumer.
1326    ///
1327    /// The `acquire_fences` are a set of fences which must all be signaled by
1328    /// the producer before the consumer presents the image.
1329    /// The `release_fences` are a set of fences which inform the producer that
1330    /// it's safe to free or modify the `image_id` image, and it's safe to
1331    /// re-use the fences in `acquire_fences`. The consumer must signal all the
1332    /// fences in `release_fences` after `image_id` is no longer being
1333    /// presented. The producer may reuse resources after any of the
1334    /// `release_fences` is signaled.
1335    ///
1336    /// This design allows a producer to distribute image processing across
1337    /// multiple threads / processes without unnecessary coordination delay.
1338    /// Each thread / process signals its own fence in `acquire_fences` when
1339    /// it's done rendering its piece of `image_id`, and waits on its own fence
1340    /// in `release_fences` to render new content in `image_id`.
1341    ///
1342    /// `presentation_time` specifies the time on or after which the
1343    /// client would like the enqueued operations should take visible effect
1344    /// (light up pixels on the screen), expressed in nanoseconds in the
1345    /// `CLOCK_MONOTONIC` timebase.  Desired presentation times must be
1346    /// monotonically non-decreasing.
1347    ///
1348    /// `presentation_info` returns timing information about the submitted frame
1349    /// and future frames (see presentation_info.fidl).
1350    ///
1351    /// The producer may decide not to signal `acquire_fences` for an image.
1352    /// In that case, if a later image is enqueued and later image's
1353    /// `presentation_time` is reached, the consumer presents the later image when
1354    /// later image's `acquire_fences` are signaled. The consumer also signals
1355    /// earlier image's `release_fences` and removes it from the presentation queue.
1356    /// This sequence works as a cancellation mechanism.
1357    ///
1358    /// The following errors will cause the connection to be closed:
1359    /// - `image_id` does not reference a currently registered image resource
1360    PresentImage {
1361        image_id: u32,
1362        presentation_time: u64,
1363        acquire_fences: Vec<fidl::Event>,
1364        release_fences: Vec<fidl::Event>,
1365        responder: ImagePipe2PresentImageResponder,
1366    },
1367}
1368
1369impl ImagePipe2Request {
1370    #[allow(irrefutable_let_patterns)]
1371    pub fn into_add_buffer_collection2(
1372        self,
1373    ) -> Option<(
1374        u32,
1375        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
1376        ImagePipe2ControlHandle,
1377    )> {
1378        if let ImagePipe2Request::AddBufferCollection2 {
1379            buffer_collection_id,
1380            buffer_collection_token,
1381            control_handle,
1382        } = self
1383        {
1384            Some((buffer_collection_id, buffer_collection_token, control_handle))
1385        } else {
1386            None
1387        }
1388    }
1389
1390    #[allow(irrefutable_let_patterns)]
1391    pub fn into_add_buffer_collection(
1392        self,
1393    ) -> Option<(
1394        u32,
1395        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
1396        ImagePipe2ControlHandle,
1397    )> {
1398        if let ImagePipe2Request::AddBufferCollection {
1399            buffer_collection_id,
1400            buffer_collection_token,
1401            control_handle,
1402        } = self
1403        {
1404            Some((buffer_collection_id, buffer_collection_token, control_handle))
1405        } else {
1406            None
1407        }
1408    }
1409
1410    #[allow(irrefutable_let_patterns)]
1411    pub fn into_add_image(
1412        self,
1413    ) -> Option<(u32, u32, u32, fidl_fuchsia_sysmem::ImageFormat2, ImagePipe2ControlHandle)> {
1414        if let ImagePipe2Request::AddImage {
1415            image_id,
1416            buffer_collection_id,
1417            buffer_collection_index,
1418            image_format,
1419            control_handle,
1420        } = self
1421        {
1422            Some((
1423                image_id,
1424                buffer_collection_id,
1425                buffer_collection_index,
1426                image_format,
1427                control_handle,
1428            ))
1429        } else {
1430            None
1431        }
1432    }
1433
1434    #[allow(irrefutable_let_patterns)]
1435    pub fn into_remove_buffer_collection(self) -> Option<(u32, ImagePipe2ControlHandle)> {
1436        if let ImagePipe2Request::RemoveBufferCollection { buffer_collection_id, control_handle } =
1437            self
1438        {
1439            Some((buffer_collection_id, control_handle))
1440        } else {
1441            None
1442        }
1443    }
1444
1445    #[allow(irrefutable_let_patterns)]
1446    pub fn into_remove_image(self) -> Option<(u32, ImagePipe2ControlHandle)> {
1447        if let ImagePipe2Request::RemoveImage { image_id, control_handle } = self {
1448            Some((image_id, control_handle))
1449        } else {
1450            None
1451        }
1452    }
1453
1454    #[allow(irrefutable_let_patterns)]
1455    pub fn into_present_image(
1456        self,
1457    ) -> Option<(u32, u64, Vec<fidl::Event>, Vec<fidl::Event>, ImagePipe2PresentImageResponder)>
1458    {
1459        if let ImagePipe2Request::PresentImage {
1460            image_id,
1461            presentation_time,
1462            acquire_fences,
1463            release_fences,
1464            responder,
1465        } = self
1466        {
1467            Some((image_id, presentation_time, acquire_fences, release_fences, responder))
1468        } else {
1469            None
1470        }
1471    }
1472
1473    /// Name of the method defined in FIDL
1474    pub fn method_name(&self) -> &'static str {
1475        match *self {
1476            ImagePipe2Request::AddBufferCollection2 { .. } => "add_buffer_collection2",
1477            ImagePipe2Request::AddBufferCollection { .. } => "add_buffer_collection",
1478            ImagePipe2Request::AddImage { .. } => "add_image",
1479            ImagePipe2Request::RemoveBufferCollection { .. } => "remove_buffer_collection",
1480            ImagePipe2Request::RemoveImage { .. } => "remove_image",
1481            ImagePipe2Request::PresentImage { .. } => "present_image",
1482        }
1483    }
1484}
1485
1486#[derive(Debug, Clone)]
1487pub struct ImagePipe2ControlHandle {
1488    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1489}
1490
1491impl fidl::endpoints::ControlHandle for ImagePipe2ControlHandle {
1492    fn shutdown(&self) {
1493        self.inner.shutdown()
1494    }
1495    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1496        self.inner.shutdown_with_epitaph(status)
1497    }
1498
1499    fn is_closed(&self) -> bool {
1500        self.inner.channel().is_closed()
1501    }
1502    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1503        self.inner.channel().on_closed()
1504    }
1505
1506    #[cfg(target_os = "fuchsia")]
1507    fn signal_peer(
1508        &self,
1509        clear_mask: zx::Signals,
1510        set_mask: zx::Signals,
1511    ) -> Result<(), zx_status::Status> {
1512        use fidl::Peered;
1513        self.inner.channel().signal_peer(clear_mask, set_mask)
1514    }
1515}
1516
1517impl ImagePipe2ControlHandle {}
1518
1519#[must_use = "FIDL methods require a response to be sent"]
1520#[derive(Debug)]
1521pub struct ImagePipe2PresentImageResponder {
1522    control_handle: std::mem::ManuallyDrop<ImagePipe2ControlHandle>,
1523    tx_id: u32,
1524}
1525
1526/// Set the the channel to be shutdown (see [`ImagePipe2ControlHandle::shutdown`])
1527/// if the responder is dropped without sending a response, so that the client
1528/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1529impl std::ops::Drop for ImagePipe2PresentImageResponder {
1530    fn drop(&mut self) {
1531        self.control_handle.shutdown();
1532        // Safety: drops once, never accessed again
1533        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1534    }
1535}
1536
1537impl fidl::endpoints::Responder for ImagePipe2PresentImageResponder {
1538    type ControlHandle = ImagePipe2ControlHandle;
1539
1540    fn control_handle(&self) -> &ImagePipe2ControlHandle {
1541        &self.control_handle
1542    }
1543
1544    fn drop_without_shutdown(mut self) {
1545        // Safety: drops once, never accessed again due to mem::forget
1546        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1547        // Prevent Drop from running (which would shut down the channel)
1548        std::mem::forget(self);
1549    }
1550}
1551
1552impl ImagePipe2PresentImageResponder {
1553    /// Sends a response to the FIDL transaction.
1554    ///
1555    /// Sets the channel to shutdown if an error occurs.
1556    pub fn send(self, mut presentation_info: &PresentationInfo) -> Result<(), fidl::Error> {
1557        let _result = self.send_raw(presentation_info);
1558        if _result.is_err() {
1559            self.control_handle.shutdown();
1560        }
1561        self.drop_without_shutdown();
1562        _result
1563    }
1564
1565    /// Similar to "send" but does not shutdown the channel if an error occurs.
1566    pub fn send_no_shutdown_on_err(
1567        self,
1568        mut presentation_info: &PresentationInfo,
1569    ) -> Result<(), fidl::Error> {
1570        let _result = self.send_raw(presentation_info);
1571        self.drop_without_shutdown();
1572        _result
1573    }
1574
1575    fn send_raw(&self, mut presentation_info: &PresentationInfo) -> Result<(), fidl::Error> {
1576        self.control_handle.inner.send::<ImagePipe2PresentImageResponse>(
1577            (presentation_info,),
1578            self.tx_id,
1579            0x73cfb50f577c143a,
1580            fidl::encoding::DynamicFlags::empty(),
1581        )
1582    }
1583}
1584
1585mod internal {
1586    use super::*;
1587    unsafe impl fidl::encoding::TypeMarker for AlphaFormat {
1588        type Owned = Self;
1589
1590        #[inline(always)]
1591        fn inline_align(_context: fidl::encoding::Context) -> usize {
1592            std::mem::align_of::<u32>()
1593        }
1594
1595        #[inline(always)]
1596        fn inline_size(_context: fidl::encoding::Context) -> usize {
1597            std::mem::size_of::<u32>()
1598        }
1599
1600        #[inline(always)]
1601        fn encode_is_copy() -> bool {
1602            true
1603        }
1604
1605        #[inline(always)]
1606        fn decode_is_copy() -> bool {
1607            false
1608        }
1609    }
1610
1611    impl fidl::encoding::ValueTypeMarker for AlphaFormat {
1612        type Borrowed<'a> = Self;
1613        #[inline(always)]
1614        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1615            *value
1616        }
1617    }
1618
1619    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for AlphaFormat {
1620        #[inline]
1621        unsafe fn encode(
1622            self,
1623            encoder: &mut fidl::encoding::Encoder<'_, D>,
1624            offset: usize,
1625            _depth: fidl::encoding::Depth,
1626        ) -> fidl::Result<()> {
1627            encoder.debug_check_bounds::<Self>(offset);
1628            encoder.write_num(self.into_primitive(), offset);
1629            Ok(())
1630        }
1631    }
1632
1633    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AlphaFormat {
1634        #[inline(always)]
1635        fn new_empty() -> Self {
1636            Self::Opaque
1637        }
1638
1639        #[inline]
1640        unsafe fn decode(
1641            &mut self,
1642            decoder: &mut fidl::encoding::Decoder<'_, D>,
1643            offset: usize,
1644            _depth: fidl::encoding::Depth,
1645        ) -> fidl::Result<()> {
1646            decoder.debug_check_bounds::<Self>(offset);
1647            let prim = decoder.read_num::<u32>(offset);
1648
1649            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1650            Ok(())
1651        }
1652    }
1653    unsafe impl fidl::encoding::TypeMarker for ColorSpace {
1654        type Owned = Self;
1655
1656        #[inline(always)]
1657        fn inline_align(_context: fidl::encoding::Context) -> usize {
1658            std::mem::align_of::<u32>()
1659        }
1660
1661        #[inline(always)]
1662        fn inline_size(_context: fidl::encoding::Context) -> usize {
1663            std::mem::size_of::<u32>()
1664        }
1665
1666        #[inline(always)]
1667        fn encode_is_copy() -> bool {
1668            true
1669        }
1670
1671        #[inline(always)]
1672        fn decode_is_copy() -> bool {
1673            false
1674        }
1675    }
1676
1677    impl fidl::encoding::ValueTypeMarker for ColorSpace {
1678        type Borrowed<'a> = Self;
1679        #[inline(always)]
1680        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1681            *value
1682        }
1683    }
1684
1685    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ColorSpace {
1686        #[inline]
1687        unsafe fn encode(
1688            self,
1689            encoder: &mut fidl::encoding::Encoder<'_, D>,
1690            offset: usize,
1691            _depth: fidl::encoding::Depth,
1692        ) -> fidl::Result<()> {
1693            encoder.debug_check_bounds::<Self>(offset);
1694            encoder.write_num(self.into_primitive(), offset);
1695            Ok(())
1696        }
1697    }
1698
1699    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ColorSpace {
1700        #[inline(always)]
1701        fn new_empty() -> Self {
1702            Self::Srgb
1703        }
1704
1705        #[inline]
1706        unsafe fn decode(
1707            &mut self,
1708            decoder: &mut fidl::encoding::Decoder<'_, D>,
1709            offset: usize,
1710            _depth: fidl::encoding::Depth,
1711        ) -> fidl::Result<()> {
1712            decoder.debug_check_bounds::<Self>(offset);
1713            let prim = decoder.read_num::<u32>(offset);
1714
1715            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1716            Ok(())
1717        }
1718    }
1719    unsafe impl fidl::encoding::TypeMarker for MemoryType {
1720        type Owned = Self;
1721
1722        #[inline(always)]
1723        fn inline_align(_context: fidl::encoding::Context) -> usize {
1724            std::mem::align_of::<u32>()
1725        }
1726
1727        #[inline(always)]
1728        fn inline_size(_context: fidl::encoding::Context) -> usize {
1729            std::mem::size_of::<u32>()
1730        }
1731
1732        #[inline(always)]
1733        fn encode_is_copy() -> bool {
1734            true
1735        }
1736
1737        #[inline(always)]
1738        fn decode_is_copy() -> bool {
1739            false
1740        }
1741    }
1742
1743    impl fidl::encoding::ValueTypeMarker for MemoryType {
1744        type Borrowed<'a> = Self;
1745        #[inline(always)]
1746        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1747            *value
1748        }
1749    }
1750
1751    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for MemoryType {
1752        #[inline]
1753        unsafe fn encode(
1754            self,
1755            encoder: &mut fidl::encoding::Encoder<'_, D>,
1756            offset: usize,
1757            _depth: fidl::encoding::Depth,
1758        ) -> fidl::Result<()> {
1759            encoder.debug_check_bounds::<Self>(offset);
1760            encoder.write_num(self.into_primitive(), offset);
1761            Ok(())
1762        }
1763    }
1764
1765    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MemoryType {
1766        #[inline(always)]
1767        fn new_empty() -> Self {
1768            Self::HostMemory
1769        }
1770
1771        #[inline]
1772        unsafe fn decode(
1773            &mut self,
1774            decoder: &mut fidl::encoding::Decoder<'_, D>,
1775            offset: usize,
1776            _depth: fidl::encoding::Depth,
1777        ) -> fidl::Result<()> {
1778            decoder.debug_check_bounds::<Self>(offset);
1779            let prim = decoder.read_num::<u32>(offset);
1780
1781            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1782            Ok(())
1783        }
1784    }
1785    unsafe impl fidl::encoding::TypeMarker for PixelFormat {
1786        type Owned = Self;
1787
1788        #[inline(always)]
1789        fn inline_align(_context: fidl::encoding::Context) -> usize {
1790            std::mem::align_of::<u32>()
1791        }
1792
1793        #[inline(always)]
1794        fn inline_size(_context: fidl::encoding::Context) -> usize {
1795            std::mem::size_of::<u32>()
1796        }
1797
1798        #[inline(always)]
1799        fn encode_is_copy() -> bool {
1800            true
1801        }
1802
1803        #[inline(always)]
1804        fn decode_is_copy() -> bool {
1805            false
1806        }
1807    }
1808
1809    impl fidl::encoding::ValueTypeMarker for PixelFormat {
1810        type Borrowed<'a> = Self;
1811        #[inline(always)]
1812        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1813            *value
1814        }
1815    }
1816
1817    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for PixelFormat {
1818        #[inline]
1819        unsafe fn encode(
1820            self,
1821            encoder: &mut fidl::encoding::Encoder<'_, D>,
1822            offset: usize,
1823            _depth: fidl::encoding::Depth,
1824        ) -> fidl::Result<()> {
1825            encoder.debug_check_bounds::<Self>(offset);
1826            encoder.write_num(self.into_primitive(), offset);
1827            Ok(())
1828        }
1829    }
1830
1831    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PixelFormat {
1832        #[inline(always)]
1833        fn new_empty() -> Self {
1834            Self::Bgra8
1835        }
1836
1837        #[inline]
1838        unsafe fn decode(
1839            &mut self,
1840            decoder: &mut fidl::encoding::Decoder<'_, D>,
1841            offset: usize,
1842            _depth: fidl::encoding::Depth,
1843        ) -> fidl::Result<()> {
1844            decoder.debug_check_bounds::<Self>(offset);
1845            let prim = decoder.read_num::<u32>(offset);
1846
1847            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1848            Ok(())
1849        }
1850    }
1851    unsafe impl fidl::encoding::TypeMarker for Tiling {
1852        type Owned = Self;
1853
1854        #[inline(always)]
1855        fn inline_align(_context: fidl::encoding::Context) -> usize {
1856            std::mem::align_of::<u32>()
1857        }
1858
1859        #[inline(always)]
1860        fn inline_size(_context: fidl::encoding::Context) -> usize {
1861            std::mem::size_of::<u32>()
1862        }
1863
1864        #[inline(always)]
1865        fn encode_is_copy() -> bool {
1866            true
1867        }
1868
1869        #[inline(always)]
1870        fn decode_is_copy() -> bool {
1871            false
1872        }
1873    }
1874
1875    impl fidl::encoding::ValueTypeMarker for Tiling {
1876        type Borrowed<'a> = Self;
1877        #[inline(always)]
1878        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1879            *value
1880        }
1881    }
1882
1883    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Tiling {
1884        #[inline]
1885        unsafe fn encode(
1886            self,
1887            encoder: &mut fidl::encoding::Encoder<'_, D>,
1888            offset: usize,
1889            _depth: fidl::encoding::Depth,
1890        ) -> fidl::Result<()> {
1891            encoder.debug_check_bounds::<Self>(offset);
1892            encoder.write_num(self.into_primitive(), offset);
1893            Ok(())
1894        }
1895    }
1896
1897    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Tiling {
1898        #[inline(always)]
1899        fn new_empty() -> Self {
1900            Self::Linear
1901        }
1902
1903        #[inline]
1904        unsafe fn decode(
1905            &mut self,
1906            decoder: &mut fidl::encoding::Decoder<'_, D>,
1907            offset: usize,
1908            _depth: fidl::encoding::Depth,
1909        ) -> fidl::Result<()> {
1910            decoder.debug_check_bounds::<Self>(offset);
1911            let prim = decoder.read_num::<u32>(offset);
1912
1913            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1914            Ok(())
1915        }
1916    }
1917    unsafe impl fidl::encoding::TypeMarker for Transform {
1918        type Owned = Self;
1919
1920        #[inline(always)]
1921        fn inline_align(_context: fidl::encoding::Context) -> usize {
1922            std::mem::align_of::<u32>()
1923        }
1924
1925        #[inline(always)]
1926        fn inline_size(_context: fidl::encoding::Context) -> usize {
1927            std::mem::size_of::<u32>()
1928        }
1929
1930        #[inline(always)]
1931        fn encode_is_copy() -> bool {
1932            true
1933        }
1934
1935        #[inline(always)]
1936        fn decode_is_copy() -> bool {
1937            false
1938        }
1939    }
1940
1941    impl fidl::encoding::ValueTypeMarker for Transform {
1942        type Borrowed<'a> = Self;
1943        #[inline(always)]
1944        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1945            *value
1946        }
1947    }
1948
1949    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Transform {
1950        #[inline]
1951        unsafe fn encode(
1952            self,
1953            encoder: &mut fidl::encoding::Encoder<'_, D>,
1954            offset: usize,
1955            _depth: fidl::encoding::Depth,
1956        ) -> fidl::Result<()> {
1957            encoder.debug_check_bounds::<Self>(offset);
1958            encoder.write_num(self.into_primitive(), offset);
1959            Ok(())
1960        }
1961    }
1962
1963    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Transform {
1964        #[inline(always)]
1965        fn new_empty() -> Self {
1966            Self::Normal
1967        }
1968
1969        #[inline]
1970        unsafe fn decode(
1971            &mut self,
1972            decoder: &mut fidl::encoding::Decoder<'_, D>,
1973            offset: usize,
1974            _depth: fidl::encoding::Depth,
1975        ) -> fidl::Result<()> {
1976            decoder.debug_check_bounds::<Self>(offset);
1977            let prim = decoder.read_num::<u32>(offset);
1978
1979            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1980            Ok(())
1981        }
1982    }
1983
1984    impl fidl::encoding::ValueTypeMarker for ImageInfo {
1985        type Borrowed<'a> = &'a Self;
1986        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1987            value
1988        }
1989    }
1990
1991    unsafe impl fidl::encoding::TypeMarker for ImageInfo {
1992        type Owned = Self;
1993
1994        #[inline(always)]
1995        fn inline_align(_context: fidl::encoding::Context) -> usize {
1996            4
1997        }
1998
1999        #[inline(always)]
2000        fn inline_size(_context: fidl::encoding::Context) -> usize {
2001            32
2002        }
2003    }
2004
2005    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ImageInfo, D>
2006        for &ImageInfo
2007    {
2008        #[inline]
2009        unsafe fn encode(
2010            self,
2011            encoder: &mut fidl::encoding::Encoder<'_, D>,
2012            offset: usize,
2013            _depth: fidl::encoding::Depth,
2014        ) -> fidl::Result<()> {
2015            encoder.debug_check_bounds::<ImageInfo>(offset);
2016            // Delegate to tuple encoding.
2017            fidl::encoding::Encode::<ImageInfo, D>::encode(
2018                (
2019                    <Transform as fidl::encoding::ValueTypeMarker>::borrow(&self.transform),
2020                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.width),
2021                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.height),
2022                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.stride),
2023                    <PixelFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.pixel_format),
2024                    <ColorSpace as fidl::encoding::ValueTypeMarker>::borrow(&self.color_space),
2025                    <Tiling as fidl::encoding::ValueTypeMarker>::borrow(&self.tiling),
2026                    <AlphaFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.alpha_format),
2027                ),
2028                encoder,
2029                offset,
2030                _depth,
2031            )
2032        }
2033    }
2034    unsafe impl<
2035            D: fidl::encoding::ResourceDialect,
2036            T0: fidl::encoding::Encode<Transform, D>,
2037            T1: fidl::encoding::Encode<u32, D>,
2038            T2: fidl::encoding::Encode<u32, D>,
2039            T3: fidl::encoding::Encode<u32, D>,
2040            T4: fidl::encoding::Encode<PixelFormat, D>,
2041            T5: fidl::encoding::Encode<ColorSpace, D>,
2042            T6: fidl::encoding::Encode<Tiling, D>,
2043            T7: fidl::encoding::Encode<AlphaFormat, D>,
2044        > fidl::encoding::Encode<ImageInfo, D> for (T0, T1, T2, T3, T4, T5, T6, T7)
2045    {
2046        #[inline]
2047        unsafe fn encode(
2048            self,
2049            encoder: &mut fidl::encoding::Encoder<'_, D>,
2050            offset: usize,
2051            depth: fidl::encoding::Depth,
2052        ) -> fidl::Result<()> {
2053            encoder.debug_check_bounds::<ImageInfo>(offset);
2054            // Zero out padding regions. There's no need to apply masks
2055            // because the unmasked parts will be overwritten by fields.
2056            // Write the fields.
2057            self.0.encode(encoder, offset + 0, depth)?;
2058            self.1.encode(encoder, offset + 4, depth)?;
2059            self.2.encode(encoder, offset + 8, depth)?;
2060            self.3.encode(encoder, offset + 12, depth)?;
2061            self.4.encode(encoder, offset + 16, depth)?;
2062            self.5.encode(encoder, offset + 20, depth)?;
2063            self.6.encode(encoder, offset + 24, depth)?;
2064            self.7.encode(encoder, offset + 28, depth)?;
2065            Ok(())
2066        }
2067    }
2068
2069    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ImageInfo {
2070        #[inline(always)]
2071        fn new_empty() -> Self {
2072            Self {
2073                transform: fidl::new_empty!(Transform, D),
2074                width: fidl::new_empty!(u32, D),
2075                height: fidl::new_empty!(u32, D),
2076                stride: fidl::new_empty!(u32, D),
2077                pixel_format: fidl::new_empty!(PixelFormat, D),
2078                color_space: fidl::new_empty!(ColorSpace, D),
2079                tiling: fidl::new_empty!(Tiling, D),
2080                alpha_format: fidl::new_empty!(AlphaFormat, D),
2081            }
2082        }
2083
2084        #[inline]
2085        unsafe fn decode(
2086            &mut self,
2087            decoder: &mut fidl::encoding::Decoder<'_, D>,
2088            offset: usize,
2089            _depth: fidl::encoding::Depth,
2090        ) -> fidl::Result<()> {
2091            decoder.debug_check_bounds::<Self>(offset);
2092            // Verify that padding bytes are zero.
2093            fidl::decode!(Transform, D, &mut self.transform, decoder, offset + 0, _depth)?;
2094            fidl::decode!(u32, D, &mut self.width, decoder, offset + 4, _depth)?;
2095            fidl::decode!(u32, D, &mut self.height, decoder, offset + 8, _depth)?;
2096            fidl::decode!(u32, D, &mut self.stride, decoder, offset + 12, _depth)?;
2097            fidl::decode!(PixelFormat, D, &mut self.pixel_format, decoder, offset + 16, _depth)?;
2098            fidl::decode!(ColorSpace, D, &mut self.color_space, decoder, offset + 20, _depth)?;
2099            fidl::decode!(Tiling, D, &mut self.tiling, decoder, offset + 24, _depth)?;
2100            fidl::decode!(AlphaFormat, D, &mut self.alpha_format, decoder, offset + 28, _depth)?;
2101            Ok(())
2102        }
2103    }
2104
2105    impl fidl::encoding::ResourceTypeMarker for ImagePipe2AddBufferCollection2Request {
2106        type Borrowed<'a> = &'a mut Self;
2107        fn take_or_borrow<'a>(
2108            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2109        ) -> Self::Borrowed<'a> {
2110            value
2111        }
2112    }
2113
2114    unsafe impl fidl::encoding::TypeMarker for ImagePipe2AddBufferCollection2Request {
2115        type Owned = Self;
2116
2117        #[inline(always)]
2118        fn inline_align(_context: fidl::encoding::Context) -> usize {
2119            4
2120        }
2121
2122        #[inline(always)]
2123        fn inline_size(_context: fidl::encoding::Context) -> usize {
2124            8
2125        }
2126    }
2127
2128    unsafe impl
2129        fidl::encoding::Encode<
2130            ImagePipe2AddBufferCollection2Request,
2131            fidl::encoding::DefaultFuchsiaResourceDialect,
2132        > for &mut ImagePipe2AddBufferCollection2Request
2133    {
2134        #[inline]
2135        unsafe fn encode(
2136            self,
2137            encoder: &mut fidl::encoding::Encoder<
2138                '_,
2139                fidl::encoding::DefaultFuchsiaResourceDialect,
2140            >,
2141            offset: usize,
2142            _depth: fidl::encoding::Depth,
2143        ) -> fidl::Result<()> {
2144            encoder.debug_check_bounds::<ImagePipe2AddBufferCollection2Request>(offset);
2145            // Delegate to tuple encoding.
2146            fidl::encoding::Encode::<
2147                ImagePipe2AddBufferCollection2Request,
2148                fidl::encoding::DefaultFuchsiaResourceDialect,
2149            >::encode(
2150                (
2151                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_collection_id),
2152                    <fidl::encoding::Endpoint<
2153                        fidl::endpoints::ClientEnd<
2154                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
2155                        >,
2156                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2157                        &mut self.buffer_collection_token,
2158                    ),
2159                ),
2160                encoder,
2161                offset,
2162                _depth,
2163            )
2164        }
2165    }
2166    unsafe impl<
2167            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2168            T1: fidl::encoding::Encode<
2169                fidl::encoding::Endpoint<
2170                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
2171                >,
2172                fidl::encoding::DefaultFuchsiaResourceDialect,
2173            >,
2174        >
2175        fidl::encoding::Encode<
2176            ImagePipe2AddBufferCollection2Request,
2177            fidl::encoding::DefaultFuchsiaResourceDialect,
2178        > for (T0, T1)
2179    {
2180        #[inline]
2181        unsafe fn encode(
2182            self,
2183            encoder: &mut fidl::encoding::Encoder<
2184                '_,
2185                fidl::encoding::DefaultFuchsiaResourceDialect,
2186            >,
2187            offset: usize,
2188            depth: fidl::encoding::Depth,
2189        ) -> fidl::Result<()> {
2190            encoder.debug_check_bounds::<ImagePipe2AddBufferCollection2Request>(offset);
2191            // Zero out padding regions. There's no need to apply masks
2192            // because the unmasked parts will be overwritten by fields.
2193            // Write the fields.
2194            self.0.encode(encoder, offset + 0, depth)?;
2195            self.1.encode(encoder, offset + 4, depth)?;
2196            Ok(())
2197        }
2198    }
2199
2200    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2201        for ImagePipe2AddBufferCollection2Request
2202    {
2203        #[inline(always)]
2204        fn new_empty() -> Self {
2205            Self {
2206                buffer_collection_id: fidl::new_empty!(
2207                    u32,
2208                    fidl::encoding::DefaultFuchsiaResourceDialect
2209                ),
2210                buffer_collection_token: fidl::new_empty!(
2211                    fidl::encoding::Endpoint<
2212                        fidl::endpoints::ClientEnd<
2213                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
2214                        >,
2215                    >,
2216                    fidl::encoding::DefaultFuchsiaResourceDialect
2217                ),
2218            }
2219        }
2220
2221        #[inline]
2222        unsafe fn decode(
2223            &mut self,
2224            decoder: &mut fidl::encoding::Decoder<
2225                '_,
2226                fidl::encoding::DefaultFuchsiaResourceDialect,
2227            >,
2228            offset: usize,
2229            _depth: fidl::encoding::Depth,
2230        ) -> fidl::Result<()> {
2231            decoder.debug_check_bounds::<Self>(offset);
2232            // Verify that padding bytes are zero.
2233            fidl::decode!(
2234                u32,
2235                fidl::encoding::DefaultFuchsiaResourceDialect,
2236                &mut self.buffer_collection_id,
2237                decoder,
2238                offset + 0,
2239                _depth
2240            )?;
2241            fidl::decode!(
2242                fidl::encoding::Endpoint<
2243                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
2244                >,
2245                fidl::encoding::DefaultFuchsiaResourceDialect,
2246                &mut self.buffer_collection_token,
2247                decoder,
2248                offset + 4,
2249                _depth
2250            )?;
2251            Ok(())
2252        }
2253    }
2254
2255    impl fidl::encoding::ResourceTypeMarker for ImagePipe2AddBufferCollectionRequest {
2256        type Borrowed<'a> = &'a mut Self;
2257        fn take_or_borrow<'a>(
2258            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2259        ) -> Self::Borrowed<'a> {
2260            value
2261        }
2262    }
2263
2264    unsafe impl fidl::encoding::TypeMarker for ImagePipe2AddBufferCollectionRequest {
2265        type Owned = Self;
2266
2267        #[inline(always)]
2268        fn inline_align(_context: fidl::encoding::Context) -> usize {
2269            4
2270        }
2271
2272        #[inline(always)]
2273        fn inline_size(_context: fidl::encoding::Context) -> usize {
2274            8
2275        }
2276    }
2277
2278    unsafe impl
2279        fidl::encoding::Encode<
2280            ImagePipe2AddBufferCollectionRequest,
2281            fidl::encoding::DefaultFuchsiaResourceDialect,
2282        > for &mut ImagePipe2AddBufferCollectionRequest
2283    {
2284        #[inline]
2285        unsafe fn encode(
2286            self,
2287            encoder: &mut fidl::encoding::Encoder<
2288                '_,
2289                fidl::encoding::DefaultFuchsiaResourceDialect,
2290            >,
2291            offset: usize,
2292            _depth: fidl::encoding::Depth,
2293        ) -> fidl::Result<()> {
2294            encoder.debug_check_bounds::<ImagePipe2AddBufferCollectionRequest>(offset);
2295            // Delegate to tuple encoding.
2296            fidl::encoding::Encode::<
2297                ImagePipe2AddBufferCollectionRequest,
2298                fidl::encoding::DefaultFuchsiaResourceDialect,
2299            >::encode(
2300                (
2301                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_collection_id),
2302                    <fidl::encoding::Endpoint<
2303                        fidl::endpoints::ClientEnd<
2304                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
2305                        >,
2306                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2307                        &mut self.buffer_collection_token,
2308                    ),
2309                ),
2310                encoder,
2311                offset,
2312                _depth,
2313            )
2314        }
2315    }
2316    unsafe impl<
2317            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2318            T1: fidl::encoding::Encode<
2319                fidl::encoding::Endpoint<
2320                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
2321                >,
2322                fidl::encoding::DefaultFuchsiaResourceDialect,
2323            >,
2324        >
2325        fidl::encoding::Encode<
2326            ImagePipe2AddBufferCollectionRequest,
2327            fidl::encoding::DefaultFuchsiaResourceDialect,
2328        > for (T0, T1)
2329    {
2330        #[inline]
2331        unsafe fn encode(
2332            self,
2333            encoder: &mut fidl::encoding::Encoder<
2334                '_,
2335                fidl::encoding::DefaultFuchsiaResourceDialect,
2336            >,
2337            offset: usize,
2338            depth: fidl::encoding::Depth,
2339        ) -> fidl::Result<()> {
2340            encoder.debug_check_bounds::<ImagePipe2AddBufferCollectionRequest>(offset);
2341            // Zero out padding regions. There's no need to apply masks
2342            // because the unmasked parts will be overwritten by fields.
2343            // Write the fields.
2344            self.0.encode(encoder, offset + 0, depth)?;
2345            self.1.encode(encoder, offset + 4, depth)?;
2346            Ok(())
2347        }
2348    }
2349
2350    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2351        for ImagePipe2AddBufferCollectionRequest
2352    {
2353        #[inline(always)]
2354        fn new_empty() -> Self {
2355            Self {
2356                buffer_collection_id: fidl::new_empty!(
2357                    u32,
2358                    fidl::encoding::DefaultFuchsiaResourceDialect
2359                ),
2360                buffer_collection_token: fidl::new_empty!(
2361                    fidl::encoding::Endpoint<
2362                        fidl::endpoints::ClientEnd<
2363                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
2364                        >,
2365                    >,
2366                    fidl::encoding::DefaultFuchsiaResourceDialect
2367                ),
2368            }
2369        }
2370
2371        #[inline]
2372        unsafe fn decode(
2373            &mut self,
2374            decoder: &mut fidl::encoding::Decoder<
2375                '_,
2376                fidl::encoding::DefaultFuchsiaResourceDialect,
2377            >,
2378            offset: usize,
2379            _depth: fidl::encoding::Depth,
2380        ) -> fidl::Result<()> {
2381            decoder.debug_check_bounds::<Self>(offset);
2382            // Verify that padding bytes are zero.
2383            fidl::decode!(
2384                u32,
2385                fidl::encoding::DefaultFuchsiaResourceDialect,
2386                &mut self.buffer_collection_id,
2387                decoder,
2388                offset + 0,
2389                _depth
2390            )?;
2391            fidl::decode!(
2392                fidl::encoding::Endpoint<
2393                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
2394                >,
2395                fidl::encoding::DefaultFuchsiaResourceDialect,
2396                &mut self.buffer_collection_token,
2397                decoder,
2398                offset + 4,
2399                _depth
2400            )?;
2401            Ok(())
2402        }
2403    }
2404
2405    impl fidl::encoding::ValueTypeMarker for ImagePipe2AddImageRequest {
2406        type Borrowed<'a> = &'a Self;
2407        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2408            value
2409        }
2410    }
2411
2412    unsafe impl fidl::encoding::TypeMarker for ImagePipe2AddImageRequest {
2413        type Owned = Self;
2414
2415        #[inline(always)]
2416        fn inline_align(_context: fidl::encoding::Context) -> usize {
2417            8
2418        }
2419
2420        #[inline(always)]
2421        fn inline_size(_context: fidl::encoding::Context) -> usize {
2422            72
2423        }
2424    }
2425
2426    unsafe impl<D: fidl::encoding::ResourceDialect>
2427        fidl::encoding::Encode<ImagePipe2AddImageRequest, D> for &ImagePipe2AddImageRequest
2428    {
2429        #[inline]
2430        unsafe fn encode(
2431            self,
2432            encoder: &mut fidl::encoding::Encoder<'_, D>,
2433            offset: usize,
2434            _depth: fidl::encoding::Depth,
2435        ) -> fidl::Result<()> {
2436            encoder.debug_check_bounds::<ImagePipe2AddImageRequest>(offset);
2437            // Delegate to tuple encoding.
2438            fidl::encoding::Encode::<ImagePipe2AddImageRequest, D>::encode(
2439                (
2440                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.image_id),
2441                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_collection_id),
2442                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_collection_index),
2443                    <fidl_fuchsia_sysmem::ImageFormat2 as fidl::encoding::ValueTypeMarker>::borrow(
2444                        &self.image_format,
2445                    ),
2446                ),
2447                encoder,
2448                offset,
2449                _depth,
2450            )
2451        }
2452    }
2453    unsafe impl<
2454            D: fidl::encoding::ResourceDialect,
2455            T0: fidl::encoding::Encode<u32, D>,
2456            T1: fidl::encoding::Encode<u32, D>,
2457            T2: fidl::encoding::Encode<u32, D>,
2458            T3: fidl::encoding::Encode<fidl_fuchsia_sysmem::ImageFormat2, D>,
2459        > fidl::encoding::Encode<ImagePipe2AddImageRequest, D> for (T0, T1, T2, T3)
2460    {
2461        #[inline]
2462        unsafe fn encode(
2463            self,
2464            encoder: &mut fidl::encoding::Encoder<'_, D>,
2465            offset: usize,
2466            depth: fidl::encoding::Depth,
2467        ) -> fidl::Result<()> {
2468            encoder.debug_check_bounds::<ImagePipe2AddImageRequest>(offset);
2469            // Zero out padding regions. There's no need to apply masks
2470            // because the unmasked parts will be overwritten by fields.
2471            unsafe {
2472                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
2473                (ptr as *mut u64).write_unaligned(0);
2474            }
2475            // Write the fields.
2476            self.0.encode(encoder, offset + 0, depth)?;
2477            self.1.encode(encoder, offset + 4, depth)?;
2478            self.2.encode(encoder, offset + 8, depth)?;
2479            self.3.encode(encoder, offset + 16, depth)?;
2480            Ok(())
2481        }
2482    }
2483
2484    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2485        for ImagePipe2AddImageRequest
2486    {
2487        #[inline(always)]
2488        fn new_empty() -> Self {
2489            Self {
2490                image_id: fidl::new_empty!(u32, D),
2491                buffer_collection_id: fidl::new_empty!(u32, D),
2492                buffer_collection_index: fidl::new_empty!(u32, D),
2493                image_format: fidl::new_empty!(fidl_fuchsia_sysmem::ImageFormat2, D),
2494            }
2495        }
2496
2497        #[inline]
2498        unsafe fn decode(
2499            &mut self,
2500            decoder: &mut fidl::encoding::Decoder<'_, D>,
2501            offset: usize,
2502            _depth: fidl::encoding::Depth,
2503        ) -> fidl::Result<()> {
2504            decoder.debug_check_bounds::<Self>(offset);
2505            // Verify that padding bytes are zero.
2506            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
2507            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2508            let mask = 0xffffffff00000000u64;
2509            let maskedval = padval & mask;
2510            if maskedval != 0 {
2511                return Err(fidl::Error::NonZeroPadding {
2512                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
2513                });
2514            }
2515            fidl::decode!(u32, D, &mut self.image_id, decoder, offset + 0, _depth)?;
2516            fidl::decode!(u32, D, &mut self.buffer_collection_id, decoder, offset + 4, _depth)?;
2517            fidl::decode!(u32, D, &mut self.buffer_collection_index, decoder, offset + 8, _depth)?;
2518            fidl::decode!(
2519                fidl_fuchsia_sysmem::ImageFormat2,
2520                D,
2521                &mut self.image_format,
2522                decoder,
2523                offset + 16,
2524                _depth
2525            )?;
2526            Ok(())
2527        }
2528    }
2529
2530    impl fidl::encoding::ResourceTypeMarker for ImagePipe2PresentImageRequest {
2531        type Borrowed<'a> = &'a mut Self;
2532        fn take_or_borrow<'a>(
2533            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2534        ) -> Self::Borrowed<'a> {
2535            value
2536        }
2537    }
2538
2539    unsafe impl fidl::encoding::TypeMarker for ImagePipe2PresentImageRequest {
2540        type Owned = Self;
2541
2542        #[inline(always)]
2543        fn inline_align(_context: fidl::encoding::Context) -> usize {
2544            8
2545        }
2546
2547        #[inline(always)]
2548        fn inline_size(_context: fidl::encoding::Context) -> usize {
2549            48
2550        }
2551    }
2552
2553    unsafe impl
2554        fidl::encoding::Encode<
2555            ImagePipe2PresentImageRequest,
2556            fidl::encoding::DefaultFuchsiaResourceDialect,
2557        > for &mut ImagePipe2PresentImageRequest
2558    {
2559        #[inline]
2560        unsafe fn encode(
2561            self,
2562            encoder: &mut fidl::encoding::Encoder<
2563                '_,
2564                fidl::encoding::DefaultFuchsiaResourceDialect,
2565            >,
2566            offset: usize,
2567            _depth: fidl::encoding::Depth,
2568        ) -> fidl::Result<()> {
2569            encoder.debug_check_bounds::<ImagePipe2PresentImageRequest>(offset);
2570            // Delegate to tuple encoding.
2571            fidl::encoding::Encode::<
2572                ImagePipe2PresentImageRequest,
2573                fidl::encoding::DefaultFuchsiaResourceDialect,
2574            >::encode(
2575                (
2576                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.image_id),
2577                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.presentation_time),
2578                    <fidl::encoding::Vector<
2579                        fidl::encoding::HandleType<
2580                            fidl::Event,
2581                            { fidl::ObjectType::EVENT.into_raw() },
2582                            2147483648,
2583                        >,
2584                        16,
2585                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2586                        &mut self.acquire_fences,
2587                    ),
2588                    <fidl::encoding::Vector<
2589                        fidl::encoding::HandleType<
2590                            fidl::Event,
2591                            { fidl::ObjectType::EVENT.into_raw() },
2592                            2147483648,
2593                        >,
2594                        16,
2595                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2596                        &mut self.release_fences,
2597                    ),
2598                ),
2599                encoder,
2600                offset,
2601                _depth,
2602            )
2603        }
2604    }
2605    unsafe impl<
2606            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2607            T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2608            T2: fidl::encoding::Encode<
2609                fidl::encoding::Vector<
2610                    fidl::encoding::HandleType<
2611                        fidl::Event,
2612                        { fidl::ObjectType::EVENT.into_raw() },
2613                        2147483648,
2614                    >,
2615                    16,
2616                >,
2617                fidl::encoding::DefaultFuchsiaResourceDialect,
2618            >,
2619            T3: fidl::encoding::Encode<
2620                fidl::encoding::Vector<
2621                    fidl::encoding::HandleType<
2622                        fidl::Event,
2623                        { fidl::ObjectType::EVENT.into_raw() },
2624                        2147483648,
2625                    >,
2626                    16,
2627                >,
2628                fidl::encoding::DefaultFuchsiaResourceDialect,
2629            >,
2630        >
2631        fidl::encoding::Encode<
2632            ImagePipe2PresentImageRequest,
2633            fidl::encoding::DefaultFuchsiaResourceDialect,
2634        > for (T0, T1, T2, T3)
2635    {
2636        #[inline]
2637        unsafe fn encode(
2638            self,
2639            encoder: &mut fidl::encoding::Encoder<
2640                '_,
2641                fidl::encoding::DefaultFuchsiaResourceDialect,
2642            >,
2643            offset: usize,
2644            depth: fidl::encoding::Depth,
2645        ) -> fidl::Result<()> {
2646            encoder.debug_check_bounds::<ImagePipe2PresentImageRequest>(offset);
2647            // Zero out padding regions. There's no need to apply masks
2648            // because the unmasked parts will be overwritten by fields.
2649            unsafe {
2650                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2651                (ptr as *mut u64).write_unaligned(0);
2652            }
2653            // Write the fields.
2654            self.0.encode(encoder, offset + 0, depth)?;
2655            self.1.encode(encoder, offset + 8, depth)?;
2656            self.2.encode(encoder, offset + 16, depth)?;
2657            self.3.encode(encoder, offset + 32, depth)?;
2658            Ok(())
2659        }
2660    }
2661
2662    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2663        for ImagePipe2PresentImageRequest
2664    {
2665        #[inline(always)]
2666        fn new_empty() -> Self {
2667            Self {
2668                image_id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
2669                presentation_time: fidl::new_empty!(
2670                    u64,
2671                    fidl::encoding::DefaultFuchsiaResourceDialect
2672                ),
2673                acquire_fences: fidl::new_empty!(
2674                    fidl::encoding::Vector<
2675                        fidl::encoding::HandleType<
2676                            fidl::Event,
2677                            { fidl::ObjectType::EVENT.into_raw() },
2678                            2147483648,
2679                        >,
2680                        16,
2681                    >,
2682                    fidl::encoding::DefaultFuchsiaResourceDialect
2683                ),
2684                release_fences: fidl::new_empty!(
2685                    fidl::encoding::Vector<
2686                        fidl::encoding::HandleType<
2687                            fidl::Event,
2688                            { fidl::ObjectType::EVENT.into_raw() },
2689                            2147483648,
2690                        >,
2691                        16,
2692                    >,
2693                    fidl::encoding::DefaultFuchsiaResourceDialect
2694                ),
2695            }
2696        }
2697
2698        #[inline]
2699        unsafe fn decode(
2700            &mut self,
2701            decoder: &mut fidl::encoding::Decoder<
2702                '_,
2703                fidl::encoding::DefaultFuchsiaResourceDialect,
2704            >,
2705            offset: usize,
2706            _depth: fidl::encoding::Depth,
2707        ) -> fidl::Result<()> {
2708            decoder.debug_check_bounds::<Self>(offset);
2709            // Verify that padding bytes are zero.
2710            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2711            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2712            let mask = 0xffffffff00000000u64;
2713            let maskedval = padval & mask;
2714            if maskedval != 0 {
2715                return Err(fidl::Error::NonZeroPadding {
2716                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2717                });
2718            }
2719            fidl::decode!(
2720                u32,
2721                fidl::encoding::DefaultFuchsiaResourceDialect,
2722                &mut self.image_id,
2723                decoder,
2724                offset + 0,
2725                _depth
2726            )?;
2727            fidl::decode!(
2728                u64,
2729                fidl::encoding::DefaultFuchsiaResourceDialect,
2730                &mut self.presentation_time,
2731                decoder,
2732                offset + 8,
2733                _depth
2734            )?;
2735            fidl::decode!(
2736                fidl::encoding::Vector<
2737                    fidl::encoding::HandleType<
2738                        fidl::Event,
2739                        { fidl::ObjectType::EVENT.into_raw() },
2740                        2147483648,
2741                    >,
2742                    16,
2743                >,
2744                fidl::encoding::DefaultFuchsiaResourceDialect,
2745                &mut self.acquire_fences,
2746                decoder,
2747                offset + 16,
2748                _depth
2749            )?;
2750            fidl::decode!(
2751                fidl::encoding::Vector<
2752                    fidl::encoding::HandleType<
2753                        fidl::Event,
2754                        { fidl::ObjectType::EVENT.into_raw() },
2755                        2147483648,
2756                    >,
2757                    16,
2758                >,
2759                fidl::encoding::DefaultFuchsiaResourceDialect,
2760                &mut self.release_fences,
2761                decoder,
2762                offset + 32,
2763                _depth
2764            )?;
2765            Ok(())
2766        }
2767    }
2768
2769    impl fidl::encoding::ValueTypeMarker for ImagePipe2PresentImageResponse {
2770        type Borrowed<'a> = &'a Self;
2771        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2772            value
2773        }
2774    }
2775
2776    unsafe impl fidl::encoding::TypeMarker for ImagePipe2PresentImageResponse {
2777        type Owned = Self;
2778
2779        #[inline(always)]
2780        fn inline_align(_context: fidl::encoding::Context) -> usize {
2781            8
2782        }
2783
2784        #[inline(always)]
2785        fn inline_size(_context: fidl::encoding::Context) -> usize {
2786            16
2787        }
2788        #[inline(always)]
2789        fn encode_is_copy() -> bool {
2790            true
2791        }
2792
2793        #[inline(always)]
2794        fn decode_is_copy() -> bool {
2795            true
2796        }
2797    }
2798
2799    unsafe impl<D: fidl::encoding::ResourceDialect>
2800        fidl::encoding::Encode<ImagePipe2PresentImageResponse, D>
2801        for &ImagePipe2PresentImageResponse
2802    {
2803        #[inline]
2804        unsafe fn encode(
2805            self,
2806            encoder: &mut fidl::encoding::Encoder<'_, D>,
2807            offset: usize,
2808            _depth: fidl::encoding::Depth,
2809        ) -> fidl::Result<()> {
2810            encoder.debug_check_bounds::<ImagePipe2PresentImageResponse>(offset);
2811            unsafe {
2812                // Copy the object into the buffer.
2813                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2814                (buf_ptr as *mut ImagePipe2PresentImageResponse)
2815                    .write_unaligned((self as *const ImagePipe2PresentImageResponse).read());
2816                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
2817                // done second because the memcpy will write garbage to these bytes.
2818            }
2819            Ok(())
2820        }
2821    }
2822    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<PresentationInfo, D>>
2823        fidl::encoding::Encode<ImagePipe2PresentImageResponse, D> for (T0,)
2824    {
2825        #[inline]
2826        unsafe fn encode(
2827            self,
2828            encoder: &mut fidl::encoding::Encoder<'_, D>,
2829            offset: usize,
2830            depth: fidl::encoding::Depth,
2831        ) -> fidl::Result<()> {
2832            encoder.debug_check_bounds::<ImagePipe2PresentImageResponse>(offset);
2833            // Zero out padding regions. There's no need to apply masks
2834            // because the unmasked parts will be overwritten by fields.
2835            // Write the fields.
2836            self.0.encode(encoder, offset + 0, depth)?;
2837            Ok(())
2838        }
2839    }
2840
2841    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2842        for ImagePipe2PresentImageResponse
2843    {
2844        #[inline(always)]
2845        fn new_empty() -> Self {
2846            Self { presentation_info: fidl::new_empty!(PresentationInfo, D) }
2847        }
2848
2849        #[inline]
2850        unsafe fn decode(
2851            &mut self,
2852            decoder: &mut fidl::encoding::Decoder<'_, D>,
2853            offset: usize,
2854            _depth: fidl::encoding::Depth,
2855        ) -> fidl::Result<()> {
2856            decoder.debug_check_bounds::<Self>(offset);
2857            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2858            // Verify that padding bytes are zero.
2859            // Copy from the buffer into the object.
2860            unsafe {
2861                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
2862            }
2863            Ok(())
2864        }
2865    }
2866
2867    impl fidl::encoding::ValueTypeMarker for ImagePipe2RemoveBufferCollectionRequest {
2868        type Borrowed<'a> = &'a Self;
2869        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2870            value
2871        }
2872    }
2873
2874    unsafe impl fidl::encoding::TypeMarker for ImagePipe2RemoveBufferCollectionRequest {
2875        type Owned = Self;
2876
2877        #[inline(always)]
2878        fn inline_align(_context: fidl::encoding::Context) -> usize {
2879            4
2880        }
2881
2882        #[inline(always)]
2883        fn inline_size(_context: fidl::encoding::Context) -> usize {
2884            4
2885        }
2886        #[inline(always)]
2887        fn encode_is_copy() -> bool {
2888            true
2889        }
2890
2891        #[inline(always)]
2892        fn decode_is_copy() -> bool {
2893            true
2894        }
2895    }
2896
2897    unsafe impl<D: fidl::encoding::ResourceDialect>
2898        fidl::encoding::Encode<ImagePipe2RemoveBufferCollectionRequest, D>
2899        for &ImagePipe2RemoveBufferCollectionRequest
2900    {
2901        #[inline]
2902        unsafe fn encode(
2903            self,
2904            encoder: &mut fidl::encoding::Encoder<'_, D>,
2905            offset: usize,
2906            _depth: fidl::encoding::Depth,
2907        ) -> fidl::Result<()> {
2908            encoder.debug_check_bounds::<ImagePipe2RemoveBufferCollectionRequest>(offset);
2909            unsafe {
2910                // Copy the object into the buffer.
2911                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2912                (buf_ptr as *mut ImagePipe2RemoveBufferCollectionRequest).write_unaligned(
2913                    (self as *const ImagePipe2RemoveBufferCollectionRequest).read(),
2914                );
2915                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
2916                // done second because the memcpy will write garbage to these bytes.
2917            }
2918            Ok(())
2919        }
2920    }
2921    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
2922        fidl::encoding::Encode<ImagePipe2RemoveBufferCollectionRequest, D> for (T0,)
2923    {
2924        #[inline]
2925        unsafe fn encode(
2926            self,
2927            encoder: &mut fidl::encoding::Encoder<'_, D>,
2928            offset: usize,
2929            depth: fidl::encoding::Depth,
2930        ) -> fidl::Result<()> {
2931            encoder.debug_check_bounds::<ImagePipe2RemoveBufferCollectionRequest>(offset);
2932            // Zero out padding regions. There's no need to apply masks
2933            // because the unmasked parts will be overwritten by fields.
2934            // Write the fields.
2935            self.0.encode(encoder, offset + 0, depth)?;
2936            Ok(())
2937        }
2938    }
2939
2940    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2941        for ImagePipe2RemoveBufferCollectionRequest
2942    {
2943        #[inline(always)]
2944        fn new_empty() -> Self {
2945            Self { buffer_collection_id: fidl::new_empty!(u32, D) }
2946        }
2947
2948        #[inline]
2949        unsafe fn decode(
2950            &mut self,
2951            decoder: &mut fidl::encoding::Decoder<'_, D>,
2952            offset: usize,
2953            _depth: fidl::encoding::Depth,
2954        ) -> fidl::Result<()> {
2955            decoder.debug_check_bounds::<Self>(offset);
2956            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2957            // Verify that padding bytes are zero.
2958            // Copy from the buffer into the object.
2959            unsafe {
2960                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
2961            }
2962            Ok(())
2963        }
2964    }
2965
2966    impl fidl::encoding::ValueTypeMarker for ImagePipe2RemoveImageRequest {
2967        type Borrowed<'a> = &'a Self;
2968        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2969            value
2970        }
2971    }
2972
2973    unsafe impl fidl::encoding::TypeMarker for ImagePipe2RemoveImageRequest {
2974        type Owned = Self;
2975
2976        #[inline(always)]
2977        fn inline_align(_context: fidl::encoding::Context) -> usize {
2978            4
2979        }
2980
2981        #[inline(always)]
2982        fn inline_size(_context: fidl::encoding::Context) -> usize {
2983            4
2984        }
2985        #[inline(always)]
2986        fn encode_is_copy() -> bool {
2987            true
2988        }
2989
2990        #[inline(always)]
2991        fn decode_is_copy() -> bool {
2992            true
2993        }
2994    }
2995
2996    unsafe impl<D: fidl::encoding::ResourceDialect>
2997        fidl::encoding::Encode<ImagePipe2RemoveImageRequest, D> for &ImagePipe2RemoveImageRequest
2998    {
2999        #[inline]
3000        unsafe fn encode(
3001            self,
3002            encoder: &mut fidl::encoding::Encoder<'_, D>,
3003            offset: usize,
3004            _depth: fidl::encoding::Depth,
3005        ) -> fidl::Result<()> {
3006            encoder.debug_check_bounds::<ImagePipe2RemoveImageRequest>(offset);
3007            unsafe {
3008                // Copy the object into the buffer.
3009                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
3010                (buf_ptr as *mut ImagePipe2RemoveImageRequest)
3011                    .write_unaligned((self as *const ImagePipe2RemoveImageRequest).read());
3012                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
3013                // done second because the memcpy will write garbage to these bytes.
3014            }
3015            Ok(())
3016        }
3017    }
3018    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
3019        fidl::encoding::Encode<ImagePipe2RemoveImageRequest, D> for (T0,)
3020    {
3021        #[inline]
3022        unsafe fn encode(
3023            self,
3024            encoder: &mut fidl::encoding::Encoder<'_, D>,
3025            offset: usize,
3026            depth: fidl::encoding::Depth,
3027        ) -> fidl::Result<()> {
3028            encoder.debug_check_bounds::<ImagePipe2RemoveImageRequest>(offset);
3029            // Zero out padding regions. There's no need to apply masks
3030            // because the unmasked parts will be overwritten by fields.
3031            // Write the fields.
3032            self.0.encode(encoder, offset + 0, depth)?;
3033            Ok(())
3034        }
3035    }
3036
3037    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3038        for ImagePipe2RemoveImageRequest
3039    {
3040        #[inline(always)]
3041        fn new_empty() -> Self {
3042            Self { image_id: fidl::new_empty!(u32, D) }
3043        }
3044
3045        #[inline]
3046        unsafe fn decode(
3047            &mut self,
3048            decoder: &mut fidl::encoding::Decoder<'_, D>,
3049            offset: usize,
3050            _depth: fidl::encoding::Depth,
3051        ) -> fidl::Result<()> {
3052            decoder.debug_check_bounds::<Self>(offset);
3053            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
3054            // Verify that padding bytes are zero.
3055            // Copy from the buffer into the object.
3056            unsafe {
3057                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
3058            }
3059            Ok(())
3060        }
3061    }
3062
3063    impl fidl::encoding::ValueTypeMarker for PresentationInfo {
3064        type Borrowed<'a> = &'a Self;
3065        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3066            value
3067        }
3068    }
3069
3070    unsafe impl fidl::encoding::TypeMarker for PresentationInfo {
3071        type Owned = Self;
3072
3073        #[inline(always)]
3074        fn inline_align(_context: fidl::encoding::Context) -> usize {
3075            8
3076        }
3077
3078        #[inline(always)]
3079        fn inline_size(_context: fidl::encoding::Context) -> usize {
3080            16
3081        }
3082        #[inline(always)]
3083        fn encode_is_copy() -> bool {
3084            true
3085        }
3086
3087        #[inline(always)]
3088        fn decode_is_copy() -> bool {
3089            true
3090        }
3091    }
3092
3093    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PresentationInfo, D>
3094        for &PresentationInfo
3095    {
3096        #[inline]
3097        unsafe fn encode(
3098            self,
3099            encoder: &mut fidl::encoding::Encoder<'_, D>,
3100            offset: usize,
3101            _depth: fidl::encoding::Depth,
3102        ) -> fidl::Result<()> {
3103            encoder.debug_check_bounds::<PresentationInfo>(offset);
3104            unsafe {
3105                // Copy the object into the buffer.
3106                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
3107                (buf_ptr as *mut PresentationInfo)
3108                    .write_unaligned((self as *const PresentationInfo).read());
3109                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
3110                // done second because the memcpy will write garbage to these bytes.
3111            }
3112            Ok(())
3113        }
3114    }
3115    unsafe impl<
3116            D: fidl::encoding::ResourceDialect,
3117            T0: fidl::encoding::Encode<u64, D>,
3118            T1: fidl::encoding::Encode<u64, D>,
3119        > fidl::encoding::Encode<PresentationInfo, D> for (T0, T1)
3120    {
3121        #[inline]
3122        unsafe fn encode(
3123            self,
3124            encoder: &mut fidl::encoding::Encoder<'_, D>,
3125            offset: usize,
3126            depth: fidl::encoding::Depth,
3127        ) -> fidl::Result<()> {
3128            encoder.debug_check_bounds::<PresentationInfo>(offset);
3129            // Zero out padding regions. There's no need to apply masks
3130            // because the unmasked parts will be overwritten by fields.
3131            // Write the fields.
3132            self.0.encode(encoder, offset + 0, depth)?;
3133            self.1.encode(encoder, offset + 8, depth)?;
3134            Ok(())
3135        }
3136    }
3137
3138    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PresentationInfo {
3139        #[inline(always)]
3140        fn new_empty() -> Self {
3141            Self {
3142                presentation_time: fidl::new_empty!(u64, D),
3143                presentation_interval: fidl::new_empty!(u64, D),
3144            }
3145        }
3146
3147        #[inline]
3148        unsafe fn decode(
3149            &mut self,
3150            decoder: &mut fidl::encoding::Decoder<'_, D>,
3151            offset: usize,
3152            _depth: fidl::encoding::Depth,
3153        ) -> fidl::Result<()> {
3154            decoder.debug_check_bounds::<Self>(offset);
3155            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
3156            // Verify that padding bytes are zero.
3157            // Copy from the buffer into the object.
3158            unsafe {
3159                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
3160            }
3161            Ok(())
3162        }
3163    }
3164}