Skip to main content

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        Self { client: fidl::client::sync::Client::new(channel) }
75    }
76
77    pub fn into_channel(self) -> fidl::Channel {
78        self.client.into_channel()
79    }
80
81    /// Waits until an event arrives and returns it. It is safe for other
82    /// threads to make concurrent requests while waiting for an event.
83    pub fn wait_for_event(
84        &self,
85        deadline: zx::MonotonicInstant,
86    ) -> Result<SetupEvent, fidl::Error> {
87        SetupEvent::decode(self.client.wait_for_event::<SetupMarker>(deadline)?)
88    }
89
90    /// Returns the viewrefs for injection authority (`Config.context`) and injection
91    /// destination (`Config.target`).
92    ///
93    /// This only returns when valid context and target views exist.
94    /// Typically called just once.
95    pub fn r#get_view_refs(
96        &self,
97        ___deadline: zx::MonotonicInstant,
98    ) -> Result<(fidl_fuchsia_ui_views::ViewRef, fidl_fuchsia_ui_views::ViewRef), fidl::Error> {
99        let _response = self
100            .client
101            .send_query::<fidl::encoding::EmptyPayload, SetupGetViewRefsResponse, SetupMarker>(
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 = self
123            .client
124            .send_query::<fidl::encoding::EmptyPayload, SetupWatchViewportResponse, SetupMarker>(
125                (),
126                0x5488bc48af9c943a,
127                fidl::encoding::DynamicFlags::empty(),
128                ___deadline,
129            )?;
130        Ok(_response.viewport)
131    }
132}
133
134#[cfg(target_os = "fuchsia")]
135impl From<SetupSynchronousProxy> for zx::NullableHandle {
136    fn from(value: SetupSynchronousProxy) -> Self {
137        value.into_channel().into()
138    }
139}
140
141#[cfg(target_os = "fuchsia")]
142impl From<fidl::Channel> for SetupSynchronousProxy {
143    fn from(value: fidl::Channel) -> Self {
144        Self::new(value)
145    }
146}
147
148#[cfg(target_os = "fuchsia")]
149impl fidl::endpoints::FromClient for SetupSynchronousProxy {
150    type Protocol = SetupMarker;
151
152    fn from_client(value: fidl::endpoints::ClientEnd<SetupMarker>) -> Self {
153        Self::new(value.into_channel())
154    }
155}
156
157#[derive(Debug, Clone)]
158pub struct SetupProxy {
159    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
160}
161
162impl fidl::endpoints::Proxy for SetupProxy {
163    type Protocol = SetupMarker;
164
165    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
166        Self::new(inner)
167    }
168
169    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
170        self.client.into_channel().map_err(|client| Self { client })
171    }
172
173    fn as_channel(&self) -> &::fidl::AsyncChannel {
174        self.client.as_channel()
175    }
176}
177
178impl SetupProxy {
179    /// Create a new Proxy for fuchsia.ui.pointerinjector.configuration/Setup.
180    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
181        let protocol_name = <SetupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
182        Self { client: fidl::client::Client::new(channel, protocol_name) }
183    }
184
185    /// Get a Stream of events from the remote end of the protocol.
186    ///
187    /// # Panics
188    ///
189    /// Panics if the event stream was already taken.
190    pub fn take_event_stream(&self) -> SetupEventStream {
191        SetupEventStream { event_receiver: self.client.take_event_receiver() }
192    }
193
194    /// Returns the viewrefs for injection authority (`Config.context`) and injection
195    /// destination (`Config.target`).
196    ///
197    /// This only returns when valid context and target views exist.
198    /// Typically called just once.
199    pub fn r#get_view_refs(
200        &self,
201    ) -> fidl::client::QueryResponseFut<
202        (fidl_fuchsia_ui_views::ViewRef, fidl_fuchsia_ui_views::ViewRef),
203        fidl::encoding::DefaultFuchsiaResourceDialect,
204    > {
205        SetupProxyInterface::r#get_view_refs(self)
206    }
207
208    /// Returns the current viewport. Follows the hanging get pattern.
209    ///
210    /// The first call to this function will return the current viewport, whenever
211    /// one exists. Subsequent calls will block until the viewport has been updated.
212    ///
213    /// Flow control: There should only be one outstanding call to this function.
214    /// The channel will be closed if an additional call to this function is made
215    /// while a call is outstanding.
216    pub fn r#watch_viewport(
217        &self,
218    ) -> fidl::client::QueryResponseFut<
219        fidl_fuchsia_ui_pointerinjector::Viewport,
220        fidl::encoding::DefaultFuchsiaResourceDialect,
221    > {
222        SetupProxyInterface::r#watch_viewport(self)
223    }
224}
225
226impl SetupProxyInterface for SetupProxy {
227    type GetViewRefsResponseFut = fidl::client::QueryResponseFut<
228        (fidl_fuchsia_ui_views::ViewRef, fidl_fuchsia_ui_views::ViewRef),
229        fidl::encoding::DefaultFuchsiaResourceDialect,
230    >;
231    fn r#get_view_refs(&self) -> Self::GetViewRefsResponseFut {
232        fn _decode(
233            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
234        ) -> Result<(fidl_fuchsia_ui_views::ViewRef, fidl_fuchsia_ui_views::ViewRef), fidl::Error>
235        {
236            let _response = fidl::client::decode_transaction_body::<
237                SetupGetViewRefsResponse,
238                fidl::encoding::DefaultFuchsiaResourceDialect,
239                0x5d7cc6a455bdde6,
240            >(_buf?)?;
241            Ok((_response.context, _response.target))
242        }
243        self.client.send_query_and_decode::<
244            fidl::encoding::EmptyPayload,
245            (fidl_fuchsia_ui_views::ViewRef, fidl_fuchsia_ui_views::ViewRef),
246        >(
247            (),
248            0x5d7cc6a455bdde6,
249            fidl::encoding::DynamicFlags::empty(),
250            _decode,
251        )
252    }
253
254    type WatchViewportResponseFut = fidl::client::QueryResponseFut<
255        fidl_fuchsia_ui_pointerinjector::Viewport,
256        fidl::encoding::DefaultFuchsiaResourceDialect,
257    >;
258    fn r#watch_viewport(&self) -> Self::WatchViewportResponseFut {
259        fn _decode(
260            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
261        ) -> Result<fidl_fuchsia_ui_pointerinjector::Viewport, fidl::Error> {
262            let _response = fidl::client::decode_transaction_body::<
263                SetupWatchViewportResponse,
264                fidl::encoding::DefaultFuchsiaResourceDialect,
265                0x5488bc48af9c943a,
266            >(_buf?)?;
267            Ok(_response.viewport)
268        }
269        self.client.send_query_and_decode::<
270            fidl::encoding::EmptyPayload,
271            fidl_fuchsia_ui_pointerinjector::Viewport,
272        >(
273            (),
274            0x5488bc48af9c943a,
275            fidl::encoding::DynamicFlags::empty(),
276            _decode,
277        )
278    }
279}
280
281pub struct SetupEventStream {
282    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
283}
284
285impl std::marker::Unpin for SetupEventStream {}
286
287impl futures::stream::FusedStream for SetupEventStream {
288    fn is_terminated(&self) -> bool {
289        self.event_receiver.is_terminated()
290    }
291}
292
293impl futures::Stream for SetupEventStream {
294    type Item = Result<SetupEvent, fidl::Error>;
295
296    fn poll_next(
297        mut self: std::pin::Pin<&mut Self>,
298        cx: &mut std::task::Context<'_>,
299    ) -> std::task::Poll<Option<Self::Item>> {
300        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
301            &mut self.event_receiver,
302            cx
303        )?) {
304            Some(buf) => std::task::Poll::Ready(Some(SetupEvent::decode(buf))),
305            None => std::task::Poll::Ready(None),
306        }
307    }
308}
309
310#[derive(Debug)]
311pub enum SetupEvent {}
312
313impl SetupEvent {
314    /// Decodes a message buffer as a [`SetupEvent`].
315    fn decode(
316        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
317    ) -> Result<SetupEvent, fidl::Error> {
318        let (bytes, _handles) = buf.split_mut();
319        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
320        debug_assert_eq!(tx_header.tx_id, 0);
321        match tx_header.ordinal {
322            _ => Err(fidl::Error::UnknownOrdinal {
323                ordinal: tx_header.ordinal,
324                protocol_name: <SetupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
325            }),
326        }
327    }
328}
329
330/// A Stream of incoming requests for fuchsia.ui.pointerinjector.configuration/Setup.
331pub struct SetupRequestStream {
332    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
333    is_terminated: bool,
334}
335
336impl std::marker::Unpin for SetupRequestStream {}
337
338impl futures::stream::FusedStream for SetupRequestStream {
339    fn is_terminated(&self) -> bool {
340        self.is_terminated
341    }
342}
343
344impl fidl::endpoints::RequestStream for SetupRequestStream {
345    type Protocol = SetupMarker;
346    type ControlHandle = SetupControlHandle;
347
348    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
349        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
350    }
351
352    fn control_handle(&self) -> Self::ControlHandle {
353        SetupControlHandle { inner: self.inner.clone() }
354    }
355
356    fn into_inner(
357        self,
358    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
359    {
360        (self.inner, self.is_terminated)
361    }
362
363    fn from_inner(
364        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
365        is_terminated: bool,
366    ) -> Self {
367        Self { inner, is_terminated }
368    }
369}
370
371impl futures::Stream for SetupRequestStream {
372    type Item = Result<SetupRequest, fidl::Error>;
373
374    fn poll_next(
375        mut self: std::pin::Pin<&mut Self>,
376        cx: &mut std::task::Context<'_>,
377    ) -> std::task::Poll<Option<Self::Item>> {
378        let this = &mut *self;
379        if this.inner.check_shutdown(cx) {
380            this.is_terminated = true;
381            return std::task::Poll::Ready(None);
382        }
383        if this.is_terminated {
384            panic!("polled SetupRequestStream after completion");
385        }
386        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
387            |bytes, handles| {
388                match this.inner.channel().read_etc(cx, bytes, handles) {
389                    std::task::Poll::Ready(Ok(())) => {}
390                    std::task::Poll::Pending => return std::task::Poll::Pending,
391                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
392                        this.is_terminated = true;
393                        return std::task::Poll::Ready(None);
394                    }
395                    std::task::Poll::Ready(Err(e)) => {
396                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
397                            e.into(),
398                        ))));
399                    }
400                }
401
402                // A message has been received from the channel
403                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
404
405                std::task::Poll::Ready(Some(match header.ordinal {
406                    0x5d7cc6a455bdde6 => {
407                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
408                        let mut req = fidl::new_empty!(
409                            fidl::encoding::EmptyPayload,
410                            fidl::encoding::DefaultFuchsiaResourceDialect
411                        );
412                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
413                        let control_handle = SetupControlHandle { inner: this.inner.clone() };
414                        Ok(SetupRequest::GetViewRefs {
415                            responder: SetupGetViewRefsResponder {
416                                control_handle: std::mem::ManuallyDrop::new(control_handle),
417                                tx_id: header.tx_id,
418                            },
419                        })
420                    }
421                    0x5488bc48af9c943a => {
422                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
423                        let mut req = fidl::new_empty!(
424                            fidl::encoding::EmptyPayload,
425                            fidl::encoding::DefaultFuchsiaResourceDialect
426                        );
427                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
428                        let control_handle = SetupControlHandle { inner: this.inner.clone() };
429                        Ok(SetupRequest::WatchViewport {
430                            responder: SetupWatchViewportResponder {
431                                control_handle: std::mem::ManuallyDrop::new(control_handle),
432                                tx_id: header.tx_id,
433                            },
434                        })
435                    }
436                    _ => Err(fidl::Error::UnknownOrdinal {
437                        ordinal: header.ordinal,
438                        protocol_name: <SetupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
439                    }),
440                }))
441            },
442        )
443    }
444}
445
446/// A service used by an input pipeline to set up pointer injection into Scenic.
447/// This should be implemented by the component that configures the scene
448/// (Root Presenter or Scene Manager).
449#[derive(Debug)]
450pub enum SetupRequest {
451    /// Returns the viewrefs for injection authority (`Config.context`) and injection
452    /// destination (`Config.target`).
453    ///
454    /// This only returns when valid context and target views exist.
455    /// Typically called just once.
456    GetViewRefs { responder: SetupGetViewRefsResponder },
457    /// Returns the current viewport. Follows the hanging get pattern.
458    ///
459    /// The first call to this function will return the current viewport, whenever
460    /// one exists. Subsequent calls will block until the viewport has been updated.
461    ///
462    /// Flow control: There should only be one outstanding call to this function.
463    /// The channel will be closed if an additional call to this function is made
464    /// while a call is outstanding.
465    WatchViewport { responder: SetupWatchViewportResponder },
466}
467
468impl SetupRequest {
469    #[allow(irrefutable_let_patterns)]
470    pub fn into_get_view_refs(self) -> Option<(SetupGetViewRefsResponder)> {
471        if let SetupRequest::GetViewRefs { responder } = self { Some((responder)) } else { None }
472    }
473
474    #[allow(irrefutable_let_patterns)]
475    pub fn into_watch_viewport(self) -> Option<(SetupWatchViewportResponder)> {
476        if let SetupRequest::WatchViewport { responder } = self { Some((responder)) } else { None }
477    }
478
479    /// Name of the method defined in FIDL
480    pub fn method_name(&self) -> &'static str {
481        match *self {
482            SetupRequest::GetViewRefs { .. } => "get_view_refs",
483            SetupRequest::WatchViewport { .. } => "watch_viewport",
484        }
485    }
486}
487
488#[derive(Debug, Clone)]
489pub struct SetupControlHandle {
490    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
491}
492
493impl SetupControlHandle {
494    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
495        self.inner.shutdown_with_epitaph(status.into())
496    }
497}
498
499impl fidl::endpoints::ControlHandle for SetupControlHandle {
500    fn shutdown(&self) {
501        self.inner.shutdown()
502    }
503
504    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
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}