fidl_fuchsia_ui_pointerinjector_configuration/
fidl_fuchsia_ui_pointerinjector_configuration.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_pointerinjector_configuration__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct SetupGetViewRefsResponse {
16    pub context: fidl_fuchsia_ui_views::ViewRef,
17    pub target: fidl_fuchsia_ui_views::ViewRef,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SetupGetViewRefsResponse {}
21
22#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
23pub struct SetupMarker;
24
25impl fidl::endpoints::ProtocolMarker for SetupMarker {
26    type Proxy = SetupProxy;
27    type RequestStream = SetupRequestStream;
28    #[cfg(target_os = "fuchsia")]
29    type SynchronousProxy = SetupSynchronousProxy;
30
31    const DEBUG_NAME: &'static str = "fuchsia.ui.pointerinjector.configuration.Setup";
32}
33impl fidl::endpoints::DiscoverableProtocolMarker for SetupMarker {}
34
35pub trait SetupProxyInterface: Send + Sync {
36    type GetViewRefsResponseFut: std::future::Future<
37            Output = Result<
38                (fidl_fuchsia_ui_views::ViewRef, fidl_fuchsia_ui_views::ViewRef),
39                fidl::Error,
40            >,
41        > + Send;
42    fn r#get_view_refs(&self) -> Self::GetViewRefsResponseFut;
43    type WatchViewportResponseFut: std::future::Future<Output = Result<fidl_fuchsia_ui_pointerinjector::Viewport, fidl::Error>>
44        + Send;
45    fn r#watch_viewport(&self) -> Self::WatchViewportResponseFut;
46}
47#[derive(Debug)]
48#[cfg(target_os = "fuchsia")]
49pub struct SetupSynchronousProxy {
50    client: fidl::client::sync::Client,
51}
52
53#[cfg(target_os = "fuchsia")]
54impl fidl::endpoints::SynchronousProxy for SetupSynchronousProxy {
55    type Proxy = SetupProxy;
56    type Protocol = SetupMarker;
57
58    fn from_channel(inner: fidl::Channel) -> Self {
59        Self::new(inner)
60    }
61
62    fn into_channel(self) -> fidl::Channel {
63        self.client.into_channel()
64    }
65
66    fn as_channel(&self) -> &fidl::Channel {
67        self.client.as_channel()
68    }
69}
70
71#[cfg(target_os = "fuchsia")]
72impl SetupSynchronousProxy {
73    pub fn new(channel: fidl::Channel) -> Self {
74        let protocol_name = <SetupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
75        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
76    }
77
78    pub fn into_channel(self) -> fidl::Channel {
79        self.client.into_channel()
80    }
81
82    /// Waits until an event arrives and returns it. It is safe for other
83    /// threads to make concurrent requests while waiting for an event.
84    pub fn wait_for_event(
85        &self,
86        deadline: zx::MonotonicInstant,
87    ) -> Result<SetupEvent, fidl::Error> {
88        SetupEvent::decode(self.client.wait_for_event(deadline)?)
89    }
90
91    /// Returns the viewrefs for injection authority (`Config.context`) and injection
92    /// destination (`Config.target`).
93    ///
94    /// This only returns when valid context and target views exist.
95    /// Typically called just once.
96    pub fn r#get_view_refs(
97        &self,
98        ___deadline: zx::MonotonicInstant,
99    ) -> Result<(fidl_fuchsia_ui_views::ViewRef, fidl_fuchsia_ui_views::ViewRef), fidl::Error> {
100        let _response =
101            self.client.send_query::<fidl::encoding::EmptyPayload, SetupGetViewRefsResponse>(
102                (),
103                0x5d7cc6a455bdde6,
104                fidl::encoding::DynamicFlags::empty(),
105                ___deadline,
106            )?;
107        Ok((_response.context, _response.target))
108    }
109
110    /// Returns the current viewport. Follows the hanging get pattern.
111    ///
112    /// The first call to this function will return the current viewport, whenever
113    /// one exists. Subsequent calls will block until the viewport has been updated.
114    ///
115    /// Flow control: There should only be one outstanding call to this function.
116    /// The channel will be closed if an additional call to this function is made
117    /// while a call is outstanding.
118    pub fn r#watch_viewport(
119        &self,
120        ___deadline: zx::MonotonicInstant,
121    ) -> Result<fidl_fuchsia_ui_pointerinjector::Viewport, fidl::Error> {
122        let _response =
123            self.client.send_query::<fidl::encoding::EmptyPayload, SetupWatchViewportResponse>(
124                (),
125                0x5488bc48af9c943a,
126                fidl::encoding::DynamicFlags::empty(),
127                ___deadline,
128            )?;
129        Ok(_response.viewport)
130    }
131}
132
133#[cfg(target_os = "fuchsia")]
134impl From<SetupSynchronousProxy> for zx::Handle {
135    fn from(value: SetupSynchronousProxy) -> Self {
136        value.into_channel().into()
137    }
138}
139
140#[cfg(target_os = "fuchsia")]
141impl From<fidl::Channel> for SetupSynchronousProxy {
142    fn from(value: fidl::Channel) -> Self {
143        Self::new(value)
144    }
145}
146
147#[cfg(target_os = "fuchsia")]
148impl fidl::endpoints::FromClient for SetupSynchronousProxy {
149    type Protocol = SetupMarker;
150
151    fn from_client(value: fidl::endpoints::ClientEnd<SetupMarker>) -> Self {
152        Self::new(value.into_channel())
153    }
154}
155
156#[derive(Debug, Clone)]
157pub struct SetupProxy {
158    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
159}
160
161impl fidl::endpoints::Proxy for SetupProxy {
162    type Protocol = SetupMarker;
163
164    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
165        Self::new(inner)
166    }
167
168    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
169        self.client.into_channel().map_err(|client| Self { client })
170    }
171
172    fn as_channel(&self) -> &::fidl::AsyncChannel {
173        self.client.as_channel()
174    }
175}
176
177impl SetupProxy {
178    /// Create a new Proxy for fuchsia.ui.pointerinjector.configuration/Setup.
179    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
180        let protocol_name = <SetupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
181        Self { client: fidl::client::Client::new(channel, protocol_name) }
182    }
183
184    /// Get a Stream of events from the remote end of the protocol.
185    ///
186    /// # Panics
187    ///
188    /// Panics if the event stream was already taken.
189    pub fn take_event_stream(&self) -> SetupEventStream {
190        SetupEventStream { event_receiver: self.client.take_event_receiver() }
191    }
192
193    /// Returns the viewrefs for injection authority (`Config.context`) and injection
194    /// destination (`Config.target`).
195    ///
196    /// This only returns when valid context and target views exist.
197    /// Typically called just once.
198    pub fn r#get_view_refs(
199        &self,
200    ) -> fidl::client::QueryResponseFut<
201        (fidl_fuchsia_ui_views::ViewRef, fidl_fuchsia_ui_views::ViewRef),
202        fidl::encoding::DefaultFuchsiaResourceDialect,
203    > {
204        SetupProxyInterface::r#get_view_refs(self)
205    }
206
207    /// Returns the current viewport. Follows the hanging get pattern.
208    ///
209    /// The first call to this function will return the current viewport, whenever
210    /// one exists. Subsequent calls will block until the viewport has been updated.
211    ///
212    /// Flow control: There should only be one outstanding call to this function.
213    /// The channel will be closed if an additional call to this function is made
214    /// while a call is outstanding.
215    pub fn r#watch_viewport(
216        &self,
217    ) -> fidl::client::QueryResponseFut<
218        fidl_fuchsia_ui_pointerinjector::Viewport,
219        fidl::encoding::DefaultFuchsiaResourceDialect,
220    > {
221        SetupProxyInterface::r#watch_viewport(self)
222    }
223}
224
225impl SetupProxyInterface for SetupProxy {
226    type GetViewRefsResponseFut = fidl::client::QueryResponseFut<
227        (fidl_fuchsia_ui_views::ViewRef, fidl_fuchsia_ui_views::ViewRef),
228        fidl::encoding::DefaultFuchsiaResourceDialect,
229    >;
230    fn r#get_view_refs(&self) -> Self::GetViewRefsResponseFut {
231        fn _decode(
232            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
233        ) -> Result<(fidl_fuchsia_ui_views::ViewRef, fidl_fuchsia_ui_views::ViewRef), fidl::Error>
234        {
235            let _response = fidl::client::decode_transaction_body::<
236                SetupGetViewRefsResponse,
237                fidl::encoding::DefaultFuchsiaResourceDialect,
238                0x5d7cc6a455bdde6,
239            >(_buf?)?;
240            Ok((_response.context, _response.target))
241        }
242        self.client.send_query_and_decode::<
243            fidl::encoding::EmptyPayload,
244            (fidl_fuchsia_ui_views::ViewRef, fidl_fuchsia_ui_views::ViewRef),
245        >(
246            (),
247            0x5d7cc6a455bdde6,
248            fidl::encoding::DynamicFlags::empty(),
249            _decode,
250        )
251    }
252
253    type WatchViewportResponseFut = fidl::client::QueryResponseFut<
254        fidl_fuchsia_ui_pointerinjector::Viewport,
255        fidl::encoding::DefaultFuchsiaResourceDialect,
256    >;
257    fn r#watch_viewport(&self) -> Self::WatchViewportResponseFut {
258        fn _decode(
259            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
260        ) -> Result<fidl_fuchsia_ui_pointerinjector::Viewport, fidl::Error> {
261            let _response = fidl::client::decode_transaction_body::<
262                SetupWatchViewportResponse,
263                fidl::encoding::DefaultFuchsiaResourceDialect,
264                0x5488bc48af9c943a,
265            >(_buf?)?;
266            Ok(_response.viewport)
267        }
268        self.client.send_query_and_decode::<
269            fidl::encoding::EmptyPayload,
270            fidl_fuchsia_ui_pointerinjector::Viewport,
271        >(
272            (),
273            0x5488bc48af9c943a,
274            fidl::encoding::DynamicFlags::empty(),
275            _decode,
276        )
277    }
278}
279
280pub struct SetupEventStream {
281    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
282}
283
284impl std::marker::Unpin for SetupEventStream {}
285
286impl futures::stream::FusedStream for SetupEventStream {
287    fn is_terminated(&self) -> bool {
288        self.event_receiver.is_terminated()
289    }
290}
291
292impl futures::Stream for SetupEventStream {
293    type Item = Result<SetupEvent, fidl::Error>;
294
295    fn poll_next(
296        mut self: std::pin::Pin<&mut Self>,
297        cx: &mut std::task::Context<'_>,
298    ) -> std::task::Poll<Option<Self::Item>> {
299        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
300            &mut self.event_receiver,
301            cx
302        )?) {
303            Some(buf) => std::task::Poll::Ready(Some(SetupEvent::decode(buf))),
304            None => std::task::Poll::Ready(None),
305        }
306    }
307}
308
309#[derive(Debug)]
310pub enum SetupEvent {}
311
312impl SetupEvent {
313    /// Decodes a message buffer as a [`SetupEvent`].
314    fn decode(
315        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
316    ) -> Result<SetupEvent, fidl::Error> {
317        let (bytes, _handles) = buf.split_mut();
318        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
319        debug_assert_eq!(tx_header.tx_id, 0);
320        match tx_header.ordinal {
321            _ => Err(fidl::Error::UnknownOrdinal {
322                ordinal: tx_header.ordinal,
323                protocol_name: <SetupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
324            }),
325        }
326    }
327}
328
329/// A Stream of incoming requests for fuchsia.ui.pointerinjector.configuration/Setup.
330pub struct SetupRequestStream {
331    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
332    is_terminated: bool,
333}
334
335impl std::marker::Unpin for SetupRequestStream {}
336
337impl futures::stream::FusedStream for SetupRequestStream {
338    fn is_terminated(&self) -> bool {
339        self.is_terminated
340    }
341}
342
343impl fidl::endpoints::RequestStream for SetupRequestStream {
344    type Protocol = SetupMarker;
345    type ControlHandle = SetupControlHandle;
346
347    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
348        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
349    }
350
351    fn control_handle(&self) -> Self::ControlHandle {
352        SetupControlHandle { inner: self.inner.clone() }
353    }
354
355    fn into_inner(
356        self,
357    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
358    {
359        (self.inner, self.is_terminated)
360    }
361
362    fn from_inner(
363        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
364        is_terminated: bool,
365    ) -> Self {
366        Self { inner, is_terminated }
367    }
368}
369
370impl futures::Stream for SetupRequestStream {
371    type Item = Result<SetupRequest, fidl::Error>;
372
373    fn poll_next(
374        mut self: std::pin::Pin<&mut Self>,
375        cx: &mut std::task::Context<'_>,
376    ) -> std::task::Poll<Option<Self::Item>> {
377        let this = &mut *self;
378        if this.inner.check_shutdown(cx) {
379            this.is_terminated = true;
380            return std::task::Poll::Ready(None);
381        }
382        if this.is_terminated {
383            panic!("polled SetupRequestStream after completion");
384        }
385        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
386            |bytes, handles| {
387                match this.inner.channel().read_etc(cx, bytes, handles) {
388                    std::task::Poll::Ready(Ok(())) => {}
389                    std::task::Poll::Pending => return std::task::Poll::Pending,
390                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
391                        this.is_terminated = true;
392                        return std::task::Poll::Ready(None);
393                    }
394                    std::task::Poll::Ready(Err(e)) => {
395                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
396                            e.into(),
397                        ))))
398                    }
399                }
400
401                // A message has been received from the channel
402                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
403
404                std::task::Poll::Ready(Some(match header.ordinal {
405                    0x5d7cc6a455bdde6 => {
406                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
407                        let mut req = fidl::new_empty!(
408                            fidl::encoding::EmptyPayload,
409                            fidl::encoding::DefaultFuchsiaResourceDialect
410                        );
411                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
412                        let control_handle = SetupControlHandle { inner: this.inner.clone() };
413                        Ok(SetupRequest::GetViewRefs {
414                            responder: SetupGetViewRefsResponder {
415                                control_handle: std::mem::ManuallyDrop::new(control_handle),
416                                tx_id: header.tx_id,
417                            },
418                        })
419                    }
420                    0x5488bc48af9c943a => {
421                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
422                        let mut req = fidl::new_empty!(
423                            fidl::encoding::EmptyPayload,
424                            fidl::encoding::DefaultFuchsiaResourceDialect
425                        );
426                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
427                        let control_handle = SetupControlHandle { inner: this.inner.clone() };
428                        Ok(SetupRequest::WatchViewport {
429                            responder: SetupWatchViewportResponder {
430                                control_handle: std::mem::ManuallyDrop::new(control_handle),
431                                tx_id: header.tx_id,
432                            },
433                        })
434                    }
435                    _ => Err(fidl::Error::UnknownOrdinal {
436                        ordinal: header.ordinal,
437                        protocol_name: <SetupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
438                    }),
439                }))
440            },
441        )
442    }
443}
444
445/// A service used by an input pipeline to set up pointer injection into Scenic.
446/// This should be implemented by the component that configures the scene
447/// (Root Presenter or Scene Manager).
448#[derive(Debug)]
449pub enum SetupRequest {
450    /// Returns the viewrefs for injection authority (`Config.context`) and injection
451    /// destination (`Config.target`).
452    ///
453    /// This only returns when valid context and target views exist.
454    /// Typically called just once.
455    GetViewRefs { responder: SetupGetViewRefsResponder },
456    /// Returns the current viewport. Follows the hanging get pattern.
457    ///
458    /// The first call to this function will return the current viewport, whenever
459    /// one exists. Subsequent calls will block until the viewport has been updated.
460    ///
461    /// Flow control: There should only be one outstanding call to this function.
462    /// The channel will be closed if an additional call to this function is made
463    /// while a call is outstanding.
464    WatchViewport { responder: SetupWatchViewportResponder },
465}
466
467impl SetupRequest {
468    #[allow(irrefutable_let_patterns)]
469    pub fn into_get_view_refs(self) -> Option<(SetupGetViewRefsResponder)> {
470        if let SetupRequest::GetViewRefs { responder } = self {
471            Some((responder))
472        } else {
473            None
474        }
475    }
476
477    #[allow(irrefutable_let_patterns)]
478    pub fn into_watch_viewport(self) -> Option<(SetupWatchViewportResponder)> {
479        if let SetupRequest::WatchViewport { responder } = self {
480            Some((responder))
481        } else {
482            None
483        }
484    }
485
486    /// Name of the method defined in FIDL
487    pub fn method_name(&self) -> &'static str {
488        match *self {
489            SetupRequest::GetViewRefs { .. } => "get_view_refs",
490            SetupRequest::WatchViewport { .. } => "watch_viewport",
491        }
492    }
493}
494
495#[derive(Debug, Clone)]
496pub struct SetupControlHandle {
497    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
498}
499
500impl fidl::endpoints::ControlHandle for SetupControlHandle {
501    fn shutdown(&self) {
502        self.inner.shutdown()
503    }
504    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
505        self.inner.shutdown_with_epitaph(status)
506    }
507
508    fn is_closed(&self) -> bool {
509        self.inner.channel().is_closed()
510    }
511    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
512        self.inner.channel().on_closed()
513    }
514
515    #[cfg(target_os = "fuchsia")]
516    fn signal_peer(
517        &self,
518        clear_mask: zx::Signals,
519        set_mask: zx::Signals,
520    ) -> Result<(), zx_status::Status> {
521        use fidl::Peered;
522        self.inner.channel().signal_peer(clear_mask, set_mask)
523    }
524}
525
526impl SetupControlHandle {}
527
528#[must_use = "FIDL methods require a response to be sent"]
529#[derive(Debug)]
530pub struct SetupGetViewRefsResponder {
531    control_handle: std::mem::ManuallyDrop<SetupControlHandle>,
532    tx_id: u32,
533}
534
535/// Set the the channel to be shutdown (see [`SetupControlHandle::shutdown`])
536/// if the responder is dropped without sending a response, so that the client
537/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
538impl std::ops::Drop for SetupGetViewRefsResponder {
539    fn drop(&mut self) {
540        self.control_handle.shutdown();
541        // Safety: drops once, never accessed again
542        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
543    }
544}
545
546impl fidl::endpoints::Responder for SetupGetViewRefsResponder {
547    type ControlHandle = SetupControlHandle;
548
549    fn control_handle(&self) -> &SetupControlHandle {
550        &self.control_handle
551    }
552
553    fn drop_without_shutdown(mut self) {
554        // Safety: drops once, never accessed again due to mem::forget
555        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
556        // Prevent Drop from running (which would shut down the channel)
557        std::mem::forget(self);
558    }
559}
560
561impl SetupGetViewRefsResponder {
562    /// Sends a response to the FIDL transaction.
563    ///
564    /// Sets the channel to shutdown if an error occurs.
565    pub fn send(
566        self,
567        mut context: fidl_fuchsia_ui_views::ViewRef,
568        mut target: fidl_fuchsia_ui_views::ViewRef,
569    ) -> Result<(), fidl::Error> {
570        let _result = self.send_raw(context, target);
571        if _result.is_err() {
572            self.control_handle.shutdown();
573        }
574        self.drop_without_shutdown();
575        _result
576    }
577
578    /// Similar to "send" but does not shutdown the channel if an error occurs.
579    pub fn send_no_shutdown_on_err(
580        self,
581        mut context: fidl_fuchsia_ui_views::ViewRef,
582        mut target: fidl_fuchsia_ui_views::ViewRef,
583    ) -> Result<(), fidl::Error> {
584        let _result = self.send_raw(context, target);
585        self.drop_without_shutdown();
586        _result
587    }
588
589    fn send_raw(
590        &self,
591        mut context: fidl_fuchsia_ui_views::ViewRef,
592        mut target: fidl_fuchsia_ui_views::ViewRef,
593    ) -> Result<(), fidl::Error> {
594        self.control_handle.inner.send::<SetupGetViewRefsResponse>(
595            (&mut context, &mut target),
596            self.tx_id,
597            0x5d7cc6a455bdde6,
598            fidl::encoding::DynamicFlags::empty(),
599        )
600    }
601}
602
603#[must_use = "FIDL methods require a response to be sent"]
604#[derive(Debug)]
605pub struct SetupWatchViewportResponder {
606    control_handle: std::mem::ManuallyDrop<SetupControlHandle>,
607    tx_id: u32,
608}
609
610/// Set the the channel to be shutdown (see [`SetupControlHandle::shutdown`])
611/// if the responder is dropped without sending a response, so that the client
612/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
613impl std::ops::Drop for SetupWatchViewportResponder {
614    fn drop(&mut self) {
615        self.control_handle.shutdown();
616        // Safety: drops once, never accessed again
617        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
618    }
619}
620
621impl fidl::endpoints::Responder for SetupWatchViewportResponder {
622    type ControlHandle = SetupControlHandle;
623
624    fn control_handle(&self) -> &SetupControlHandle {
625        &self.control_handle
626    }
627
628    fn drop_without_shutdown(mut self) {
629        // Safety: drops once, never accessed again due to mem::forget
630        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
631        // Prevent Drop from running (which would shut down the channel)
632        std::mem::forget(self);
633    }
634}
635
636impl SetupWatchViewportResponder {
637    /// Sends a response to the FIDL transaction.
638    ///
639    /// Sets the channel to shutdown if an error occurs.
640    pub fn send(
641        self,
642        mut viewport: &fidl_fuchsia_ui_pointerinjector::Viewport,
643    ) -> Result<(), fidl::Error> {
644        let _result = self.send_raw(viewport);
645        if _result.is_err() {
646            self.control_handle.shutdown();
647        }
648        self.drop_without_shutdown();
649        _result
650    }
651
652    /// Similar to "send" but does not shutdown the channel if an error occurs.
653    pub fn send_no_shutdown_on_err(
654        self,
655        mut viewport: &fidl_fuchsia_ui_pointerinjector::Viewport,
656    ) -> Result<(), fidl::Error> {
657        let _result = self.send_raw(viewport);
658        self.drop_without_shutdown();
659        _result
660    }
661
662    fn send_raw(
663        &self,
664        mut viewport: &fidl_fuchsia_ui_pointerinjector::Viewport,
665    ) -> Result<(), fidl::Error> {
666        self.control_handle.inner.send::<SetupWatchViewportResponse>(
667            (viewport,),
668            self.tx_id,
669            0x5488bc48af9c943a,
670            fidl::encoding::DynamicFlags::empty(),
671        )
672    }
673}
674
675mod internal {
676    use super::*;
677
678    impl fidl::encoding::ResourceTypeMarker for SetupGetViewRefsResponse {
679        type Borrowed<'a> = &'a mut Self;
680        fn take_or_borrow<'a>(
681            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
682        ) -> Self::Borrowed<'a> {
683            value
684        }
685    }
686
687    unsafe impl fidl::encoding::TypeMarker for SetupGetViewRefsResponse {
688        type Owned = Self;
689
690        #[inline(always)]
691        fn inline_align(_context: fidl::encoding::Context) -> usize {
692            4
693        }
694
695        #[inline(always)]
696        fn inline_size(_context: fidl::encoding::Context) -> usize {
697            8
698        }
699    }
700
701    unsafe impl
702        fidl::encoding::Encode<
703            SetupGetViewRefsResponse,
704            fidl::encoding::DefaultFuchsiaResourceDialect,
705        > for &mut SetupGetViewRefsResponse
706    {
707        #[inline]
708        unsafe fn encode(
709            self,
710            encoder: &mut fidl::encoding::Encoder<
711                '_,
712                fidl::encoding::DefaultFuchsiaResourceDialect,
713            >,
714            offset: usize,
715            _depth: fidl::encoding::Depth,
716        ) -> fidl::Result<()> {
717            encoder.debug_check_bounds::<SetupGetViewRefsResponse>(offset);
718            // Delegate to tuple encoding.
719            fidl::encoding::Encode::<SetupGetViewRefsResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
720                (
721                    <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.context),
722                    <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.target),
723                ),
724                encoder, offset, _depth
725            )
726        }
727    }
728    unsafe impl<
729            T0: fidl::encoding::Encode<
730                fidl_fuchsia_ui_views::ViewRef,
731                fidl::encoding::DefaultFuchsiaResourceDialect,
732            >,
733            T1: fidl::encoding::Encode<
734                fidl_fuchsia_ui_views::ViewRef,
735                fidl::encoding::DefaultFuchsiaResourceDialect,
736            >,
737        >
738        fidl::encoding::Encode<
739            SetupGetViewRefsResponse,
740            fidl::encoding::DefaultFuchsiaResourceDialect,
741        > for (T0, T1)
742    {
743        #[inline]
744        unsafe fn encode(
745            self,
746            encoder: &mut fidl::encoding::Encoder<
747                '_,
748                fidl::encoding::DefaultFuchsiaResourceDialect,
749            >,
750            offset: usize,
751            depth: fidl::encoding::Depth,
752        ) -> fidl::Result<()> {
753            encoder.debug_check_bounds::<SetupGetViewRefsResponse>(offset);
754            // Zero out padding regions. There's no need to apply masks
755            // because the unmasked parts will be overwritten by fields.
756            // Write the fields.
757            self.0.encode(encoder, offset + 0, depth)?;
758            self.1.encode(encoder, offset + 4, depth)?;
759            Ok(())
760        }
761    }
762
763    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
764        for SetupGetViewRefsResponse
765    {
766        #[inline(always)]
767        fn new_empty() -> Self {
768            Self {
769                context: fidl::new_empty!(
770                    fidl_fuchsia_ui_views::ViewRef,
771                    fidl::encoding::DefaultFuchsiaResourceDialect
772                ),
773                target: fidl::new_empty!(
774                    fidl_fuchsia_ui_views::ViewRef,
775                    fidl::encoding::DefaultFuchsiaResourceDialect
776                ),
777            }
778        }
779
780        #[inline]
781        unsafe fn decode(
782            &mut self,
783            decoder: &mut fidl::encoding::Decoder<
784                '_,
785                fidl::encoding::DefaultFuchsiaResourceDialect,
786            >,
787            offset: usize,
788            _depth: fidl::encoding::Depth,
789        ) -> fidl::Result<()> {
790            decoder.debug_check_bounds::<Self>(offset);
791            // Verify that padding bytes are zero.
792            fidl::decode!(
793                fidl_fuchsia_ui_views::ViewRef,
794                fidl::encoding::DefaultFuchsiaResourceDialect,
795                &mut self.context,
796                decoder,
797                offset + 0,
798                _depth
799            )?;
800            fidl::decode!(
801                fidl_fuchsia_ui_views::ViewRef,
802                fidl::encoding::DefaultFuchsiaResourceDialect,
803                &mut self.target,
804                decoder,
805                offset + 4,
806                _depth
807            )?;
808            Ok(())
809        }
810    }
811}