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