Skip to main content

fdomain_fuchsia_images/
fdomain_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 fdomain_client::fidl::{ControlHandle as _, FDomainFlexibleIntoResult as _, Responder as _};
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9pub use fidl_fuchsia_images_common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct ImagePipe2AddBufferCollection2Request {
15    pub buffer_collection_id: u32,
16    pub buffer_collection_token:
17        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker>,
18}
19
20impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
21    for ImagePipe2AddBufferCollection2Request
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct ImagePipe2AddBufferCollectionRequest {
27    pub buffer_collection_id: u32,
28    pub buffer_collection_token:
29        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem::BufferCollectionTokenMarker>,
30}
31
32impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
33    for ImagePipe2AddBufferCollectionRequest
34{
35}
36
37#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
38pub struct ImagePipe2PresentImageRequest {
39    pub image_id: u32,
40    pub presentation_time: u64,
41    pub acquire_fences: Vec<fdomain_client::Event>,
42    pub release_fences: Vec<fdomain_client::Event>,
43}
44
45impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
46    for ImagePipe2PresentImageRequest
47{
48}
49
50#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
51pub struct ImagePipe2Marker;
52
53impl fdomain_client::fidl::ProtocolMarker for ImagePipe2Marker {
54    type Proxy = ImagePipe2Proxy;
55    type RequestStream = ImagePipe2RequestStream;
56
57    const DEBUG_NAME: &'static str = "(anonymous) ImagePipe2";
58}
59
60pub trait ImagePipe2ProxyInterface: Send + Sync {
61    fn r#add_buffer_collection2(
62        &self,
63        buffer_collection_id: u32,
64        buffer_collection_token: fdomain_client::fidl::ClientEnd<
65            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
66        >,
67    ) -> Result<(), fidl::Error>;
68    fn r#add_buffer_collection(
69        &self,
70        buffer_collection_id: u32,
71        buffer_collection_token: fdomain_client::fidl::ClientEnd<
72            fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
73        >,
74    ) -> Result<(), fidl::Error>;
75    fn r#add_image(
76        &self,
77        image_id: u32,
78        buffer_collection_id: u32,
79        buffer_collection_index: u32,
80        image_format: &fdomain_fuchsia_sysmem::ImageFormat2,
81    ) -> Result<(), fidl::Error>;
82    fn r#remove_buffer_collection(&self, buffer_collection_id: u32) -> Result<(), fidl::Error>;
83    fn r#remove_image(&self, image_id: u32) -> Result<(), fidl::Error>;
84    type PresentImageResponseFut: std::future::Future<Output = Result<PresentationInfo, fidl::Error>>
85        + Send;
86    fn r#present_image(
87        &self,
88        image_id: u32,
89        presentation_time: u64,
90        acquire_fences: Vec<fdomain_client::Event>,
91        release_fences: Vec<fdomain_client::Event>,
92    ) -> Self::PresentImageResponseFut;
93}
94
95#[derive(Debug, Clone)]
96pub struct ImagePipe2Proxy {
97    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
98}
99
100impl fdomain_client::fidl::Proxy for ImagePipe2Proxy {
101    type Protocol = ImagePipe2Marker;
102
103    fn from_channel(inner: fdomain_client::Channel) -> Self {
104        Self::new(inner)
105    }
106
107    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
108        self.client.into_channel().map_err(|client| Self { client })
109    }
110
111    fn as_channel(&self) -> &fdomain_client::Channel {
112        self.client.as_channel()
113    }
114}
115
116impl ImagePipe2Proxy {
117    /// Create a new Proxy for fuchsia.images/ImagePipe2.
118    pub fn new(channel: fdomain_client::Channel) -> Self {
119        let protocol_name = <ImagePipe2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
120        Self { client: fidl::client::Client::new(channel, protocol_name) }
121    }
122
123    /// Get a Stream of events from the remote end of the protocol.
124    ///
125    /// # Panics
126    ///
127    /// Panics if the event stream was already taken.
128    pub fn take_event_stream(&self) -> ImagePipe2EventStream {
129        ImagePipe2EventStream { event_receiver: self.client.take_event_receiver() }
130    }
131
132    /// Adds a BufferCollection resource to the image pipe.
133    ///
134    /// The producer is expected to set constraints on this resource for images added
135    /// via `AddImage()`. The consumer can set its constraints on
136    /// `buffer_collection_token` before or after. Note that the buffers won't be
137    /// allocated until all BufferCollectionToken instances are used to set
138    /// constraints, on both the producer and consumer side. See collection.fidl for
139    /// details.
140    ///
141    /// The following errors will cause the connection to be closed:
142    /// - `buffer_collection_id` is already registered
143    pub fn r#add_buffer_collection2(
144        &self,
145        mut buffer_collection_id: u32,
146        mut buffer_collection_token: fdomain_client::fidl::ClientEnd<
147            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
148        >,
149    ) -> Result<(), fidl::Error> {
150        ImagePipe2ProxyInterface::r#add_buffer_collection2(
151            self,
152            buffer_collection_id,
153            buffer_collection_token,
154        )
155    }
156
157    pub fn r#add_buffer_collection(
158        &self,
159        mut buffer_collection_id: u32,
160        mut buffer_collection_token: fdomain_client::fidl::ClientEnd<
161            fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
162        >,
163    ) -> Result<(), fidl::Error> {
164        ImagePipe2ProxyInterface::r#add_buffer_collection(
165            self,
166            buffer_collection_id,
167            buffer_collection_token,
168        )
169    }
170
171    /// Adds an image resource to image pipe.
172    ///
173    /// `buffer_collection_id` refers to the BufferCollectionToken instance that is
174    /// registered via `AddBufferCollection()`. The underlying memory objects allocated
175    /// are used to address to the image data. `buffer_collection_index` refers to the
176    /// index of the memory object allocated in BufferCollection.
177    ///
178    /// `image_format` specifiies image properties. `coded_width` and `coded_height` are
179    /// used to set image dimensions.
180    ///
181    /// It is valid to create multiple images backed by the same memory object; they
182    /// may even overlap.  Consumers must detect this and handle it accordingly.
183    ///
184    /// The following errors will cause the connection to be closed:
185    /// - `image_id` is already registered
186    /// - `buffer_collection_id` refers to an unregistered BufferCollection.
187    /// - `buffer_collection_index` points to a resource index out of the initialized
188    ///     BufferCollection bounds
189    /// - No resource is allocated in the registered BufferCollection.
190    pub fn r#add_image(
191        &self,
192        mut image_id: u32,
193        mut buffer_collection_id: u32,
194        mut buffer_collection_index: u32,
195        mut image_format: &fdomain_fuchsia_sysmem::ImageFormat2,
196    ) -> Result<(), fidl::Error> {
197        ImagePipe2ProxyInterface::r#add_image(
198            self,
199            image_id,
200            buffer_collection_id,
201            buffer_collection_index,
202            image_format,
203        )
204    }
205
206    /// Removes a BufferCollection resource from the pipe.
207    ///
208    /// The `buffer_collection_id` resource is detached as well as all Images that are
209    /// associated with that BufferCollection. Leads to the same results as calling
210    /// `RemoveImage()` on all Images for `buffer_collection_id`.
211    ///
212    /// The producer must wait for all release fences associated with the Images to
213    /// be signaled before freeing or modifying the underlying memory object since
214    /// the image may still be in use in the presentation queue.
215    ///
216    /// The following errors will cause the connection to be closed:
217    /// - `buffer_collection_id` does not reference a currently registered BufferCollection
218    pub fn r#remove_buffer_collection(
219        &self,
220        mut buffer_collection_id: u32,
221    ) -> Result<(), fidl::Error> {
222        ImagePipe2ProxyInterface::r#remove_buffer_collection(self, buffer_collection_id)
223    }
224
225    /// Removes an image resource from the pipe.
226    ///
227    /// The `image_id` is detached from the image resource and is free to be
228    /// reused to add a new image resource.
229    ///
230    /// Removing an image from the image pipe does not affect the presentation
231    /// queue or the currently presented image.
232    ///
233    /// The producer must wait for all release fences associated with the image to
234    /// be signaled before freeing or modifying the underlying memory object since
235    /// the image may still be in use in the presentation queue.
236    ///
237    /// The following errors will cause the connection to be closed:
238    /// - `image_id` does not reference a currently registered image resource
239    pub fn r#remove_image(&self, mut image_id: u32) -> Result<(), fidl::Error> {
240        ImagePipe2ProxyInterface::r#remove_image(self, image_id)
241    }
242
243    /// Enqueues the specified image for presentation by the consumer.
244    ///
245    /// The `acquire_fences` are a set of fences which must all be signaled by
246    /// the producer before the consumer presents the image.
247    /// The `release_fences` are a set of fences which inform the producer that
248    /// it's safe to free or modify the `image_id` image, and it's safe to
249    /// re-use the fences in `acquire_fences`. The consumer must signal all the
250    /// fences in `release_fences` after `image_id` is no longer being
251    /// presented. The producer may reuse resources after any of the
252    /// `release_fences` is signaled.
253    ///
254    /// This design allows a producer to distribute image processing across
255    /// multiple threads / processes without unnecessary coordination delay.
256    /// Each thread / process signals its own fence in `acquire_fences` when
257    /// it's done rendering its piece of `image_id`, and waits on its own fence
258    /// in `release_fences` to render new content in `image_id`.
259    ///
260    /// `presentation_time` specifies the time on or after which the
261    /// client would like the enqueued operations should take visible effect
262    /// (light up pixels on the screen), expressed in nanoseconds in the
263    /// `CLOCK_MONOTONIC` timebase.  Desired presentation times must be
264    /// monotonically non-decreasing.
265    ///
266    /// `presentation_info` returns timing information about the submitted frame
267    /// and future frames (see presentation_info.fidl).
268    ///
269    /// The producer may decide not to signal `acquire_fences` for an image.
270    /// In that case, if a later image is enqueued and later image's
271    /// `presentation_time` is reached, the consumer presents the later image when
272    /// later image's `acquire_fences` are signaled. The consumer also signals
273    /// earlier image's `release_fences` and removes it from the presentation queue.
274    /// This sequence works as a cancellation mechanism.
275    ///
276    /// The following errors will cause the connection to be closed:
277    /// - `image_id` does not reference a currently registered image resource
278    pub fn r#present_image(
279        &self,
280        mut image_id: u32,
281        mut presentation_time: u64,
282        mut acquire_fences: Vec<fdomain_client::Event>,
283        mut release_fences: Vec<fdomain_client::Event>,
284    ) -> fidl::client::QueryResponseFut<
285        PresentationInfo,
286        fdomain_client::fidl::FDomainResourceDialect,
287    > {
288        ImagePipe2ProxyInterface::r#present_image(
289            self,
290            image_id,
291            presentation_time,
292            acquire_fences,
293            release_fences,
294        )
295    }
296}
297
298impl ImagePipe2ProxyInterface for ImagePipe2Proxy {
299    fn r#add_buffer_collection2(
300        &self,
301        mut buffer_collection_id: u32,
302        mut buffer_collection_token: fdomain_client::fidl::ClientEnd<
303            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
304        >,
305    ) -> Result<(), fidl::Error> {
306        self.client.send::<ImagePipe2AddBufferCollection2Request>(
307            (buffer_collection_id, buffer_collection_token),
308            0x181c72c935b0b4ee,
309            fidl::encoding::DynamicFlags::empty(),
310        )
311    }
312
313    fn r#add_buffer_collection(
314        &self,
315        mut buffer_collection_id: u32,
316        mut buffer_collection_token: fdomain_client::fidl::ClientEnd<
317            fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
318        >,
319    ) -> Result<(), fidl::Error> {
320        self.client.send::<ImagePipe2AddBufferCollectionRequest>(
321            (buffer_collection_id, buffer_collection_token),
322            0x663ec76e20c87c05,
323            fidl::encoding::DynamicFlags::empty(),
324        )
325    }
326
327    fn r#add_image(
328        &self,
329        mut image_id: u32,
330        mut buffer_collection_id: u32,
331        mut buffer_collection_index: u32,
332        mut image_format: &fdomain_fuchsia_sysmem::ImageFormat2,
333    ) -> Result<(), fidl::Error> {
334        self.client.send::<ImagePipe2AddImageRequest>(
335            (image_id, buffer_collection_id, buffer_collection_index, image_format),
336            0x23566808b13af395,
337            fidl::encoding::DynamicFlags::empty(),
338        )
339    }
340
341    fn r#remove_buffer_collection(&self, mut buffer_collection_id: u32) -> Result<(), fidl::Error> {
342        self.client.send::<ImagePipe2RemoveBufferCollectionRequest>(
343            (buffer_collection_id,),
344            0x16bebb759a932299,
345            fidl::encoding::DynamicFlags::empty(),
346        )
347    }
348
349    fn r#remove_image(&self, mut image_id: u32) -> Result<(), fidl::Error> {
350        self.client.send::<ImagePipe2RemoveImageRequest>(
351            (image_id,),
352            0x16e8edd0f4d50f68,
353            fidl::encoding::DynamicFlags::empty(),
354        )
355    }
356
357    type PresentImageResponseFut = fidl::client::QueryResponseFut<
358        PresentationInfo,
359        fdomain_client::fidl::FDomainResourceDialect,
360    >;
361    fn r#present_image(
362        &self,
363        mut image_id: u32,
364        mut presentation_time: u64,
365        mut acquire_fences: Vec<fdomain_client::Event>,
366        mut release_fences: Vec<fdomain_client::Event>,
367    ) -> Self::PresentImageResponseFut {
368        fn _decode(
369            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
370        ) -> Result<PresentationInfo, fidl::Error> {
371            let _response = fidl::client::decode_transaction_body::<
372                ImagePipe2PresentImageResponse,
373                fdomain_client::fidl::FDomainResourceDialect,
374                0x73cfb50f577c143a,
375            >(_buf?)?;
376            Ok(_response.presentation_info)
377        }
378        self.client.send_query_and_decode::<ImagePipe2PresentImageRequest, PresentationInfo>(
379            (image_id, presentation_time, acquire_fences.as_mut(), release_fences.as_mut()),
380            0x73cfb50f577c143a,
381            fidl::encoding::DynamicFlags::empty(),
382            _decode,
383        )
384    }
385}
386
387pub struct ImagePipe2EventStream {
388    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
389}
390
391impl std::marker::Unpin for ImagePipe2EventStream {}
392
393impl futures::stream::FusedStream for ImagePipe2EventStream {
394    fn is_terminated(&self) -> bool {
395        self.event_receiver.is_terminated()
396    }
397}
398
399impl futures::Stream for ImagePipe2EventStream {
400    type Item = Result<ImagePipe2Event, fidl::Error>;
401
402    fn poll_next(
403        mut self: std::pin::Pin<&mut Self>,
404        cx: &mut std::task::Context<'_>,
405    ) -> std::task::Poll<Option<Self::Item>> {
406        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
407            &mut self.event_receiver,
408            cx
409        )?) {
410            Some(buf) => std::task::Poll::Ready(Some(ImagePipe2Event::decode(buf))),
411            None => std::task::Poll::Ready(None),
412        }
413    }
414}
415
416#[derive(Debug)]
417pub enum ImagePipe2Event {}
418
419impl ImagePipe2Event {
420    /// Decodes a message buffer as a [`ImagePipe2Event`].
421    fn decode(
422        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
423    ) -> Result<ImagePipe2Event, fidl::Error> {
424        let (bytes, _handles) = buf.split_mut();
425        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
426        debug_assert_eq!(tx_header.tx_id, 0);
427        match tx_header.ordinal {
428            _ => Err(fidl::Error::UnknownOrdinal {
429                ordinal: tx_header.ordinal,
430                protocol_name:
431                    <ImagePipe2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
432            }),
433        }
434    }
435}
436
437/// A Stream of incoming requests for fuchsia.images/ImagePipe2.
438pub struct ImagePipe2RequestStream {
439    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
440    is_terminated: bool,
441}
442
443impl std::marker::Unpin for ImagePipe2RequestStream {}
444
445impl futures::stream::FusedStream for ImagePipe2RequestStream {
446    fn is_terminated(&self) -> bool {
447        self.is_terminated
448    }
449}
450
451impl fdomain_client::fidl::RequestStream for ImagePipe2RequestStream {
452    type Protocol = ImagePipe2Marker;
453    type ControlHandle = ImagePipe2ControlHandle;
454
455    fn from_channel(channel: fdomain_client::Channel) -> Self {
456        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
457    }
458
459    fn control_handle(&self) -> Self::ControlHandle {
460        ImagePipe2ControlHandle { inner: self.inner.clone() }
461    }
462
463    fn into_inner(
464        self,
465    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
466    {
467        (self.inner, self.is_terminated)
468    }
469
470    fn from_inner(
471        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
472        is_terminated: bool,
473    ) -> Self {
474        Self { inner, is_terminated }
475    }
476}
477
478impl futures::Stream for ImagePipe2RequestStream {
479    type Item = Result<ImagePipe2Request, fidl::Error>;
480
481    fn poll_next(
482        mut self: std::pin::Pin<&mut Self>,
483        cx: &mut std::task::Context<'_>,
484    ) -> std::task::Poll<Option<Self::Item>> {
485        let this = &mut *self;
486        if this.inner.check_shutdown(cx) {
487            this.is_terminated = true;
488            return std::task::Poll::Ready(None);
489        }
490        if this.is_terminated {
491            panic!("polled ImagePipe2RequestStream after completion");
492        }
493        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
494            |bytes, handles| {
495                match this.inner.channel().read_etc(cx, bytes, handles) {
496                    std::task::Poll::Ready(Ok(())) => {}
497                    std::task::Poll::Pending => return std::task::Poll::Pending,
498                    std::task::Poll::Ready(Err(None)) => {
499                        this.is_terminated = true;
500                        return std::task::Poll::Ready(None);
501                    }
502                    std::task::Poll::Ready(Err(Some(e))) => {
503                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
504                            e.into(),
505                        ))));
506                    }
507                }
508
509                // A message has been received from the channel
510                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
511
512                std::task::Poll::Ready(Some(match header.ordinal {
513                    0x181c72c935b0b4ee => {
514                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
515                        let mut req = fidl::new_empty!(
516                            ImagePipe2AddBufferCollection2Request,
517                            fdomain_client::fidl::FDomainResourceDialect
518                        );
519                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ImagePipe2AddBufferCollection2Request>(&header, _body_bytes, handles, &mut req)?;
520                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
521                        Ok(ImagePipe2Request::AddBufferCollection2 {
522                            buffer_collection_id: req.buffer_collection_id,
523                            buffer_collection_token: req.buffer_collection_token,
524
525                            control_handle,
526                        })
527                    }
528                    0x663ec76e20c87c05 => {
529                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
530                        let mut req = fidl::new_empty!(
531                            ImagePipe2AddBufferCollectionRequest,
532                            fdomain_client::fidl::FDomainResourceDialect
533                        );
534                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ImagePipe2AddBufferCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
535                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
536                        Ok(ImagePipe2Request::AddBufferCollection {
537                            buffer_collection_id: req.buffer_collection_id,
538                            buffer_collection_token: req.buffer_collection_token,
539
540                            control_handle,
541                        })
542                    }
543                    0x23566808b13af395 => {
544                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
545                        let mut req = fidl::new_empty!(
546                            ImagePipe2AddImageRequest,
547                            fdomain_client::fidl::FDomainResourceDialect
548                        );
549                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ImagePipe2AddImageRequest>(&header, _body_bytes, handles, &mut req)?;
550                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
551                        Ok(ImagePipe2Request::AddImage {
552                            image_id: req.image_id,
553                            buffer_collection_id: req.buffer_collection_id,
554                            buffer_collection_index: req.buffer_collection_index,
555                            image_format: req.image_format,
556
557                            control_handle,
558                        })
559                    }
560                    0x16bebb759a932299 => {
561                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
562                        let mut req = fidl::new_empty!(
563                            ImagePipe2RemoveBufferCollectionRequest,
564                            fdomain_client::fidl::FDomainResourceDialect
565                        );
566                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ImagePipe2RemoveBufferCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
567                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
568                        Ok(ImagePipe2Request::RemoveBufferCollection {
569                            buffer_collection_id: req.buffer_collection_id,
570
571                            control_handle,
572                        })
573                    }
574                    0x16e8edd0f4d50f68 => {
575                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
576                        let mut req = fidl::new_empty!(
577                            ImagePipe2RemoveImageRequest,
578                            fdomain_client::fidl::FDomainResourceDialect
579                        );
580                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ImagePipe2RemoveImageRequest>(&header, _body_bytes, handles, &mut req)?;
581                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
582                        Ok(ImagePipe2Request::RemoveImage {
583                            image_id: req.image_id,
584
585                            control_handle,
586                        })
587                    }
588                    0x73cfb50f577c143a => {
589                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
590                        let mut req = fidl::new_empty!(
591                            ImagePipe2PresentImageRequest,
592                            fdomain_client::fidl::FDomainResourceDialect
593                        );
594                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ImagePipe2PresentImageRequest>(&header, _body_bytes, handles, &mut req)?;
595                        let control_handle = ImagePipe2ControlHandle { inner: this.inner.clone() };
596                        Ok(ImagePipe2Request::PresentImage {
597                            image_id: req.image_id,
598                            presentation_time: req.presentation_time,
599                            acquire_fences: req.acquire_fences,
600                            release_fences: req.release_fences,
601
602                            responder: ImagePipe2PresentImageResponder {
603                                control_handle: std::mem::ManuallyDrop::new(control_handle),
604                                tx_id: header.tx_id,
605                            },
606                        })
607                    }
608                    _ => Err(fidl::Error::UnknownOrdinal {
609                        ordinal: header.ordinal,
610                        protocol_name:
611                            <ImagePipe2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
612                    }),
613                }))
614            },
615        )
616    }
617}
618
619/// ImagePipe is a mechanism for streaming shared images between a producer
620/// and a consumer which may be running in different processes.
621///
622/// Conceptually, the image pipe maintains a table of image resources supplied
623/// by the producer into which graphical content may be stored as well as a
624/// presentation queue containing a sequence of images which the producer has
625/// asked the consumer to present.
626///
627/// The presentation queue is initially empty.
628///
629/// Each entry in the presentation queue consists of an image together with a
630/// pair of optional synchronization fences:
631/// - Acquire fence: signaled by the producer when the image is ready to be consumed
632/// - Release fence: signaled by the consumer when the image is free to be freed or
633///   modified by the producer
634///
635/// The producer performs the following sequence of steps to present content:
636/// - Allocate and add some number of BufferCollections to the image pipe to allow
637/// consumer to set constraints.
638/// - Allocate and add some number of images (often 2 or 3) to the image pipe
639///   to establish a pool using `AddImage()`.
640/// - Obtain the next available image from the pool.
641/// - Ask the consumer to enqueue an image for presentation and provide fences
642///   using `PresentImage()`.
643/// - Start rendering the image.
644/// - Signal the image's acquire fence when rendering is complete.
645/// - Loop to present more image, listen for signals on release fences to recycle
646///   images back into the pool.
647///
648/// The consumer performs the following sequence of steps for each image which
649/// is enqueued in the presentation queue:
650/// - Await signals on the image's acquire fence.
651/// - If the fence wait cannot be satisfied or if some other error is detected,
652///   close the image pipe.
653///   Otherwise, begin presenting the image's content.
654/// - Retire the previously presented image (if any) from the presentation queue
655///   and signal its release fence when no longer needed.
656/// - Continue presenting the same image until the next one is ready.  Loop.
657///
658/// If the producer wants to close the image pipe, it should:
659/// - Close its side of the connection.
660/// - Wait on all release fences for buffers that it has submitted with
661///   `PresentImage()`.
662/// - Proceed with resource cleanup.
663///
664/// When the consumer detects the image pipe has closed, it should:
665/// - Stop using/presenting any images from the pipe.
666/// - Unmap all memory objects associated with the images in the pipe.
667/// - Close all BufferCollection resources.
668/// - Signal all release fences for presented and queued buffers.
669/// - Close all handles to fences.
670/// - Close its side of the connection.
671///
672/// When either party detects that a fence has been abandoned (remotely closed
673/// without being signaled) it should assume that the associated image is in
674/// an indeterminate state.  This will typically happen when the other party
675/// (or one of its delegates) has crashed.  The safest course of action is to
676/// close the image pipe, release all resources which were shared with the
677/// other party, and re-establish the connection to recover.
678#[derive(Debug)]
679pub enum ImagePipe2Request {
680    /// Adds a BufferCollection resource to the image pipe.
681    ///
682    /// The producer is expected to set constraints on this resource for images added
683    /// via `AddImage()`. The consumer can set its constraints on
684    /// `buffer_collection_token` before or after. Note that the buffers won't be
685    /// allocated until all BufferCollectionToken instances are used to set
686    /// constraints, on both the producer and consumer side. See collection.fidl for
687    /// details.
688    ///
689    /// The following errors will cause the connection to be closed:
690    /// - `buffer_collection_id` is already registered
691    AddBufferCollection2 {
692        buffer_collection_id: u32,
693        buffer_collection_token:
694            fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker>,
695        control_handle: ImagePipe2ControlHandle,
696    },
697    AddBufferCollection {
698        buffer_collection_id: u32,
699        buffer_collection_token:
700            fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem::BufferCollectionTokenMarker>,
701        control_handle: ImagePipe2ControlHandle,
702    },
703    /// Adds an image resource to image pipe.
704    ///
705    /// `buffer_collection_id` refers to the BufferCollectionToken instance that is
706    /// registered via `AddBufferCollection()`. The underlying memory objects allocated
707    /// are used to address to the image data. `buffer_collection_index` refers to the
708    /// index of the memory object allocated in BufferCollection.
709    ///
710    /// `image_format` specifiies image properties. `coded_width` and `coded_height` are
711    /// used to set image dimensions.
712    ///
713    /// It is valid to create multiple images backed by the same memory object; they
714    /// may even overlap.  Consumers must detect this and handle it accordingly.
715    ///
716    /// The following errors will cause the connection to be closed:
717    /// - `image_id` is already registered
718    /// - `buffer_collection_id` refers to an unregistered BufferCollection.
719    /// - `buffer_collection_index` points to a resource index out of the initialized
720    ///     BufferCollection bounds
721    /// - No resource is allocated in the registered BufferCollection.
722    AddImage {
723        image_id: u32,
724        buffer_collection_id: u32,
725        buffer_collection_index: u32,
726        image_format: fdomain_fuchsia_sysmem::ImageFormat2,
727        control_handle: ImagePipe2ControlHandle,
728    },
729    /// Removes a BufferCollection resource from the pipe.
730    ///
731    /// The `buffer_collection_id` resource is detached as well as all Images that are
732    /// associated with that BufferCollection. Leads to the same results as calling
733    /// `RemoveImage()` on all Images for `buffer_collection_id`.
734    ///
735    /// The producer must wait for all release fences associated with the Images to
736    /// be signaled before freeing or modifying the underlying memory object since
737    /// the image may still be in use in the presentation queue.
738    ///
739    /// The following errors will cause the connection to be closed:
740    /// - `buffer_collection_id` does not reference a currently registered BufferCollection
741    RemoveBufferCollection { buffer_collection_id: u32, control_handle: ImagePipe2ControlHandle },
742    /// Removes an image resource from the pipe.
743    ///
744    /// The `image_id` is detached from the image resource and is free to be
745    /// reused to add a new image resource.
746    ///
747    /// Removing an image from the image pipe does not affect the presentation
748    /// queue or the currently presented image.
749    ///
750    /// The producer must wait for all release fences associated with the image to
751    /// be signaled before freeing or modifying the underlying memory object since
752    /// the image may still be in use in the presentation queue.
753    ///
754    /// The following errors will cause the connection to be closed:
755    /// - `image_id` does not reference a currently registered image resource
756    RemoveImage { image_id: u32, control_handle: ImagePipe2ControlHandle },
757    /// Enqueues the specified image for presentation by the consumer.
758    ///
759    /// The `acquire_fences` are a set of fences which must all be signaled by
760    /// the producer before the consumer presents the image.
761    /// The `release_fences` are a set of fences which inform the producer that
762    /// it's safe to free or modify the `image_id` image, and it's safe to
763    /// re-use the fences in `acquire_fences`. The consumer must signal all the
764    /// fences in `release_fences` after `image_id` is no longer being
765    /// presented. The producer may reuse resources after any of the
766    /// `release_fences` is signaled.
767    ///
768    /// This design allows a producer to distribute image processing across
769    /// multiple threads / processes without unnecessary coordination delay.
770    /// Each thread / process signals its own fence in `acquire_fences` when
771    /// it's done rendering its piece of `image_id`, and waits on its own fence
772    /// in `release_fences` to render new content in `image_id`.
773    ///
774    /// `presentation_time` specifies the time on or after which the
775    /// client would like the enqueued operations should take visible effect
776    /// (light up pixels on the screen), expressed in nanoseconds in the
777    /// `CLOCK_MONOTONIC` timebase.  Desired presentation times must be
778    /// monotonically non-decreasing.
779    ///
780    /// `presentation_info` returns timing information about the submitted frame
781    /// and future frames (see presentation_info.fidl).
782    ///
783    /// The producer may decide not to signal `acquire_fences` for an image.
784    /// In that case, if a later image is enqueued and later image's
785    /// `presentation_time` is reached, the consumer presents the later image when
786    /// later image's `acquire_fences` are signaled. The consumer also signals
787    /// earlier image's `release_fences` and removes it from the presentation queue.
788    /// This sequence works as a cancellation mechanism.
789    ///
790    /// The following errors will cause the connection to be closed:
791    /// - `image_id` does not reference a currently registered image resource
792    PresentImage {
793        image_id: u32,
794        presentation_time: u64,
795        acquire_fences: Vec<fdomain_client::Event>,
796        release_fences: Vec<fdomain_client::Event>,
797        responder: ImagePipe2PresentImageResponder,
798    },
799}
800
801impl ImagePipe2Request {
802    #[allow(irrefutable_let_patterns)]
803    pub fn into_add_buffer_collection2(
804        self,
805    ) -> Option<(
806        u32,
807        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker>,
808        ImagePipe2ControlHandle,
809    )> {
810        if let ImagePipe2Request::AddBufferCollection2 {
811            buffer_collection_id,
812            buffer_collection_token,
813            control_handle,
814        } = self
815        {
816            Some((buffer_collection_id, buffer_collection_token, control_handle))
817        } else {
818            None
819        }
820    }
821
822    #[allow(irrefutable_let_patterns)]
823    pub fn into_add_buffer_collection(
824        self,
825    ) -> Option<(
826        u32,
827        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem::BufferCollectionTokenMarker>,
828        ImagePipe2ControlHandle,
829    )> {
830        if let ImagePipe2Request::AddBufferCollection {
831            buffer_collection_id,
832            buffer_collection_token,
833            control_handle,
834        } = self
835        {
836            Some((buffer_collection_id, buffer_collection_token, control_handle))
837        } else {
838            None
839        }
840    }
841
842    #[allow(irrefutable_let_patterns)]
843    pub fn into_add_image(
844        self,
845    ) -> Option<(u32, u32, u32, fdomain_fuchsia_sysmem::ImageFormat2, ImagePipe2ControlHandle)>
846    {
847        if let ImagePipe2Request::AddImage {
848            image_id,
849            buffer_collection_id,
850            buffer_collection_index,
851            image_format,
852            control_handle,
853        } = self
854        {
855            Some((
856                image_id,
857                buffer_collection_id,
858                buffer_collection_index,
859                image_format,
860                control_handle,
861            ))
862        } else {
863            None
864        }
865    }
866
867    #[allow(irrefutable_let_patterns)]
868    pub fn into_remove_buffer_collection(self) -> Option<(u32, ImagePipe2ControlHandle)> {
869        if let ImagePipe2Request::RemoveBufferCollection { buffer_collection_id, control_handle } =
870            self
871        {
872            Some((buffer_collection_id, control_handle))
873        } else {
874            None
875        }
876    }
877
878    #[allow(irrefutable_let_patterns)]
879    pub fn into_remove_image(self) -> Option<(u32, ImagePipe2ControlHandle)> {
880        if let ImagePipe2Request::RemoveImage { image_id, control_handle } = self {
881            Some((image_id, control_handle))
882        } else {
883            None
884        }
885    }
886
887    #[allow(irrefutable_let_patterns)]
888    pub fn into_present_image(
889        self,
890    ) -> Option<(
891        u32,
892        u64,
893        Vec<fdomain_client::Event>,
894        Vec<fdomain_client::Event>,
895        ImagePipe2PresentImageResponder,
896    )> {
897        if let ImagePipe2Request::PresentImage {
898            image_id,
899            presentation_time,
900            acquire_fences,
901            release_fences,
902            responder,
903        } = self
904        {
905            Some((image_id, presentation_time, acquire_fences, release_fences, responder))
906        } else {
907            None
908        }
909    }
910
911    /// Name of the method defined in FIDL
912    pub fn method_name(&self) -> &'static str {
913        match *self {
914            ImagePipe2Request::AddBufferCollection2 { .. } => "add_buffer_collection2",
915            ImagePipe2Request::AddBufferCollection { .. } => "add_buffer_collection",
916            ImagePipe2Request::AddImage { .. } => "add_image",
917            ImagePipe2Request::RemoveBufferCollection { .. } => "remove_buffer_collection",
918            ImagePipe2Request::RemoveImage { .. } => "remove_image",
919            ImagePipe2Request::PresentImage { .. } => "present_image",
920        }
921    }
922}
923
924#[derive(Debug, Clone)]
925pub struct ImagePipe2ControlHandle {
926    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
927}
928
929impl ImagePipe2ControlHandle {
930    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
931        self.inner.shutdown_with_epitaph(status.into())
932    }
933}
934
935impl fdomain_client::fidl::ControlHandle for ImagePipe2ControlHandle {
936    fn shutdown(&self) {
937        self.inner.shutdown()
938    }
939
940    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
941        self.inner.shutdown_with_epitaph(status)
942    }
943
944    fn is_closed(&self) -> bool {
945        self.inner.channel().is_closed()
946    }
947    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
948        self.inner.channel().on_closed()
949    }
950}
951
952impl ImagePipe2ControlHandle {}
953
954#[must_use = "FIDL methods require a response to be sent"]
955#[derive(Debug)]
956pub struct ImagePipe2PresentImageResponder {
957    control_handle: std::mem::ManuallyDrop<ImagePipe2ControlHandle>,
958    tx_id: u32,
959}
960
961/// Set the the channel to be shutdown (see [`ImagePipe2ControlHandle::shutdown`])
962/// if the responder is dropped without sending a response, so that the client
963/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
964impl std::ops::Drop for ImagePipe2PresentImageResponder {
965    fn drop(&mut self) {
966        self.control_handle.shutdown();
967        // Safety: drops once, never accessed again
968        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
969    }
970}
971
972impl fdomain_client::fidl::Responder for ImagePipe2PresentImageResponder {
973    type ControlHandle = ImagePipe2ControlHandle;
974
975    fn control_handle(&self) -> &ImagePipe2ControlHandle {
976        &self.control_handle
977    }
978
979    fn drop_without_shutdown(mut self) {
980        // Safety: drops once, never accessed again due to mem::forget
981        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
982        // Prevent Drop from running (which would shut down the channel)
983        std::mem::forget(self);
984    }
985}
986
987impl ImagePipe2PresentImageResponder {
988    /// Sends a response to the FIDL transaction.
989    ///
990    /// Sets the channel to shutdown if an error occurs.
991    pub fn send(self, mut presentation_info: &PresentationInfo) -> Result<(), fidl::Error> {
992        let _result = self.send_raw(presentation_info);
993        if _result.is_err() {
994            self.control_handle.shutdown();
995        }
996        self.drop_without_shutdown();
997        _result
998    }
999
1000    /// Similar to "send" but does not shutdown the channel if an error occurs.
1001    pub fn send_no_shutdown_on_err(
1002        self,
1003        mut presentation_info: &PresentationInfo,
1004    ) -> Result<(), fidl::Error> {
1005        let _result = self.send_raw(presentation_info);
1006        self.drop_without_shutdown();
1007        _result
1008    }
1009
1010    fn send_raw(&self, mut presentation_info: &PresentationInfo) -> Result<(), fidl::Error> {
1011        self.control_handle.inner.send::<ImagePipe2PresentImageResponse>(
1012            (presentation_info,),
1013            self.tx_id,
1014            0x73cfb50f577c143a,
1015            fidl::encoding::DynamicFlags::empty(),
1016        )
1017    }
1018}
1019
1020mod internal {
1021    use super::*;
1022
1023    impl fidl::encoding::ResourceTypeMarker for ImagePipe2AddBufferCollection2Request {
1024        type Borrowed<'a> = &'a mut Self;
1025        fn take_or_borrow<'a>(
1026            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1027        ) -> Self::Borrowed<'a> {
1028            value
1029        }
1030    }
1031
1032    unsafe impl fidl::encoding::TypeMarker for ImagePipe2AddBufferCollection2Request {
1033        type Owned = Self;
1034
1035        #[inline(always)]
1036        fn inline_align(_context: fidl::encoding::Context) -> usize {
1037            4
1038        }
1039
1040        #[inline(always)]
1041        fn inline_size(_context: fidl::encoding::Context) -> usize {
1042            8
1043        }
1044    }
1045
1046    unsafe impl
1047        fidl::encoding::Encode<
1048            ImagePipe2AddBufferCollection2Request,
1049            fdomain_client::fidl::FDomainResourceDialect,
1050        > for &mut ImagePipe2AddBufferCollection2Request
1051    {
1052        #[inline]
1053        unsafe fn encode(
1054            self,
1055            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1056            offset: usize,
1057            _depth: fidl::encoding::Depth,
1058        ) -> fidl::Result<()> {
1059            encoder.debug_check_bounds::<ImagePipe2AddBufferCollection2Request>(offset);
1060            // Delegate to tuple encoding.
1061            fidl::encoding::Encode::<
1062                ImagePipe2AddBufferCollection2Request,
1063                fdomain_client::fidl::FDomainResourceDialect,
1064            >::encode(
1065                (
1066                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_collection_id),
1067                    <fidl::encoding::Endpoint<
1068                        fdomain_client::fidl::ClientEnd<
1069                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
1070                        >,
1071                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1072                        &mut self.buffer_collection_token,
1073                    ),
1074                ),
1075                encoder,
1076                offset,
1077                _depth,
1078            )
1079        }
1080    }
1081    unsafe impl<
1082        T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
1083        T1: fidl::encoding::Encode<
1084                fidl::encoding::Endpoint<
1085                    fdomain_client::fidl::ClientEnd<
1086                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
1087                    >,
1088                >,
1089                fdomain_client::fidl::FDomainResourceDialect,
1090            >,
1091    >
1092        fidl::encoding::Encode<
1093            ImagePipe2AddBufferCollection2Request,
1094            fdomain_client::fidl::FDomainResourceDialect,
1095        > for (T0, T1)
1096    {
1097        #[inline]
1098        unsafe fn encode(
1099            self,
1100            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1101            offset: usize,
1102            depth: fidl::encoding::Depth,
1103        ) -> fidl::Result<()> {
1104            encoder.debug_check_bounds::<ImagePipe2AddBufferCollection2Request>(offset);
1105            // Zero out padding regions. There's no need to apply masks
1106            // because the unmasked parts will be overwritten by fields.
1107            // Write the fields.
1108            self.0.encode(encoder, offset + 0, depth)?;
1109            self.1.encode(encoder, offset + 4, depth)?;
1110            Ok(())
1111        }
1112    }
1113
1114    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1115        for ImagePipe2AddBufferCollection2Request
1116    {
1117        #[inline(always)]
1118        fn new_empty() -> Self {
1119            Self {
1120                buffer_collection_id: fidl::new_empty!(
1121                    u32,
1122                    fdomain_client::fidl::FDomainResourceDialect
1123                ),
1124                buffer_collection_token: fidl::new_empty!(
1125                    fidl::encoding::Endpoint<
1126                        fdomain_client::fidl::ClientEnd<
1127                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
1128                        >,
1129                    >,
1130                    fdomain_client::fidl::FDomainResourceDialect
1131                ),
1132            }
1133        }
1134
1135        #[inline]
1136        unsafe fn decode(
1137            &mut self,
1138            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1139            offset: usize,
1140            _depth: fidl::encoding::Depth,
1141        ) -> fidl::Result<()> {
1142            decoder.debug_check_bounds::<Self>(offset);
1143            // Verify that padding bytes are zero.
1144            fidl::decode!(
1145                u32,
1146                fdomain_client::fidl::FDomainResourceDialect,
1147                &mut self.buffer_collection_id,
1148                decoder,
1149                offset + 0,
1150                _depth
1151            )?;
1152            fidl::decode!(
1153                fidl::encoding::Endpoint<
1154                    fdomain_client::fidl::ClientEnd<
1155                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
1156                    >,
1157                >,
1158                fdomain_client::fidl::FDomainResourceDialect,
1159                &mut self.buffer_collection_token,
1160                decoder,
1161                offset + 4,
1162                _depth
1163            )?;
1164            Ok(())
1165        }
1166    }
1167
1168    impl fidl::encoding::ResourceTypeMarker for ImagePipe2AddBufferCollectionRequest {
1169        type Borrowed<'a> = &'a mut Self;
1170        fn take_or_borrow<'a>(
1171            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1172        ) -> Self::Borrowed<'a> {
1173            value
1174        }
1175    }
1176
1177    unsafe impl fidl::encoding::TypeMarker for ImagePipe2AddBufferCollectionRequest {
1178        type Owned = Self;
1179
1180        #[inline(always)]
1181        fn inline_align(_context: fidl::encoding::Context) -> usize {
1182            4
1183        }
1184
1185        #[inline(always)]
1186        fn inline_size(_context: fidl::encoding::Context) -> usize {
1187            8
1188        }
1189    }
1190
1191    unsafe impl
1192        fidl::encoding::Encode<
1193            ImagePipe2AddBufferCollectionRequest,
1194            fdomain_client::fidl::FDomainResourceDialect,
1195        > for &mut ImagePipe2AddBufferCollectionRequest
1196    {
1197        #[inline]
1198        unsafe fn encode(
1199            self,
1200            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1201            offset: usize,
1202            _depth: fidl::encoding::Depth,
1203        ) -> fidl::Result<()> {
1204            encoder.debug_check_bounds::<ImagePipe2AddBufferCollectionRequest>(offset);
1205            // Delegate to tuple encoding.
1206            fidl::encoding::Encode::<
1207                ImagePipe2AddBufferCollectionRequest,
1208                fdomain_client::fidl::FDomainResourceDialect,
1209            >::encode(
1210                (
1211                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_collection_id),
1212                    <fidl::encoding::Endpoint<
1213                        fdomain_client::fidl::ClientEnd<
1214                            fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
1215                        >,
1216                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1217                        &mut self.buffer_collection_token,
1218                    ),
1219                ),
1220                encoder,
1221                offset,
1222                _depth,
1223            )
1224        }
1225    }
1226    unsafe impl<
1227        T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
1228        T1: fidl::encoding::Encode<
1229                fidl::encoding::Endpoint<
1230                    fdomain_client::fidl::ClientEnd<
1231                        fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
1232                    >,
1233                >,
1234                fdomain_client::fidl::FDomainResourceDialect,
1235            >,
1236    >
1237        fidl::encoding::Encode<
1238            ImagePipe2AddBufferCollectionRequest,
1239            fdomain_client::fidl::FDomainResourceDialect,
1240        > for (T0, T1)
1241    {
1242        #[inline]
1243        unsafe fn encode(
1244            self,
1245            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1246            offset: usize,
1247            depth: fidl::encoding::Depth,
1248        ) -> fidl::Result<()> {
1249            encoder.debug_check_bounds::<ImagePipe2AddBufferCollectionRequest>(offset);
1250            // Zero out padding regions. There's no need to apply masks
1251            // because the unmasked parts will be overwritten by fields.
1252            // Write the fields.
1253            self.0.encode(encoder, offset + 0, depth)?;
1254            self.1.encode(encoder, offset + 4, depth)?;
1255            Ok(())
1256        }
1257    }
1258
1259    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1260        for ImagePipe2AddBufferCollectionRequest
1261    {
1262        #[inline(always)]
1263        fn new_empty() -> Self {
1264            Self {
1265                buffer_collection_id: fidl::new_empty!(
1266                    u32,
1267                    fdomain_client::fidl::FDomainResourceDialect
1268                ),
1269                buffer_collection_token: fidl::new_empty!(
1270                    fidl::encoding::Endpoint<
1271                        fdomain_client::fidl::ClientEnd<
1272                            fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
1273                        >,
1274                    >,
1275                    fdomain_client::fidl::FDomainResourceDialect
1276                ),
1277            }
1278        }
1279
1280        #[inline]
1281        unsafe fn decode(
1282            &mut self,
1283            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1284            offset: usize,
1285            _depth: fidl::encoding::Depth,
1286        ) -> fidl::Result<()> {
1287            decoder.debug_check_bounds::<Self>(offset);
1288            // Verify that padding bytes are zero.
1289            fidl::decode!(
1290                u32,
1291                fdomain_client::fidl::FDomainResourceDialect,
1292                &mut self.buffer_collection_id,
1293                decoder,
1294                offset + 0,
1295                _depth
1296            )?;
1297            fidl::decode!(
1298                fidl::encoding::Endpoint<
1299                    fdomain_client::fidl::ClientEnd<
1300                        fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
1301                    >,
1302                >,
1303                fdomain_client::fidl::FDomainResourceDialect,
1304                &mut self.buffer_collection_token,
1305                decoder,
1306                offset + 4,
1307                _depth
1308            )?;
1309            Ok(())
1310        }
1311    }
1312
1313    impl fidl::encoding::ResourceTypeMarker for ImagePipe2PresentImageRequest {
1314        type Borrowed<'a> = &'a mut Self;
1315        fn take_or_borrow<'a>(
1316            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1317        ) -> Self::Borrowed<'a> {
1318            value
1319        }
1320    }
1321
1322    unsafe impl fidl::encoding::TypeMarker for ImagePipe2PresentImageRequest {
1323        type Owned = Self;
1324
1325        #[inline(always)]
1326        fn inline_align(_context: fidl::encoding::Context) -> usize {
1327            8
1328        }
1329
1330        #[inline(always)]
1331        fn inline_size(_context: fidl::encoding::Context) -> usize {
1332            48
1333        }
1334    }
1335
1336    unsafe impl
1337        fidl::encoding::Encode<
1338            ImagePipe2PresentImageRequest,
1339            fdomain_client::fidl::FDomainResourceDialect,
1340        > for &mut ImagePipe2PresentImageRequest
1341    {
1342        #[inline]
1343        unsafe fn encode(
1344            self,
1345            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1346            offset: usize,
1347            _depth: fidl::encoding::Depth,
1348        ) -> fidl::Result<()> {
1349            encoder.debug_check_bounds::<ImagePipe2PresentImageRequest>(offset);
1350            // Delegate to tuple encoding.
1351            fidl::encoding::Encode::<
1352                ImagePipe2PresentImageRequest,
1353                fdomain_client::fidl::FDomainResourceDialect,
1354            >::encode(
1355                (
1356                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.image_id),
1357                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.presentation_time),
1358                    <fidl::encoding::Vector<
1359                        fidl::encoding::HandleType<
1360                            fdomain_client::Event,
1361                            { fidl::ObjectType::EVENT.into_raw() },
1362                            2147483648,
1363                        >,
1364                        16,
1365                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1366                        &mut self.acquire_fences,
1367                    ),
1368                    <fidl::encoding::Vector<
1369                        fidl::encoding::HandleType<
1370                            fdomain_client::Event,
1371                            { fidl::ObjectType::EVENT.into_raw() },
1372                            2147483648,
1373                        >,
1374                        16,
1375                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1376                        &mut self.release_fences,
1377                    ),
1378                ),
1379                encoder,
1380                offset,
1381                _depth,
1382            )
1383        }
1384    }
1385    unsafe impl<
1386        T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
1387        T1: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
1388        T2: fidl::encoding::Encode<
1389                fidl::encoding::Vector<
1390                    fidl::encoding::HandleType<
1391                        fdomain_client::Event,
1392                        { fidl::ObjectType::EVENT.into_raw() },
1393                        2147483648,
1394                    >,
1395                    16,
1396                >,
1397                fdomain_client::fidl::FDomainResourceDialect,
1398            >,
1399        T3: fidl::encoding::Encode<
1400                fidl::encoding::Vector<
1401                    fidl::encoding::HandleType<
1402                        fdomain_client::Event,
1403                        { fidl::ObjectType::EVENT.into_raw() },
1404                        2147483648,
1405                    >,
1406                    16,
1407                >,
1408                fdomain_client::fidl::FDomainResourceDialect,
1409            >,
1410    >
1411        fidl::encoding::Encode<
1412            ImagePipe2PresentImageRequest,
1413            fdomain_client::fidl::FDomainResourceDialect,
1414        > for (T0, T1, T2, T3)
1415    {
1416        #[inline]
1417        unsafe fn encode(
1418            self,
1419            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1420            offset: usize,
1421            depth: fidl::encoding::Depth,
1422        ) -> fidl::Result<()> {
1423            encoder.debug_check_bounds::<ImagePipe2PresentImageRequest>(offset);
1424            // Zero out padding regions. There's no need to apply masks
1425            // because the unmasked parts will be overwritten by fields.
1426            unsafe {
1427                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1428                (ptr as *mut u64).write_unaligned(0);
1429            }
1430            // Write the fields.
1431            self.0.encode(encoder, offset + 0, depth)?;
1432            self.1.encode(encoder, offset + 8, depth)?;
1433            self.2.encode(encoder, offset + 16, depth)?;
1434            self.3.encode(encoder, offset + 32, depth)?;
1435            Ok(())
1436        }
1437    }
1438
1439    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1440        for ImagePipe2PresentImageRequest
1441    {
1442        #[inline(always)]
1443        fn new_empty() -> Self {
1444            Self {
1445                image_id: fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect),
1446                presentation_time: fidl::new_empty!(
1447                    u64,
1448                    fdomain_client::fidl::FDomainResourceDialect
1449                ),
1450                acquire_fences: fidl::new_empty!(
1451                    fidl::encoding::Vector<
1452                        fidl::encoding::HandleType<
1453                            fdomain_client::Event,
1454                            { fidl::ObjectType::EVENT.into_raw() },
1455                            2147483648,
1456                        >,
1457                        16,
1458                    >,
1459                    fdomain_client::fidl::FDomainResourceDialect
1460                ),
1461                release_fences: fidl::new_empty!(
1462                    fidl::encoding::Vector<
1463                        fidl::encoding::HandleType<
1464                            fdomain_client::Event,
1465                            { fidl::ObjectType::EVENT.into_raw() },
1466                            2147483648,
1467                        >,
1468                        16,
1469                    >,
1470                    fdomain_client::fidl::FDomainResourceDialect
1471                ),
1472            }
1473        }
1474
1475        #[inline]
1476        unsafe fn decode(
1477            &mut self,
1478            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1479            offset: usize,
1480            _depth: fidl::encoding::Depth,
1481        ) -> fidl::Result<()> {
1482            decoder.debug_check_bounds::<Self>(offset);
1483            // Verify that padding bytes are zero.
1484            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1485            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1486            let mask = 0xffffffff00000000u64;
1487            let maskedval = padval & mask;
1488            if maskedval != 0 {
1489                return Err(fidl::Error::NonZeroPadding {
1490                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1491                });
1492            }
1493            fidl::decode!(
1494                u32,
1495                fdomain_client::fidl::FDomainResourceDialect,
1496                &mut self.image_id,
1497                decoder,
1498                offset + 0,
1499                _depth
1500            )?;
1501            fidl::decode!(
1502                u64,
1503                fdomain_client::fidl::FDomainResourceDialect,
1504                &mut self.presentation_time,
1505                decoder,
1506                offset + 8,
1507                _depth
1508            )?;
1509            fidl::decode!(
1510                fidl::encoding::Vector<
1511                    fidl::encoding::HandleType<
1512                        fdomain_client::Event,
1513                        { fidl::ObjectType::EVENT.into_raw() },
1514                        2147483648,
1515                    >,
1516                    16,
1517                >,
1518                fdomain_client::fidl::FDomainResourceDialect,
1519                &mut self.acquire_fences,
1520                decoder,
1521                offset + 16,
1522                _depth
1523            )?;
1524            fidl::decode!(
1525                fidl::encoding::Vector<
1526                    fidl::encoding::HandleType<
1527                        fdomain_client::Event,
1528                        { fidl::ObjectType::EVENT.into_raw() },
1529                        2147483648,
1530                    >,
1531                    16,
1532                >,
1533                fdomain_client::fidl::FDomainResourceDialect,
1534                &mut self.release_fences,
1535                decoder,
1536                offset + 32,
1537                _depth
1538            )?;
1539            Ok(())
1540        }
1541    }
1542}