fidl_fuchsia_ui_composition_internal/
fidl_fuchsia_ui_composition_internal.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_ui_composition_internal_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DisplayOwnershipGetEventResponse {
16    pub ownership_event: fidl::Event,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DisplayOwnershipGetEventResponse
21{
22}
23
24/// Return fields of the [`GetNextFrame`] call. These fields hold the
25/// frame’s information on buffer location, timing, and a way to release
26/// after using it. All fields will be returned by the server.
27#[derive(Debug, Default, PartialEq)]
28pub struct FrameInfo {
29    /// The index of the VMO where the requested frame has been rendered
30    /// in the buffer collection.
31    pub buffer_index: Option<u32>,
32    /// The time that the buffer was populated with the frame.
33    pub capture_timestamp: Option<i64>,
34    /// The release token for |buffer_index|. The client drops the eventpair
35    /// to signal to the server that |buffer_index| is free for writing.
36    /// If the eventpair is not dropped, then in the future calls to
37    /// [`GetNextFrame`], if there are no available buffers, the server will
38    /// wait until the client frees up a past buffer. If the client was holding
39    /// on to all buffers in the buffer collection and then
40    /// releases a buffer while hanging, the server will immediately return the
41    /// latest frame.
42    pub buffer_release_token: Option<fidl::EventPair>,
43    #[doc(hidden)]
44    pub __source_breaking: fidl::marker::SourceBreaking,
45}
46
47impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FrameInfo {}
48
49/// Fields required to set up a ScreenCapture protocol in the [`Configure`]
50/// call. Notice some fields are optional.
51#[derive(Debug, Default, PartialEq)]
52pub struct ScreenCaptureConfig {
53    /// The import token referencing a BufferCollection registered with the
54    /// Allocator.
55    /// Required.
56    pub import_token: Option<fidl_fuchsia_ui_composition::BufferCollectionImportToken>,
57    /// The size of the image in pixels: width and height.
58    /// This should be the width and height calculated after the
59    /// rotation that will be applied.
60    /// Required.
61    pub image_size: Option<fidl_fuchsia_math::SizeU>,
62    /// The rotation applied to the stream of images.
63    /// Defaults to CW_0_DEGREES (no rotation).
64    /// Optional.
65    pub image_rotation: Option<ScreenCaptureRotation>,
66    #[doc(hidden)]
67    pub __source_breaking: fidl::marker::SourceBreaking,
68}
69
70impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ScreenCaptureConfig {}
71
72#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
73pub struct DisplayOwnershipMarker;
74
75impl fidl::endpoints::ProtocolMarker for DisplayOwnershipMarker {
76    type Proxy = DisplayOwnershipProxy;
77    type RequestStream = DisplayOwnershipRequestStream;
78    #[cfg(target_os = "fuchsia")]
79    type SynchronousProxy = DisplayOwnershipSynchronousProxy;
80
81    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.internal.DisplayOwnership";
82}
83impl fidl::endpoints::DiscoverableProtocolMarker for DisplayOwnershipMarker {}
84
85pub trait DisplayOwnershipProxyInterface: Send + Sync {
86    type GetEventResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>> + Send;
87    fn r#get_event(&self) -> Self::GetEventResponseFut;
88}
89#[derive(Debug)]
90#[cfg(target_os = "fuchsia")]
91pub struct DisplayOwnershipSynchronousProxy {
92    client: fidl::client::sync::Client,
93}
94
95#[cfg(target_os = "fuchsia")]
96impl fidl::endpoints::SynchronousProxy for DisplayOwnershipSynchronousProxy {
97    type Proxy = DisplayOwnershipProxy;
98    type Protocol = DisplayOwnershipMarker;
99
100    fn from_channel(inner: fidl::Channel) -> Self {
101        Self::new(inner)
102    }
103
104    fn into_channel(self) -> fidl::Channel {
105        self.client.into_channel()
106    }
107
108    fn as_channel(&self) -> &fidl::Channel {
109        self.client.as_channel()
110    }
111}
112
113#[cfg(target_os = "fuchsia")]
114impl DisplayOwnershipSynchronousProxy {
115    pub fn new(channel: fidl::Channel) -> Self {
116        let protocol_name = <DisplayOwnershipMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
117        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
118    }
119
120    pub fn into_channel(self) -> fidl::Channel {
121        self.client.into_channel()
122    }
123
124    /// Waits until an event arrives and returns it. It is safe for other
125    /// threads to make concurrent requests while waiting for an event.
126    pub fn wait_for_event(
127        &self,
128        deadline: zx::MonotonicInstant,
129    ) -> Result<DisplayOwnershipEvent, fidl::Error> {
130        DisplayOwnershipEvent::decode(self.client.wait_for_event(deadline)?)
131    }
132
133    /// Gets an event signaled with SIGNAL_DISPLAY_OWNED or SIGNAL_DISPLAY_NOT_OWNED
134    /// when display ownership changes.
135    pub fn r#get_event(
136        &self,
137        ___deadline: zx::MonotonicInstant,
138    ) -> Result<fidl::Event, fidl::Error> {
139        let _response = self
140            .client
141            .send_query::<fidl::encoding::EmptyPayload, DisplayOwnershipGetEventResponse>(
142                (),
143                0x2dc713e7b367312f,
144                fidl::encoding::DynamicFlags::empty(),
145                ___deadline,
146            )?;
147        Ok(_response.ownership_event)
148    }
149}
150
151#[derive(Debug, Clone)]
152pub struct DisplayOwnershipProxy {
153    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
154}
155
156impl fidl::endpoints::Proxy for DisplayOwnershipProxy {
157    type Protocol = DisplayOwnershipMarker;
158
159    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
160        Self::new(inner)
161    }
162
163    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
164        self.client.into_channel().map_err(|client| Self { client })
165    }
166
167    fn as_channel(&self) -> &::fidl::AsyncChannel {
168        self.client.as_channel()
169    }
170}
171
172impl DisplayOwnershipProxy {
173    /// Create a new Proxy for fuchsia.ui.composition.internal/DisplayOwnership.
174    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
175        let protocol_name = <DisplayOwnershipMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
176        Self { client: fidl::client::Client::new(channel, protocol_name) }
177    }
178
179    /// Get a Stream of events from the remote end of the protocol.
180    ///
181    /// # Panics
182    ///
183    /// Panics if the event stream was already taken.
184    pub fn take_event_stream(&self) -> DisplayOwnershipEventStream {
185        DisplayOwnershipEventStream { event_receiver: self.client.take_event_receiver() }
186    }
187
188    /// Gets an event signaled with SIGNAL_DISPLAY_OWNED or SIGNAL_DISPLAY_NOT_OWNED
189    /// when display ownership changes.
190    pub fn r#get_event(
191        &self,
192    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
193    {
194        DisplayOwnershipProxyInterface::r#get_event(self)
195    }
196}
197
198impl DisplayOwnershipProxyInterface for DisplayOwnershipProxy {
199    type GetEventResponseFut =
200        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
201    fn r#get_event(&self) -> Self::GetEventResponseFut {
202        fn _decode(
203            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
204        ) -> Result<fidl::Event, fidl::Error> {
205            let _response = fidl::client::decode_transaction_body::<
206                DisplayOwnershipGetEventResponse,
207                fidl::encoding::DefaultFuchsiaResourceDialect,
208                0x2dc713e7b367312f,
209            >(_buf?)?;
210            Ok(_response.ownership_event)
211        }
212        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
213            (),
214            0x2dc713e7b367312f,
215            fidl::encoding::DynamicFlags::empty(),
216            _decode,
217        )
218    }
219}
220
221pub struct DisplayOwnershipEventStream {
222    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
223}
224
225impl std::marker::Unpin for DisplayOwnershipEventStream {}
226
227impl futures::stream::FusedStream for DisplayOwnershipEventStream {
228    fn is_terminated(&self) -> bool {
229        self.event_receiver.is_terminated()
230    }
231}
232
233impl futures::Stream for DisplayOwnershipEventStream {
234    type Item = Result<DisplayOwnershipEvent, fidl::Error>;
235
236    fn poll_next(
237        mut self: std::pin::Pin<&mut Self>,
238        cx: &mut std::task::Context<'_>,
239    ) -> std::task::Poll<Option<Self::Item>> {
240        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
241            &mut self.event_receiver,
242            cx
243        )?) {
244            Some(buf) => std::task::Poll::Ready(Some(DisplayOwnershipEvent::decode(buf))),
245            None => std::task::Poll::Ready(None),
246        }
247    }
248}
249
250#[derive(Debug)]
251pub enum DisplayOwnershipEvent {}
252
253impl DisplayOwnershipEvent {
254    /// Decodes a message buffer as a [`DisplayOwnershipEvent`].
255    fn decode(
256        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
257    ) -> Result<DisplayOwnershipEvent, fidl::Error> {
258        let (bytes, _handles) = buf.split_mut();
259        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
260        debug_assert_eq!(tx_header.tx_id, 0);
261        match tx_header.ordinal {
262            _ => Err(fidl::Error::UnknownOrdinal {
263                ordinal: tx_header.ordinal,
264                protocol_name:
265                    <DisplayOwnershipMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
266            }),
267        }
268    }
269}
270
271/// A Stream of incoming requests for fuchsia.ui.composition.internal/DisplayOwnership.
272pub struct DisplayOwnershipRequestStream {
273    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
274    is_terminated: bool,
275}
276
277impl std::marker::Unpin for DisplayOwnershipRequestStream {}
278
279impl futures::stream::FusedStream for DisplayOwnershipRequestStream {
280    fn is_terminated(&self) -> bool {
281        self.is_terminated
282    }
283}
284
285impl fidl::endpoints::RequestStream for DisplayOwnershipRequestStream {
286    type Protocol = DisplayOwnershipMarker;
287    type ControlHandle = DisplayOwnershipControlHandle;
288
289    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
290        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
291    }
292
293    fn control_handle(&self) -> Self::ControlHandle {
294        DisplayOwnershipControlHandle { inner: self.inner.clone() }
295    }
296
297    fn into_inner(
298        self,
299    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
300    {
301        (self.inner, self.is_terminated)
302    }
303
304    fn from_inner(
305        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
306        is_terminated: bool,
307    ) -> Self {
308        Self { inner, is_terminated }
309    }
310}
311
312impl futures::Stream for DisplayOwnershipRequestStream {
313    type Item = Result<DisplayOwnershipRequest, fidl::Error>;
314
315    fn poll_next(
316        mut self: std::pin::Pin<&mut Self>,
317        cx: &mut std::task::Context<'_>,
318    ) -> std::task::Poll<Option<Self::Item>> {
319        let this = &mut *self;
320        if this.inner.check_shutdown(cx) {
321            this.is_terminated = true;
322            return std::task::Poll::Ready(None);
323        }
324        if this.is_terminated {
325            panic!("polled DisplayOwnershipRequestStream after completion");
326        }
327        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
328            |bytes, handles| {
329                match this.inner.channel().read_etc(cx, bytes, handles) {
330                    std::task::Poll::Ready(Ok(())) => {}
331                    std::task::Poll::Pending => return std::task::Poll::Pending,
332                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
333                        this.is_terminated = true;
334                        return std::task::Poll::Ready(None);
335                    }
336                    std::task::Poll::Ready(Err(e)) => {
337                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
338                            e.into(),
339                        ))))
340                    }
341                }
342
343                // A message has been received from the channel
344                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
345
346                std::task::Poll::Ready(Some(match header.ordinal {
347                    0x2dc713e7b367312f => {
348                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
349                        let mut req = fidl::new_empty!(
350                            fidl::encoding::EmptyPayload,
351                            fidl::encoding::DefaultFuchsiaResourceDialect
352                        );
353                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
354                        let control_handle =
355                            DisplayOwnershipControlHandle { inner: this.inner.clone() };
356                        Ok(DisplayOwnershipRequest::GetEvent {
357                            responder: DisplayOwnershipGetEventResponder {
358                                control_handle: std::mem::ManuallyDrop::new(control_handle),
359                                tx_id: header.tx_id,
360                            },
361                        })
362                    }
363                    _ => Err(fidl::Error::UnknownOrdinal {
364                        ordinal: header.ordinal,
365                        protocol_name:
366                            <DisplayOwnershipMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
367                    }),
368                }))
369            },
370        )
371    }
372}
373
374/// Get information about Scenic ownership of the primary display.
375#[derive(Debug)]
376pub enum DisplayOwnershipRequest {
377    /// Gets an event signaled with SIGNAL_DISPLAY_OWNED or SIGNAL_DISPLAY_NOT_OWNED
378    /// when display ownership changes.
379    GetEvent { responder: DisplayOwnershipGetEventResponder },
380}
381
382impl DisplayOwnershipRequest {
383    #[allow(irrefutable_let_patterns)]
384    pub fn into_get_event(self) -> Option<(DisplayOwnershipGetEventResponder)> {
385        if let DisplayOwnershipRequest::GetEvent { responder } = self {
386            Some((responder))
387        } else {
388            None
389        }
390    }
391
392    /// Name of the method defined in FIDL
393    pub fn method_name(&self) -> &'static str {
394        match *self {
395            DisplayOwnershipRequest::GetEvent { .. } => "get_event",
396        }
397    }
398}
399
400#[derive(Debug, Clone)]
401pub struct DisplayOwnershipControlHandle {
402    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
403}
404
405impl fidl::endpoints::ControlHandle for DisplayOwnershipControlHandle {
406    fn shutdown(&self) {
407        self.inner.shutdown()
408    }
409    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
410        self.inner.shutdown_with_epitaph(status)
411    }
412
413    fn is_closed(&self) -> bool {
414        self.inner.channel().is_closed()
415    }
416    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
417        self.inner.channel().on_closed()
418    }
419
420    #[cfg(target_os = "fuchsia")]
421    fn signal_peer(
422        &self,
423        clear_mask: zx::Signals,
424        set_mask: zx::Signals,
425    ) -> Result<(), zx_status::Status> {
426        use fidl::Peered;
427        self.inner.channel().signal_peer(clear_mask, set_mask)
428    }
429}
430
431impl DisplayOwnershipControlHandle {}
432
433#[must_use = "FIDL methods require a response to be sent"]
434#[derive(Debug)]
435pub struct DisplayOwnershipGetEventResponder {
436    control_handle: std::mem::ManuallyDrop<DisplayOwnershipControlHandle>,
437    tx_id: u32,
438}
439
440/// Set the the channel to be shutdown (see [`DisplayOwnershipControlHandle::shutdown`])
441/// if the responder is dropped without sending a response, so that the client
442/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
443impl std::ops::Drop for DisplayOwnershipGetEventResponder {
444    fn drop(&mut self) {
445        self.control_handle.shutdown();
446        // Safety: drops once, never accessed again
447        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
448    }
449}
450
451impl fidl::endpoints::Responder for DisplayOwnershipGetEventResponder {
452    type ControlHandle = DisplayOwnershipControlHandle;
453
454    fn control_handle(&self) -> &DisplayOwnershipControlHandle {
455        &self.control_handle
456    }
457
458    fn drop_without_shutdown(mut self) {
459        // Safety: drops once, never accessed again due to mem::forget
460        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
461        // Prevent Drop from running (which would shut down the channel)
462        std::mem::forget(self);
463    }
464}
465
466impl DisplayOwnershipGetEventResponder {
467    /// Sends a response to the FIDL transaction.
468    ///
469    /// Sets the channel to shutdown if an error occurs.
470    pub fn send(self, mut ownership_event: fidl::Event) -> Result<(), fidl::Error> {
471        let _result = self.send_raw(ownership_event);
472        if _result.is_err() {
473            self.control_handle.shutdown();
474        }
475        self.drop_without_shutdown();
476        _result
477    }
478
479    /// Similar to "send" but does not shutdown the channel if an error occurs.
480    pub fn send_no_shutdown_on_err(
481        self,
482        mut ownership_event: fidl::Event,
483    ) -> Result<(), fidl::Error> {
484        let _result = self.send_raw(ownership_event);
485        self.drop_without_shutdown();
486        _result
487    }
488
489    fn send_raw(&self, mut ownership_event: fidl::Event) -> Result<(), fidl::Error> {
490        self.control_handle.inner.send::<DisplayOwnershipGetEventResponse>(
491            (ownership_event,),
492            self.tx_id,
493            0x2dc713e7b367312f,
494            fidl::encoding::DynamicFlags::empty(),
495        )
496    }
497}
498
499#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
500pub struct ScreenCaptureMarker;
501
502impl fidl::endpoints::ProtocolMarker for ScreenCaptureMarker {
503    type Proxy = ScreenCaptureProxy;
504    type RequestStream = ScreenCaptureRequestStream;
505    #[cfg(target_os = "fuchsia")]
506    type SynchronousProxy = ScreenCaptureSynchronousProxy;
507
508    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.internal.ScreenCapture";
509}
510impl fidl::endpoints::DiscoverableProtocolMarker for ScreenCaptureMarker {}
511pub type ScreenCaptureConfigureResult = Result<(), ScreenCaptureError>;
512pub type ScreenCaptureGetNextFrameResult = Result<FrameInfo, ScreenCaptureError>;
513
514pub trait ScreenCaptureProxyInterface: Send + Sync {
515    type ConfigureResponseFut: std::future::Future<Output = Result<ScreenCaptureConfigureResult, fidl::Error>>
516        + Send;
517    fn r#configure(&self, payload: ScreenCaptureConfig) -> Self::ConfigureResponseFut;
518    type GetNextFrameResponseFut: std::future::Future<Output = Result<ScreenCaptureGetNextFrameResult, fidl::Error>>
519        + Send;
520    fn r#get_next_frame(&self) -> Self::GetNextFrameResponseFut;
521}
522#[derive(Debug)]
523#[cfg(target_os = "fuchsia")]
524pub struct ScreenCaptureSynchronousProxy {
525    client: fidl::client::sync::Client,
526}
527
528#[cfg(target_os = "fuchsia")]
529impl fidl::endpoints::SynchronousProxy for ScreenCaptureSynchronousProxy {
530    type Proxy = ScreenCaptureProxy;
531    type Protocol = ScreenCaptureMarker;
532
533    fn from_channel(inner: fidl::Channel) -> Self {
534        Self::new(inner)
535    }
536
537    fn into_channel(self) -> fidl::Channel {
538        self.client.into_channel()
539    }
540
541    fn as_channel(&self) -> &fidl::Channel {
542        self.client.as_channel()
543    }
544}
545
546#[cfg(target_os = "fuchsia")]
547impl ScreenCaptureSynchronousProxy {
548    pub fn new(channel: fidl::Channel) -> Self {
549        let protocol_name = <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
550        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
551    }
552
553    pub fn into_channel(self) -> fidl::Channel {
554        self.client.into_channel()
555    }
556
557    /// Waits until an event arrives and returns it. It is safe for other
558    /// threads to make concurrent requests while waiting for an event.
559    pub fn wait_for_event(
560        &self,
561        deadline: zx::MonotonicInstant,
562    ) -> Result<ScreenCaptureEvent, fidl::Error> {
563        ScreenCaptureEvent::decode(self.client.wait_for_event(deadline)?)
564    }
565
566    /// Clients should first use the ['fuchsia.ui.composition/Allocator']
567    /// protocol to register a BufferCollection.
568    ///
569    /// Similarly, the clients are responsible for specifying a buffer big
570    /// enough for the image. If the buffer is too small, an
571    /// attempt will be made to render the image, however, it will not be
572    /// guaranteed to contain the complete image.
573    pub fn r#configure(
574        &self,
575        mut payload: ScreenCaptureConfig,
576        ___deadline: zx::MonotonicInstant,
577    ) -> Result<ScreenCaptureConfigureResult, fidl::Error> {
578        let _response = self.client.send_query::<ScreenCaptureConfig, fidl::encoding::ResultType<
579            fidl::encoding::EmptyStruct,
580            ScreenCaptureError,
581        >>(
582            &mut payload,
583            0x5d07582dc93862a2,
584            fidl::encoding::DynamicFlags::empty(),
585            ___deadline,
586        )?;
587        Ok(_response.map(|x| x))
588    }
589
590    /// [`GetNextFrame`] returns the latest unseen-by-the-client frame as soon
591    /// as possible. On the first call to [`GetNextFrame`] and any subsequent
592    /// calls that have not recieved the previous expected requested frame,
593    /// [`GetNextFrame`] will return immediately with the last frame to be
594    /// rendered. If the client had requested the previous frame, the server
595    /// will wait until the next frame is produced to return.
596    ///
597    /// After the client finishes processing the returned buffer, they should
598    /// drop the eventpair to signal to the server that the buffer can be
599    /// re-used.
600    ///
601    /// It is invalid to call [`GetNextFrame`] while a previous call is still
602    /// pending. Doing so will return a BAD_HANGING_GET error and cause the
603    /// channel to close.
604    pub fn r#get_next_frame(
605        &self,
606        ___deadline: zx::MonotonicInstant,
607    ) -> Result<ScreenCaptureGetNextFrameResult, fidl::Error> {
608        let _response = self.client.send_query::<
609            fidl::encoding::EmptyPayload,
610            fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>,
611        >(
612            (),
613            0x48680722eab7103,
614            fidl::encoding::DynamicFlags::empty(),
615            ___deadline,
616        )?;
617        Ok(_response.map(|x| x))
618    }
619}
620
621#[derive(Debug, Clone)]
622pub struct ScreenCaptureProxy {
623    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
624}
625
626impl fidl::endpoints::Proxy for ScreenCaptureProxy {
627    type Protocol = ScreenCaptureMarker;
628
629    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
630        Self::new(inner)
631    }
632
633    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
634        self.client.into_channel().map_err(|client| Self { client })
635    }
636
637    fn as_channel(&self) -> &::fidl::AsyncChannel {
638        self.client.as_channel()
639    }
640}
641
642impl ScreenCaptureProxy {
643    /// Create a new Proxy for fuchsia.ui.composition.internal/ScreenCapture.
644    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
645        let protocol_name = <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
646        Self { client: fidl::client::Client::new(channel, protocol_name) }
647    }
648
649    /// Get a Stream of events from the remote end of the protocol.
650    ///
651    /// # Panics
652    ///
653    /// Panics if the event stream was already taken.
654    pub fn take_event_stream(&self) -> ScreenCaptureEventStream {
655        ScreenCaptureEventStream { event_receiver: self.client.take_event_receiver() }
656    }
657
658    /// Clients should first use the ['fuchsia.ui.composition/Allocator']
659    /// protocol to register a BufferCollection.
660    ///
661    /// Similarly, the clients are responsible for specifying a buffer big
662    /// enough for the image. If the buffer is too small, an
663    /// attempt will be made to render the image, however, it will not be
664    /// guaranteed to contain the complete image.
665    pub fn r#configure(
666        &self,
667        mut payload: ScreenCaptureConfig,
668    ) -> fidl::client::QueryResponseFut<
669        ScreenCaptureConfigureResult,
670        fidl::encoding::DefaultFuchsiaResourceDialect,
671    > {
672        ScreenCaptureProxyInterface::r#configure(self, payload)
673    }
674
675    /// [`GetNextFrame`] returns the latest unseen-by-the-client frame as soon
676    /// as possible. On the first call to [`GetNextFrame`] and any subsequent
677    /// calls that have not recieved the previous expected requested frame,
678    /// [`GetNextFrame`] will return immediately with the last frame to be
679    /// rendered. If the client had requested the previous frame, the server
680    /// will wait until the next frame is produced to return.
681    ///
682    /// After the client finishes processing the returned buffer, they should
683    /// drop the eventpair to signal to the server that the buffer can be
684    /// re-used.
685    ///
686    /// It is invalid to call [`GetNextFrame`] while a previous call is still
687    /// pending. Doing so will return a BAD_HANGING_GET error and cause the
688    /// channel to close.
689    pub fn r#get_next_frame(
690        &self,
691    ) -> fidl::client::QueryResponseFut<
692        ScreenCaptureGetNextFrameResult,
693        fidl::encoding::DefaultFuchsiaResourceDialect,
694    > {
695        ScreenCaptureProxyInterface::r#get_next_frame(self)
696    }
697}
698
699impl ScreenCaptureProxyInterface for ScreenCaptureProxy {
700    type ConfigureResponseFut = fidl::client::QueryResponseFut<
701        ScreenCaptureConfigureResult,
702        fidl::encoding::DefaultFuchsiaResourceDialect,
703    >;
704    fn r#configure(&self, mut payload: ScreenCaptureConfig) -> Self::ConfigureResponseFut {
705        fn _decode(
706            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
707        ) -> Result<ScreenCaptureConfigureResult, fidl::Error> {
708            let _response = fidl::client::decode_transaction_body::<
709                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ScreenCaptureError>,
710                fidl::encoding::DefaultFuchsiaResourceDialect,
711                0x5d07582dc93862a2,
712            >(_buf?)?;
713            Ok(_response.map(|x| x))
714        }
715        self.client.send_query_and_decode::<ScreenCaptureConfig, ScreenCaptureConfigureResult>(
716            &mut payload,
717            0x5d07582dc93862a2,
718            fidl::encoding::DynamicFlags::empty(),
719            _decode,
720        )
721    }
722
723    type GetNextFrameResponseFut = fidl::client::QueryResponseFut<
724        ScreenCaptureGetNextFrameResult,
725        fidl::encoding::DefaultFuchsiaResourceDialect,
726    >;
727    fn r#get_next_frame(&self) -> Self::GetNextFrameResponseFut {
728        fn _decode(
729            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
730        ) -> Result<ScreenCaptureGetNextFrameResult, fidl::Error> {
731            let _response = fidl::client::decode_transaction_body::<
732                fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>,
733                fidl::encoding::DefaultFuchsiaResourceDialect,
734                0x48680722eab7103,
735            >(_buf?)?;
736            Ok(_response.map(|x| x))
737        }
738        self.client
739            .send_query_and_decode::<fidl::encoding::EmptyPayload, ScreenCaptureGetNextFrameResult>(
740                (),
741                0x48680722eab7103,
742                fidl::encoding::DynamicFlags::empty(),
743                _decode,
744            )
745    }
746}
747
748pub struct ScreenCaptureEventStream {
749    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
750}
751
752impl std::marker::Unpin for ScreenCaptureEventStream {}
753
754impl futures::stream::FusedStream for ScreenCaptureEventStream {
755    fn is_terminated(&self) -> bool {
756        self.event_receiver.is_terminated()
757    }
758}
759
760impl futures::Stream for ScreenCaptureEventStream {
761    type Item = Result<ScreenCaptureEvent, fidl::Error>;
762
763    fn poll_next(
764        mut self: std::pin::Pin<&mut Self>,
765        cx: &mut std::task::Context<'_>,
766    ) -> std::task::Poll<Option<Self::Item>> {
767        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
768            &mut self.event_receiver,
769            cx
770        )?) {
771            Some(buf) => std::task::Poll::Ready(Some(ScreenCaptureEvent::decode(buf))),
772            None => std::task::Poll::Ready(None),
773        }
774    }
775}
776
777#[derive(Debug)]
778pub enum ScreenCaptureEvent {}
779
780impl ScreenCaptureEvent {
781    /// Decodes a message buffer as a [`ScreenCaptureEvent`].
782    fn decode(
783        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
784    ) -> Result<ScreenCaptureEvent, fidl::Error> {
785        let (bytes, _handles) = buf.split_mut();
786        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
787        debug_assert_eq!(tx_header.tx_id, 0);
788        match tx_header.ordinal {
789            _ => Err(fidl::Error::UnknownOrdinal {
790                ordinal: tx_header.ordinal,
791                protocol_name: <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
792            }),
793        }
794    }
795}
796
797/// A Stream of incoming requests for fuchsia.ui.composition.internal/ScreenCapture.
798pub struct ScreenCaptureRequestStream {
799    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
800    is_terminated: bool,
801}
802
803impl std::marker::Unpin for ScreenCaptureRequestStream {}
804
805impl futures::stream::FusedStream for ScreenCaptureRequestStream {
806    fn is_terminated(&self) -> bool {
807        self.is_terminated
808    }
809}
810
811impl fidl::endpoints::RequestStream for ScreenCaptureRequestStream {
812    type Protocol = ScreenCaptureMarker;
813    type ControlHandle = ScreenCaptureControlHandle;
814
815    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
816        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
817    }
818
819    fn control_handle(&self) -> Self::ControlHandle {
820        ScreenCaptureControlHandle { inner: self.inner.clone() }
821    }
822
823    fn into_inner(
824        self,
825    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
826    {
827        (self.inner, self.is_terminated)
828    }
829
830    fn from_inner(
831        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
832        is_terminated: bool,
833    ) -> Self {
834        Self { inner, is_terminated }
835    }
836}
837
838impl futures::Stream for ScreenCaptureRequestStream {
839    type Item = Result<ScreenCaptureRequest, fidl::Error>;
840
841    fn poll_next(
842        mut self: std::pin::Pin<&mut Self>,
843        cx: &mut std::task::Context<'_>,
844    ) -> std::task::Poll<Option<Self::Item>> {
845        let this = &mut *self;
846        if this.inner.check_shutdown(cx) {
847            this.is_terminated = true;
848            return std::task::Poll::Ready(None);
849        }
850        if this.is_terminated {
851            panic!("polled ScreenCaptureRequestStream after completion");
852        }
853        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
854            |bytes, handles| {
855                match this.inner.channel().read_etc(cx, bytes, handles) {
856                    std::task::Poll::Ready(Ok(())) => {}
857                    std::task::Poll::Pending => return std::task::Poll::Pending,
858                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
859                        this.is_terminated = true;
860                        return std::task::Poll::Ready(None);
861                    }
862                    std::task::Poll::Ready(Err(e)) => {
863                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
864                            e.into(),
865                        ))))
866                    }
867                }
868
869                // A message has been received from the channel
870                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
871
872                std::task::Poll::Ready(Some(match header.ordinal {
873                    0x5d07582dc93862a2 => {
874                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
875                        let mut req = fidl::new_empty!(
876                            ScreenCaptureConfig,
877                            fidl::encoding::DefaultFuchsiaResourceDialect
878                        );
879                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenCaptureConfig>(&header, _body_bytes, handles, &mut req)?;
880                        let control_handle =
881                            ScreenCaptureControlHandle { inner: this.inner.clone() };
882                        Ok(ScreenCaptureRequest::Configure {
883                            payload: req,
884                            responder: ScreenCaptureConfigureResponder {
885                                control_handle: std::mem::ManuallyDrop::new(control_handle),
886                                tx_id: header.tx_id,
887                            },
888                        })
889                    }
890                    0x48680722eab7103 => {
891                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
892                        let mut req = fidl::new_empty!(
893                            fidl::encoding::EmptyPayload,
894                            fidl::encoding::DefaultFuchsiaResourceDialect
895                        );
896                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
897                        let control_handle =
898                            ScreenCaptureControlHandle { inner: this.inner.clone() };
899                        Ok(ScreenCaptureRequest::GetNextFrame {
900                            responder: ScreenCaptureGetNextFrameResponder {
901                                control_handle: std::mem::ManuallyDrop::new(control_handle),
902                                tx_id: header.tx_id,
903                            },
904                        })
905                    }
906                    _ => Err(fidl::Error::UnknownOrdinal {
907                        ordinal: header.ordinal,
908                        protocol_name:
909                            <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
910                    }),
911                }))
912            },
913        )
914    }
915}
916
917/// Provides a low-level streaming API for clients to use.
918/// ScreenCapture clients should familiarize themselves with the
919/// [`fuchsia.sysmem/BufferCollection`] and
920/// [`fuchsia.ui.composition/Allocator`] protocols as those are necessary to
921/// create the BufferCollections and images ScreenCapture uses.
922#[derive(Debug)]
923pub enum ScreenCaptureRequest {
924    /// Clients should first use the ['fuchsia.ui.composition/Allocator']
925    /// protocol to register a BufferCollection.
926    ///
927    /// Similarly, the clients are responsible for specifying a buffer big
928    /// enough for the image. If the buffer is too small, an
929    /// attempt will be made to render the image, however, it will not be
930    /// guaranteed to contain the complete image.
931    Configure { payload: ScreenCaptureConfig, responder: ScreenCaptureConfigureResponder },
932    /// [`GetNextFrame`] returns the latest unseen-by-the-client frame as soon
933    /// as possible. On the first call to [`GetNextFrame`] and any subsequent
934    /// calls that have not recieved the previous expected requested frame,
935    /// [`GetNextFrame`] will return immediately with the last frame to be
936    /// rendered. If the client had requested the previous frame, the server
937    /// will wait until the next frame is produced to return.
938    ///
939    /// After the client finishes processing the returned buffer, they should
940    /// drop the eventpair to signal to the server that the buffer can be
941    /// re-used.
942    ///
943    /// It is invalid to call [`GetNextFrame`] while a previous call is still
944    /// pending. Doing so will return a BAD_HANGING_GET error and cause the
945    /// channel to close.
946    GetNextFrame { responder: ScreenCaptureGetNextFrameResponder },
947}
948
949impl ScreenCaptureRequest {
950    #[allow(irrefutable_let_patterns)]
951    pub fn into_configure(self) -> Option<(ScreenCaptureConfig, ScreenCaptureConfigureResponder)> {
952        if let ScreenCaptureRequest::Configure { payload, responder } = self {
953            Some((payload, responder))
954        } else {
955            None
956        }
957    }
958
959    #[allow(irrefutable_let_patterns)]
960    pub fn into_get_next_frame(self) -> Option<(ScreenCaptureGetNextFrameResponder)> {
961        if let ScreenCaptureRequest::GetNextFrame { responder } = self {
962            Some((responder))
963        } else {
964            None
965        }
966    }
967
968    /// Name of the method defined in FIDL
969    pub fn method_name(&self) -> &'static str {
970        match *self {
971            ScreenCaptureRequest::Configure { .. } => "configure",
972            ScreenCaptureRequest::GetNextFrame { .. } => "get_next_frame",
973        }
974    }
975}
976
977#[derive(Debug, Clone)]
978pub struct ScreenCaptureControlHandle {
979    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
980}
981
982impl fidl::endpoints::ControlHandle for ScreenCaptureControlHandle {
983    fn shutdown(&self) {
984        self.inner.shutdown()
985    }
986    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
987        self.inner.shutdown_with_epitaph(status)
988    }
989
990    fn is_closed(&self) -> bool {
991        self.inner.channel().is_closed()
992    }
993    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
994        self.inner.channel().on_closed()
995    }
996
997    #[cfg(target_os = "fuchsia")]
998    fn signal_peer(
999        &self,
1000        clear_mask: zx::Signals,
1001        set_mask: zx::Signals,
1002    ) -> Result<(), zx_status::Status> {
1003        use fidl::Peered;
1004        self.inner.channel().signal_peer(clear_mask, set_mask)
1005    }
1006}
1007
1008impl ScreenCaptureControlHandle {}
1009
1010#[must_use = "FIDL methods require a response to be sent"]
1011#[derive(Debug)]
1012pub struct ScreenCaptureConfigureResponder {
1013    control_handle: std::mem::ManuallyDrop<ScreenCaptureControlHandle>,
1014    tx_id: u32,
1015}
1016
1017/// Set the the channel to be shutdown (see [`ScreenCaptureControlHandle::shutdown`])
1018/// if the responder is dropped without sending a response, so that the client
1019/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1020impl std::ops::Drop for ScreenCaptureConfigureResponder {
1021    fn drop(&mut self) {
1022        self.control_handle.shutdown();
1023        // Safety: drops once, never accessed again
1024        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1025    }
1026}
1027
1028impl fidl::endpoints::Responder for ScreenCaptureConfigureResponder {
1029    type ControlHandle = ScreenCaptureControlHandle;
1030
1031    fn control_handle(&self) -> &ScreenCaptureControlHandle {
1032        &self.control_handle
1033    }
1034
1035    fn drop_without_shutdown(mut self) {
1036        // Safety: drops once, never accessed again due to mem::forget
1037        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1038        // Prevent Drop from running (which would shut down the channel)
1039        std::mem::forget(self);
1040    }
1041}
1042
1043impl ScreenCaptureConfigureResponder {
1044    /// Sends a response to the FIDL transaction.
1045    ///
1046    /// Sets the channel to shutdown if an error occurs.
1047    pub fn send(self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
1048        let _result = self.send_raw(result);
1049        if _result.is_err() {
1050            self.control_handle.shutdown();
1051        }
1052        self.drop_without_shutdown();
1053        _result
1054    }
1055
1056    /// Similar to "send" but does not shutdown the channel if an error occurs.
1057    pub fn send_no_shutdown_on_err(
1058        self,
1059        mut result: Result<(), ScreenCaptureError>,
1060    ) -> Result<(), fidl::Error> {
1061        let _result = self.send_raw(result);
1062        self.drop_without_shutdown();
1063        _result
1064    }
1065
1066    fn send_raw(&self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
1067        self.control_handle.inner.send::<fidl::encoding::ResultType<
1068            fidl::encoding::EmptyStruct,
1069            ScreenCaptureError,
1070        >>(
1071            result,
1072            self.tx_id,
1073            0x5d07582dc93862a2,
1074            fidl::encoding::DynamicFlags::empty(),
1075        )
1076    }
1077}
1078
1079#[must_use = "FIDL methods require a response to be sent"]
1080#[derive(Debug)]
1081pub struct ScreenCaptureGetNextFrameResponder {
1082    control_handle: std::mem::ManuallyDrop<ScreenCaptureControlHandle>,
1083    tx_id: u32,
1084}
1085
1086/// Set the the channel to be shutdown (see [`ScreenCaptureControlHandle::shutdown`])
1087/// if the responder is dropped without sending a response, so that the client
1088/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1089impl std::ops::Drop for ScreenCaptureGetNextFrameResponder {
1090    fn drop(&mut self) {
1091        self.control_handle.shutdown();
1092        // Safety: drops once, never accessed again
1093        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1094    }
1095}
1096
1097impl fidl::endpoints::Responder for ScreenCaptureGetNextFrameResponder {
1098    type ControlHandle = ScreenCaptureControlHandle;
1099
1100    fn control_handle(&self) -> &ScreenCaptureControlHandle {
1101        &self.control_handle
1102    }
1103
1104    fn drop_without_shutdown(mut self) {
1105        // Safety: drops once, never accessed again due to mem::forget
1106        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1107        // Prevent Drop from running (which would shut down the channel)
1108        std::mem::forget(self);
1109    }
1110}
1111
1112impl ScreenCaptureGetNextFrameResponder {
1113    /// Sends a response to the FIDL transaction.
1114    ///
1115    /// Sets the channel to shutdown if an error occurs.
1116    pub fn send(
1117        self,
1118        mut result: Result<FrameInfo, ScreenCaptureError>,
1119    ) -> Result<(), fidl::Error> {
1120        let _result = self.send_raw(result);
1121        if _result.is_err() {
1122            self.control_handle.shutdown();
1123        }
1124        self.drop_without_shutdown();
1125        _result
1126    }
1127
1128    /// Similar to "send" but does not shutdown the channel if an error occurs.
1129    pub fn send_no_shutdown_on_err(
1130        self,
1131        mut result: Result<FrameInfo, ScreenCaptureError>,
1132    ) -> Result<(), fidl::Error> {
1133        let _result = self.send_raw(result);
1134        self.drop_without_shutdown();
1135        _result
1136    }
1137
1138    fn send_raw(
1139        &self,
1140        mut result: Result<FrameInfo, ScreenCaptureError>,
1141    ) -> Result<(), fidl::Error> {
1142        self.control_handle.inner.send::<fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>>(
1143            result.as_mut().map_err(|e| *e),
1144            self.tx_id,
1145            0x48680722eab7103,
1146            fidl::encoding::DynamicFlags::empty(),
1147        )
1148    }
1149}
1150
1151mod internal {
1152    use super::*;
1153
1154    impl fidl::encoding::ResourceTypeMarker for DisplayOwnershipGetEventResponse {
1155        type Borrowed<'a> = &'a mut Self;
1156        fn take_or_borrow<'a>(
1157            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1158        ) -> Self::Borrowed<'a> {
1159            value
1160        }
1161    }
1162
1163    unsafe impl fidl::encoding::TypeMarker for DisplayOwnershipGetEventResponse {
1164        type Owned = Self;
1165
1166        #[inline(always)]
1167        fn inline_align(_context: fidl::encoding::Context) -> usize {
1168            4
1169        }
1170
1171        #[inline(always)]
1172        fn inline_size(_context: fidl::encoding::Context) -> usize {
1173            4
1174        }
1175    }
1176
1177    unsafe impl
1178        fidl::encoding::Encode<
1179            DisplayOwnershipGetEventResponse,
1180            fidl::encoding::DefaultFuchsiaResourceDialect,
1181        > for &mut DisplayOwnershipGetEventResponse
1182    {
1183        #[inline]
1184        unsafe fn encode(
1185            self,
1186            encoder: &mut fidl::encoding::Encoder<
1187                '_,
1188                fidl::encoding::DefaultFuchsiaResourceDialect,
1189            >,
1190            offset: usize,
1191            _depth: fidl::encoding::Depth,
1192        ) -> fidl::Result<()> {
1193            encoder.debug_check_bounds::<DisplayOwnershipGetEventResponse>(offset);
1194            // Delegate to tuple encoding.
1195            fidl::encoding::Encode::<
1196                DisplayOwnershipGetEventResponse,
1197                fidl::encoding::DefaultFuchsiaResourceDialect,
1198            >::encode(
1199                (<fidl::encoding::HandleType<
1200                    fidl::Event,
1201                    { fidl::ObjectType::EVENT.into_raw() },
1202                    2147483648,
1203                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1204                    &mut self.ownership_event,
1205                ),),
1206                encoder,
1207                offset,
1208                _depth,
1209            )
1210        }
1211    }
1212    unsafe impl<
1213            T0: fidl::encoding::Encode<
1214                fidl::encoding::HandleType<
1215                    fidl::Event,
1216                    { fidl::ObjectType::EVENT.into_raw() },
1217                    2147483648,
1218                >,
1219                fidl::encoding::DefaultFuchsiaResourceDialect,
1220            >,
1221        >
1222        fidl::encoding::Encode<
1223            DisplayOwnershipGetEventResponse,
1224            fidl::encoding::DefaultFuchsiaResourceDialect,
1225        > for (T0,)
1226    {
1227        #[inline]
1228        unsafe fn encode(
1229            self,
1230            encoder: &mut fidl::encoding::Encoder<
1231                '_,
1232                fidl::encoding::DefaultFuchsiaResourceDialect,
1233            >,
1234            offset: usize,
1235            depth: fidl::encoding::Depth,
1236        ) -> fidl::Result<()> {
1237            encoder.debug_check_bounds::<DisplayOwnershipGetEventResponse>(offset);
1238            // Zero out padding regions. There's no need to apply masks
1239            // because the unmasked parts will be overwritten by fields.
1240            // Write the fields.
1241            self.0.encode(encoder, offset + 0, depth)?;
1242            Ok(())
1243        }
1244    }
1245
1246    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1247        for DisplayOwnershipGetEventResponse
1248    {
1249        #[inline(always)]
1250        fn new_empty() -> Self {
1251            Self {
1252                ownership_event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1253            }
1254        }
1255
1256        #[inline]
1257        unsafe fn decode(
1258            &mut self,
1259            decoder: &mut fidl::encoding::Decoder<
1260                '_,
1261                fidl::encoding::DefaultFuchsiaResourceDialect,
1262            >,
1263            offset: usize,
1264            _depth: fidl::encoding::Depth,
1265        ) -> fidl::Result<()> {
1266            decoder.debug_check_bounds::<Self>(offset);
1267            // Verify that padding bytes are zero.
1268            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.ownership_event, decoder, offset + 0, _depth)?;
1269            Ok(())
1270        }
1271    }
1272
1273    impl FrameInfo {
1274        #[inline(always)]
1275        fn max_ordinal_present(&self) -> u64 {
1276            if let Some(_) = self.buffer_release_token {
1277                return 3;
1278            }
1279            if let Some(_) = self.capture_timestamp {
1280                return 2;
1281            }
1282            if let Some(_) = self.buffer_index {
1283                return 1;
1284            }
1285            0
1286        }
1287    }
1288
1289    impl fidl::encoding::ResourceTypeMarker for FrameInfo {
1290        type Borrowed<'a> = &'a mut Self;
1291        fn take_or_borrow<'a>(
1292            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1293        ) -> Self::Borrowed<'a> {
1294            value
1295        }
1296    }
1297
1298    unsafe impl fidl::encoding::TypeMarker for FrameInfo {
1299        type Owned = Self;
1300
1301        #[inline(always)]
1302        fn inline_align(_context: fidl::encoding::Context) -> usize {
1303            8
1304        }
1305
1306        #[inline(always)]
1307        fn inline_size(_context: fidl::encoding::Context) -> usize {
1308            16
1309        }
1310    }
1311
1312    unsafe impl fidl::encoding::Encode<FrameInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
1313        for &mut FrameInfo
1314    {
1315        unsafe fn encode(
1316            self,
1317            encoder: &mut fidl::encoding::Encoder<
1318                '_,
1319                fidl::encoding::DefaultFuchsiaResourceDialect,
1320            >,
1321            offset: usize,
1322            mut depth: fidl::encoding::Depth,
1323        ) -> fidl::Result<()> {
1324            encoder.debug_check_bounds::<FrameInfo>(offset);
1325            // Vector header
1326            let max_ordinal: u64 = self.max_ordinal_present();
1327            encoder.write_num(max_ordinal, offset);
1328            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1329            // Calling encoder.out_of_line_offset(0) is not allowed.
1330            if max_ordinal == 0 {
1331                return Ok(());
1332            }
1333            depth.increment()?;
1334            let envelope_size = 8;
1335            let bytes_len = max_ordinal as usize * envelope_size;
1336            #[allow(unused_variables)]
1337            let offset = encoder.out_of_line_offset(bytes_len);
1338            let mut _prev_end_offset: usize = 0;
1339            if 1 > max_ordinal {
1340                return Ok(());
1341            }
1342
1343            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1344            // are envelope_size bytes.
1345            let cur_offset: usize = (1 - 1) * envelope_size;
1346
1347            // Zero reserved fields.
1348            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1349
1350            // Safety:
1351            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1352            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1353            //   envelope_size bytes, there is always sufficient room.
1354            fidl::encoding::encode_in_envelope_optional::<
1355                u32,
1356                fidl::encoding::DefaultFuchsiaResourceDialect,
1357            >(
1358                self.buffer_index.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1359                encoder,
1360                offset + cur_offset,
1361                depth,
1362            )?;
1363
1364            _prev_end_offset = cur_offset + envelope_size;
1365            if 2 > max_ordinal {
1366                return Ok(());
1367            }
1368
1369            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1370            // are envelope_size bytes.
1371            let cur_offset: usize = (2 - 1) * envelope_size;
1372
1373            // Zero reserved fields.
1374            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1375
1376            // Safety:
1377            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1378            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1379            //   envelope_size bytes, there is always sufficient room.
1380            fidl::encoding::encode_in_envelope_optional::<
1381                i64,
1382                fidl::encoding::DefaultFuchsiaResourceDialect,
1383            >(
1384                self.capture_timestamp
1385                    .as_ref()
1386                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1387                encoder,
1388                offset + cur_offset,
1389                depth,
1390            )?;
1391
1392            _prev_end_offset = cur_offset + envelope_size;
1393            if 3 > max_ordinal {
1394                return Ok(());
1395            }
1396
1397            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1398            // are envelope_size bytes.
1399            let cur_offset: usize = (3 - 1) * envelope_size;
1400
1401            // Zero reserved fields.
1402            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1403
1404            // Safety:
1405            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1406            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1407            //   envelope_size bytes, there is always sufficient room.
1408            fidl::encoding::encode_in_envelope_optional::<
1409                fidl::encoding::HandleType<
1410                    fidl::EventPair,
1411                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1412                    2147483648,
1413                >,
1414                fidl::encoding::DefaultFuchsiaResourceDialect,
1415            >(
1416                self.buffer_release_token.as_mut().map(
1417                    <fidl::encoding::HandleType<
1418                        fidl::EventPair,
1419                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1420                        2147483648,
1421                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1422                ),
1423                encoder,
1424                offset + cur_offset,
1425                depth,
1426            )?;
1427
1428            _prev_end_offset = cur_offset + envelope_size;
1429
1430            Ok(())
1431        }
1432    }
1433
1434    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FrameInfo {
1435        #[inline(always)]
1436        fn new_empty() -> Self {
1437            Self::default()
1438        }
1439
1440        unsafe fn decode(
1441            &mut self,
1442            decoder: &mut fidl::encoding::Decoder<
1443                '_,
1444                fidl::encoding::DefaultFuchsiaResourceDialect,
1445            >,
1446            offset: usize,
1447            mut depth: fidl::encoding::Depth,
1448        ) -> fidl::Result<()> {
1449            decoder.debug_check_bounds::<Self>(offset);
1450            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1451                None => return Err(fidl::Error::NotNullable),
1452                Some(len) => len,
1453            };
1454            // Calling decoder.out_of_line_offset(0) is not allowed.
1455            if len == 0 {
1456                return Ok(());
1457            };
1458            depth.increment()?;
1459            let envelope_size = 8;
1460            let bytes_len = len * envelope_size;
1461            let offset = decoder.out_of_line_offset(bytes_len)?;
1462            // Decode the envelope for each type.
1463            let mut _next_ordinal_to_read = 0;
1464            let mut next_offset = offset;
1465            let end_offset = offset + bytes_len;
1466            _next_ordinal_to_read += 1;
1467            if next_offset >= end_offset {
1468                return Ok(());
1469            }
1470
1471            // Decode unknown envelopes for gaps in ordinals.
1472            while _next_ordinal_to_read < 1 {
1473                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1474                _next_ordinal_to_read += 1;
1475                next_offset += envelope_size;
1476            }
1477
1478            let next_out_of_line = decoder.next_out_of_line();
1479            let handles_before = decoder.remaining_handles();
1480            if let Some((inlined, num_bytes, num_handles)) =
1481                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1482            {
1483                let member_inline_size =
1484                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1485                if inlined != (member_inline_size <= 4) {
1486                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1487                }
1488                let inner_offset;
1489                let mut inner_depth = depth.clone();
1490                if inlined {
1491                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1492                    inner_offset = next_offset;
1493                } else {
1494                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1495                    inner_depth.increment()?;
1496                }
1497                let val_ref = self.buffer_index.get_or_insert_with(|| {
1498                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1499                });
1500                fidl::decode!(
1501                    u32,
1502                    fidl::encoding::DefaultFuchsiaResourceDialect,
1503                    val_ref,
1504                    decoder,
1505                    inner_offset,
1506                    inner_depth
1507                )?;
1508                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1509                {
1510                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1511                }
1512                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1513                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1514                }
1515            }
1516
1517            next_offset += envelope_size;
1518            _next_ordinal_to_read += 1;
1519            if next_offset >= end_offset {
1520                return Ok(());
1521            }
1522
1523            // Decode unknown envelopes for gaps in ordinals.
1524            while _next_ordinal_to_read < 2 {
1525                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1526                _next_ordinal_to_read += 1;
1527                next_offset += envelope_size;
1528            }
1529
1530            let next_out_of_line = decoder.next_out_of_line();
1531            let handles_before = decoder.remaining_handles();
1532            if let Some((inlined, num_bytes, num_handles)) =
1533                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1534            {
1535                let member_inline_size =
1536                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1537                if inlined != (member_inline_size <= 4) {
1538                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1539                }
1540                let inner_offset;
1541                let mut inner_depth = depth.clone();
1542                if inlined {
1543                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1544                    inner_offset = next_offset;
1545                } else {
1546                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1547                    inner_depth.increment()?;
1548                }
1549                let val_ref = self.capture_timestamp.get_or_insert_with(|| {
1550                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
1551                });
1552                fidl::decode!(
1553                    i64,
1554                    fidl::encoding::DefaultFuchsiaResourceDialect,
1555                    val_ref,
1556                    decoder,
1557                    inner_offset,
1558                    inner_depth
1559                )?;
1560                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1561                {
1562                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1563                }
1564                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1565                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1566                }
1567            }
1568
1569            next_offset += envelope_size;
1570            _next_ordinal_to_read += 1;
1571            if next_offset >= end_offset {
1572                return Ok(());
1573            }
1574
1575            // Decode unknown envelopes for gaps in ordinals.
1576            while _next_ordinal_to_read < 3 {
1577                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1578                _next_ordinal_to_read += 1;
1579                next_offset += envelope_size;
1580            }
1581
1582            let next_out_of_line = decoder.next_out_of_line();
1583            let handles_before = decoder.remaining_handles();
1584            if let Some((inlined, num_bytes, num_handles)) =
1585                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1586            {
1587                let member_inline_size = <fidl::encoding::HandleType<
1588                    fidl::EventPair,
1589                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1590                    2147483648,
1591                > as fidl::encoding::TypeMarker>::inline_size(
1592                    decoder.context
1593                );
1594                if inlined != (member_inline_size <= 4) {
1595                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1596                }
1597                let inner_offset;
1598                let mut inner_depth = depth.clone();
1599                if inlined {
1600                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1601                    inner_offset = next_offset;
1602                } else {
1603                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1604                    inner_depth.increment()?;
1605                }
1606                let val_ref =
1607                self.buffer_release_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
1608                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1609                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1610                {
1611                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1612                }
1613                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1614                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1615                }
1616            }
1617
1618            next_offset += envelope_size;
1619
1620            // Decode the remaining unknown envelopes.
1621            while next_offset < end_offset {
1622                _next_ordinal_to_read += 1;
1623                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1624                next_offset += envelope_size;
1625            }
1626
1627            Ok(())
1628        }
1629    }
1630
1631    impl ScreenCaptureConfig {
1632        #[inline(always)]
1633        fn max_ordinal_present(&self) -> u64 {
1634            if let Some(_) = self.image_rotation {
1635                return 3;
1636            }
1637            if let Some(_) = self.image_size {
1638                return 2;
1639            }
1640            if let Some(_) = self.import_token {
1641                return 1;
1642            }
1643            0
1644        }
1645    }
1646
1647    impl fidl::encoding::ResourceTypeMarker for ScreenCaptureConfig {
1648        type Borrowed<'a> = &'a mut Self;
1649        fn take_or_borrow<'a>(
1650            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1651        ) -> Self::Borrowed<'a> {
1652            value
1653        }
1654    }
1655
1656    unsafe impl fidl::encoding::TypeMarker for ScreenCaptureConfig {
1657        type Owned = Self;
1658
1659        #[inline(always)]
1660        fn inline_align(_context: fidl::encoding::Context) -> usize {
1661            8
1662        }
1663
1664        #[inline(always)]
1665        fn inline_size(_context: fidl::encoding::Context) -> usize {
1666            16
1667        }
1668    }
1669
1670    unsafe impl
1671        fidl::encoding::Encode<ScreenCaptureConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
1672        for &mut ScreenCaptureConfig
1673    {
1674        unsafe fn encode(
1675            self,
1676            encoder: &mut fidl::encoding::Encoder<
1677                '_,
1678                fidl::encoding::DefaultFuchsiaResourceDialect,
1679            >,
1680            offset: usize,
1681            mut depth: fidl::encoding::Depth,
1682        ) -> fidl::Result<()> {
1683            encoder.debug_check_bounds::<ScreenCaptureConfig>(offset);
1684            // Vector header
1685            let max_ordinal: u64 = self.max_ordinal_present();
1686            encoder.write_num(max_ordinal, offset);
1687            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1688            // Calling encoder.out_of_line_offset(0) is not allowed.
1689            if max_ordinal == 0 {
1690                return Ok(());
1691            }
1692            depth.increment()?;
1693            let envelope_size = 8;
1694            let bytes_len = max_ordinal as usize * envelope_size;
1695            #[allow(unused_variables)]
1696            let offset = encoder.out_of_line_offset(bytes_len);
1697            let mut _prev_end_offset: usize = 0;
1698            if 1 > max_ordinal {
1699                return Ok(());
1700            }
1701
1702            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1703            // are envelope_size bytes.
1704            let cur_offset: usize = (1 - 1) * envelope_size;
1705
1706            // Zero reserved fields.
1707            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1708
1709            // Safety:
1710            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1711            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1712            //   envelope_size bytes, there is always sufficient room.
1713            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_ui_composition::BufferCollectionImportToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
1714            self.import_token.as_mut().map(<fidl_fuchsia_ui_composition::BufferCollectionImportToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1715            encoder, offset + cur_offset, depth
1716        )?;
1717
1718            _prev_end_offset = cur_offset + envelope_size;
1719            if 2 > max_ordinal {
1720                return Ok(());
1721            }
1722
1723            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1724            // are envelope_size bytes.
1725            let cur_offset: usize = (2 - 1) * envelope_size;
1726
1727            // Zero reserved fields.
1728            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1729
1730            // Safety:
1731            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1732            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1733            //   envelope_size bytes, there is always sufficient room.
1734            fidl::encoding::encode_in_envelope_optional::<
1735                fidl_fuchsia_math::SizeU,
1736                fidl::encoding::DefaultFuchsiaResourceDialect,
1737            >(
1738                self.image_size
1739                    .as_ref()
1740                    .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
1741                encoder,
1742                offset + cur_offset,
1743                depth,
1744            )?;
1745
1746            _prev_end_offset = cur_offset + envelope_size;
1747            if 3 > max_ordinal {
1748                return Ok(());
1749            }
1750
1751            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1752            // are envelope_size bytes.
1753            let cur_offset: usize = (3 - 1) * envelope_size;
1754
1755            // Zero reserved fields.
1756            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1757
1758            // Safety:
1759            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1760            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1761            //   envelope_size bytes, there is always sufficient room.
1762            fidl::encoding::encode_in_envelope_optional::<
1763                ScreenCaptureRotation,
1764                fidl::encoding::DefaultFuchsiaResourceDialect,
1765            >(
1766                self.image_rotation
1767                    .as_ref()
1768                    .map(<ScreenCaptureRotation as fidl::encoding::ValueTypeMarker>::borrow),
1769                encoder,
1770                offset + cur_offset,
1771                depth,
1772            )?;
1773
1774            _prev_end_offset = cur_offset + envelope_size;
1775
1776            Ok(())
1777        }
1778    }
1779
1780    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1781        for ScreenCaptureConfig
1782    {
1783        #[inline(always)]
1784        fn new_empty() -> Self {
1785            Self::default()
1786        }
1787
1788        unsafe fn decode(
1789            &mut self,
1790            decoder: &mut fidl::encoding::Decoder<
1791                '_,
1792                fidl::encoding::DefaultFuchsiaResourceDialect,
1793            >,
1794            offset: usize,
1795            mut depth: fidl::encoding::Depth,
1796        ) -> fidl::Result<()> {
1797            decoder.debug_check_bounds::<Self>(offset);
1798            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1799                None => return Err(fidl::Error::NotNullable),
1800                Some(len) => len,
1801            };
1802            // Calling decoder.out_of_line_offset(0) is not allowed.
1803            if len == 0 {
1804                return Ok(());
1805            };
1806            depth.increment()?;
1807            let envelope_size = 8;
1808            let bytes_len = len * envelope_size;
1809            let offset = decoder.out_of_line_offset(bytes_len)?;
1810            // Decode the envelope for each type.
1811            let mut _next_ordinal_to_read = 0;
1812            let mut next_offset = offset;
1813            let end_offset = offset + bytes_len;
1814            _next_ordinal_to_read += 1;
1815            if next_offset >= end_offset {
1816                return Ok(());
1817            }
1818
1819            // Decode unknown envelopes for gaps in ordinals.
1820            while _next_ordinal_to_read < 1 {
1821                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1822                _next_ordinal_to_read += 1;
1823                next_offset += envelope_size;
1824            }
1825
1826            let next_out_of_line = decoder.next_out_of_line();
1827            let handles_before = decoder.remaining_handles();
1828            if let Some((inlined, num_bytes, num_handles)) =
1829                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1830            {
1831                let member_inline_size = <fidl_fuchsia_ui_composition::BufferCollectionImportToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1832                if inlined != (member_inline_size <= 4) {
1833                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1834                }
1835                let inner_offset;
1836                let mut inner_depth = depth.clone();
1837                if inlined {
1838                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1839                    inner_offset = next_offset;
1840                } else {
1841                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1842                    inner_depth.increment()?;
1843                }
1844                let val_ref = self.import_token.get_or_insert_with(|| {
1845                    fidl::new_empty!(
1846                        fidl_fuchsia_ui_composition::BufferCollectionImportToken,
1847                        fidl::encoding::DefaultFuchsiaResourceDialect
1848                    )
1849                });
1850                fidl::decode!(
1851                    fidl_fuchsia_ui_composition::BufferCollectionImportToken,
1852                    fidl::encoding::DefaultFuchsiaResourceDialect,
1853                    val_ref,
1854                    decoder,
1855                    inner_offset,
1856                    inner_depth
1857                )?;
1858                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1859                {
1860                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1861                }
1862                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1863                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1864                }
1865            }
1866
1867            next_offset += envelope_size;
1868            _next_ordinal_to_read += 1;
1869            if next_offset >= end_offset {
1870                return Ok(());
1871            }
1872
1873            // Decode unknown envelopes for gaps in ordinals.
1874            while _next_ordinal_to_read < 2 {
1875                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1876                _next_ordinal_to_read += 1;
1877                next_offset += envelope_size;
1878            }
1879
1880            let next_out_of_line = decoder.next_out_of_line();
1881            let handles_before = decoder.remaining_handles();
1882            if let Some((inlined, num_bytes, num_handles)) =
1883                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1884            {
1885                let member_inline_size =
1886                    <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
1887                        decoder.context,
1888                    );
1889                if inlined != (member_inline_size <= 4) {
1890                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1891                }
1892                let inner_offset;
1893                let mut inner_depth = depth.clone();
1894                if inlined {
1895                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1896                    inner_offset = next_offset;
1897                } else {
1898                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1899                    inner_depth.increment()?;
1900                }
1901                let val_ref = self.image_size.get_or_insert_with(|| {
1902                    fidl::new_empty!(
1903                        fidl_fuchsia_math::SizeU,
1904                        fidl::encoding::DefaultFuchsiaResourceDialect
1905                    )
1906                });
1907                fidl::decode!(
1908                    fidl_fuchsia_math::SizeU,
1909                    fidl::encoding::DefaultFuchsiaResourceDialect,
1910                    val_ref,
1911                    decoder,
1912                    inner_offset,
1913                    inner_depth
1914                )?;
1915                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1916                {
1917                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1918                }
1919                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1920                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1921                }
1922            }
1923
1924            next_offset += envelope_size;
1925            _next_ordinal_to_read += 1;
1926            if next_offset >= end_offset {
1927                return Ok(());
1928            }
1929
1930            // Decode unknown envelopes for gaps in ordinals.
1931            while _next_ordinal_to_read < 3 {
1932                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1933                _next_ordinal_to_read += 1;
1934                next_offset += envelope_size;
1935            }
1936
1937            let next_out_of_line = decoder.next_out_of_line();
1938            let handles_before = decoder.remaining_handles();
1939            if let Some((inlined, num_bytes, num_handles)) =
1940                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1941            {
1942                let member_inline_size =
1943                    <ScreenCaptureRotation as fidl::encoding::TypeMarker>::inline_size(
1944                        decoder.context,
1945                    );
1946                if inlined != (member_inline_size <= 4) {
1947                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1948                }
1949                let inner_offset;
1950                let mut inner_depth = depth.clone();
1951                if inlined {
1952                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1953                    inner_offset = next_offset;
1954                } else {
1955                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1956                    inner_depth.increment()?;
1957                }
1958                let val_ref = self.image_rotation.get_or_insert_with(|| {
1959                    fidl::new_empty!(
1960                        ScreenCaptureRotation,
1961                        fidl::encoding::DefaultFuchsiaResourceDialect
1962                    )
1963                });
1964                fidl::decode!(
1965                    ScreenCaptureRotation,
1966                    fidl::encoding::DefaultFuchsiaResourceDialect,
1967                    val_ref,
1968                    decoder,
1969                    inner_offset,
1970                    inner_depth
1971                )?;
1972                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1973                {
1974                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1975                }
1976                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1977                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1978                }
1979            }
1980
1981            next_offset += envelope_size;
1982
1983            // Decode the remaining unknown envelopes.
1984            while next_offset < end_offset {
1985                _next_ordinal_to_read += 1;
1986                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1987                next_offset += envelope_size;
1988            }
1989
1990            Ok(())
1991        }
1992    }
1993}