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::NullableHandle {
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 { Some((responder)) } else { None }
471    }
472
473    #[allow(irrefutable_let_patterns)]
474    pub fn into_watch_viewport(self) -> Option<(SetupWatchViewportResponder)> {
475        if let SetupRequest::WatchViewport { responder } = self { Some((responder)) } else { None }
476    }
477
478    /// Name of the method defined in FIDL
479    pub fn method_name(&self) -> &'static str {
480        match *self {
481            SetupRequest::GetViewRefs { .. } => "get_view_refs",
482            SetupRequest::WatchViewport { .. } => "watch_viewport",
483        }
484    }
485}
486
487#[derive(Debug, Clone)]
488pub struct SetupControlHandle {
489    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
490}
491
492impl fidl::endpoints::ControlHandle for SetupControlHandle {
493    fn shutdown(&self) {
494        self.inner.shutdown()
495    }
496
497    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
498        self.inner.shutdown_with_epitaph(status)
499    }
500
501    fn is_closed(&self) -> bool {
502        self.inner.channel().is_closed()
503    }
504    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
505        self.inner.channel().on_closed()
506    }
507
508    #[cfg(target_os = "fuchsia")]
509    fn signal_peer(
510        &self,
511        clear_mask: zx::Signals,
512        set_mask: zx::Signals,
513    ) -> Result<(), zx_status::Status> {
514        use fidl::Peered;
515        self.inner.channel().signal_peer(clear_mask, set_mask)
516    }
517}
518
519impl SetupControlHandle {}
520
521#[must_use = "FIDL methods require a response to be sent"]
522#[derive(Debug)]
523pub struct SetupGetViewRefsResponder {
524    control_handle: std::mem::ManuallyDrop<SetupControlHandle>,
525    tx_id: u32,
526}
527
528/// Set the the channel to be shutdown (see [`SetupControlHandle::shutdown`])
529/// if the responder is dropped without sending a response, so that the client
530/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
531impl std::ops::Drop for SetupGetViewRefsResponder {
532    fn drop(&mut self) {
533        self.control_handle.shutdown();
534        // Safety: drops once, never accessed again
535        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
536    }
537}
538
539impl fidl::endpoints::Responder for SetupGetViewRefsResponder {
540    type ControlHandle = SetupControlHandle;
541
542    fn control_handle(&self) -> &SetupControlHandle {
543        &self.control_handle
544    }
545
546    fn drop_without_shutdown(mut self) {
547        // Safety: drops once, never accessed again due to mem::forget
548        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
549        // Prevent Drop from running (which would shut down the channel)
550        std::mem::forget(self);
551    }
552}
553
554impl SetupGetViewRefsResponder {
555    /// Sends a response to the FIDL transaction.
556    ///
557    /// Sets the channel to shutdown if an error occurs.
558    pub fn send(
559        self,
560        mut context: fidl_fuchsia_ui_views::ViewRef,
561        mut target: fidl_fuchsia_ui_views::ViewRef,
562    ) -> Result<(), fidl::Error> {
563        let _result = self.send_raw(context, target);
564        if _result.is_err() {
565            self.control_handle.shutdown();
566        }
567        self.drop_without_shutdown();
568        _result
569    }
570
571    /// Similar to "send" but does not shutdown the channel if an error occurs.
572    pub fn send_no_shutdown_on_err(
573        self,
574        mut context: fidl_fuchsia_ui_views::ViewRef,
575        mut target: fidl_fuchsia_ui_views::ViewRef,
576    ) -> Result<(), fidl::Error> {
577        let _result = self.send_raw(context, target);
578        self.drop_without_shutdown();
579        _result
580    }
581
582    fn send_raw(
583        &self,
584        mut context: fidl_fuchsia_ui_views::ViewRef,
585        mut target: fidl_fuchsia_ui_views::ViewRef,
586    ) -> Result<(), fidl::Error> {
587        self.control_handle.inner.send::<SetupGetViewRefsResponse>(
588            (&mut context, &mut target),
589            self.tx_id,
590            0x5d7cc6a455bdde6,
591            fidl::encoding::DynamicFlags::empty(),
592        )
593    }
594}
595
596#[must_use = "FIDL methods require a response to be sent"]
597#[derive(Debug)]
598pub struct SetupWatchViewportResponder {
599    control_handle: std::mem::ManuallyDrop<SetupControlHandle>,
600    tx_id: u32,
601}
602
603/// Set the the channel to be shutdown (see [`SetupControlHandle::shutdown`])
604/// if the responder is dropped without sending a response, so that the client
605/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
606impl std::ops::Drop for SetupWatchViewportResponder {
607    fn drop(&mut self) {
608        self.control_handle.shutdown();
609        // Safety: drops once, never accessed again
610        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
611    }
612}
613
614impl fidl::endpoints::Responder for SetupWatchViewportResponder {
615    type ControlHandle = SetupControlHandle;
616
617    fn control_handle(&self) -> &SetupControlHandle {
618        &self.control_handle
619    }
620
621    fn drop_without_shutdown(mut self) {
622        // Safety: drops once, never accessed again due to mem::forget
623        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
624        // Prevent Drop from running (which would shut down the channel)
625        std::mem::forget(self);
626    }
627}
628
629impl SetupWatchViewportResponder {
630    /// Sends a response to the FIDL transaction.
631    ///
632    /// Sets the channel to shutdown if an error occurs.
633    pub fn send(
634        self,
635        mut viewport: &fidl_fuchsia_ui_pointerinjector::Viewport,
636    ) -> Result<(), fidl::Error> {
637        let _result = self.send_raw(viewport);
638        if _result.is_err() {
639            self.control_handle.shutdown();
640        }
641        self.drop_without_shutdown();
642        _result
643    }
644
645    /// Similar to "send" but does not shutdown the channel if an error occurs.
646    pub fn send_no_shutdown_on_err(
647        self,
648        mut viewport: &fidl_fuchsia_ui_pointerinjector::Viewport,
649    ) -> Result<(), fidl::Error> {
650        let _result = self.send_raw(viewport);
651        self.drop_without_shutdown();
652        _result
653    }
654
655    fn send_raw(
656        &self,
657        mut viewport: &fidl_fuchsia_ui_pointerinjector::Viewport,
658    ) -> Result<(), fidl::Error> {
659        self.control_handle.inner.send::<SetupWatchViewportResponse>(
660            (viewport,),
661            self.tx_id,
662            0x5488bc48af9c943a,
663            fidl::encoding::DynamicFlags::empty(),
664        )
665    }
666}
667
668mod internal {
669    use super::*;
670
671    impl fidl::encoding::ResourceTypeMarker for SetupGetViewRefsResponse {
672        type Borrowed<'a> = &'a mut Self;
673        fn take_or_borrow<'a>(
674            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
675        ) -> Self::Borrowed<'a> {
676            value
677        }
678    }
679
680    unsafe impl fidl::encoding::TypeMarker for SetupGetViewRefsResponse {
681        type Owned = Self;
682
683        #[inline(always)]
684        fn inline_align(_context: fidl::encoding::Context) -> usize {
685            4
686        }
687
688        #[inline(always)]
689        fn inline_size(_context: fidl::encoding::Context) -> usize {
690            8
691        }
692    }
693
694    unsafe impl
695        fidl::encoding::Encode<
696            SetupGetViewRefsResponse,
697            fidl::encoding::DefaultFuchsiaResourceDialect,
698        > for &mut SetupGetViewRefsResponse
699    {
700        #[inline]
701        unsafe fn encode(
702            self,
703            encoder: &mut fidl::encoding::Encoder<
704                '_,
705                fidl::encoding::DefaultFuchsiaResourceDialect,
706            >,
707            offset: usize,
708            _depth: fidl::encoding::Depth,
709        ) -> fidl::Result<()> {
710            encoder.debug_check_bounds::<SetupGetViewRefsResponse>(offset);
711            // Delegate to tuple encoding.
712            fidl::encoding::Encode::<SetupGetViewRefsResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
713                (
714                    <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.context),
715                    <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.target),
716                ),
717                encoder, offset, _depth
718            )
719        }
720    }
721    unsafe impl<
722        T0: fidl::encoding::Encode<
723                fidl_fuchsia_ui_views::ViewRef,
724                fidl::encoding::DefaultFuchsiaResourceDialect,
725            >,
726        T1: fidl::encoding::Encode<
727                fidl_fuchsia_ui_views::ViewRef,
728                fidl::encoding::DefaultFuchsiaResourceDialect,
729            >,
730    >
731        fidl::encoding::Encode<
732            SetupGetViewRefsResponse,
733            fidl::encoding::DefaultFuchsiaResourceDialect,
734        > for (T0, T1)
735    {
736        #[inline]
737        unsafe fn encode(
738            self,
739            encoder: &mut fidl::encoding::Encoder<
740                '_,
741                fidl::encoding::DefaultFuchsiaResourceDialect,
742            >,
743            offset: usize,
744            depth: fidl::encoding::Depth,
745        ) -> fidl::Result<()> {
746            encoder.debug_check_bounds::<SetupGetViewRefsResponse>(offset);
747            // Zero out padding regions. There's no need to apply masks
748            // because the unmasked parts will be overwritten by fields.
749            // Write the fields.
750            self.0.encode(encoder, offset + 0, depth)?;
751            self.1.encode(encoder, offset + 4, depth)?;
752            Ok(())
753        }
754    }
755
756    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
757        for SetupGetViewRefsResponse
758    {
759        #[inline(always)]
760        fn new_empty() -> Self {
761            Self {
762                context: fidl::new_empty!(
763                    fidl_fuchsia_ui_views::ViewRef,
764                    fidl::encoding::DefaultFuchsiaResourceDialect
765                ),
766                target: fidl::new_empty!(
767                    fidl_fuchsia_ui_views::ViewRef,
768                    fidl::encoding::DefaultFuchsiaResourceDialect
769                ),
770            }
771        }
772
773        #[inline]
774        unsafe fn decode(
775            &mut self,
776            decoder: &mut fidl::encoding::Decoder<
777                '_,
778                fidl::encoding::DefaultFuchsiaResourceDialect,
779            >,
780            offset: usize,
781            _depth: fidl::encoding::Depth,
782        ) -> fidl::Result<()> {
783            decoder.debug_check_bounds::<Self>(offset);
784            // Verify that padding bytes are zero.
785            fidl::decode!(
786                fidl_fuchsia_ui_views::ViewRef,
787                fidl::encoding::DefaultFuchsiaResourceDialect,
788                &mut self.context,
789                decoder,
790                offset + 0,
791                _depth
792            )?;
793            fidl::decode!(
794                fidl_fuchsia_ui_views::ViewRef,
795                fidl::encoding::DefaultFuchsiaResourceDialect,
796                &mut self.target,
797                decoder,
798                offset + 4,
799                _depth
800            )?;
801            Ok(())
802        }
803    }
804}