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