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