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