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