Skip to main content

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