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