Skip to main content

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