fidl_fuchsia_ui_composition_internal/
fidl_fuchsia_ui_composition_internal.rs

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