fidl_fuchsia_ui_pointer/
fidl_fuchsia_ui_pointer.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_pointer_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct MouseSourceMarker;
16
17impl fidl::endpoints::ProtocolMarker for MouseSourceMarker {
18    type Proxy = MouseSourceProxy;
19    type RequestStream = MouseSourceRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = MouseSourceSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) MouseSource";
24}
25
26pub trait MouseSourceProxyInterface: Send + Sync {
27    type WatchResponseFut: std::future::Future<Output = Result<Vec<MouseEvent>, fidl::Error>> + Send;
28    fn r#watch(&self) -> Self::WatchResponseFut;
29}
30#[derive(Debug)]
31#[cfg(target_os = "fuchsia")]
32pub struct MouseSourceSynchronousProxy {
33    client: fidl::client::sync::Client,
34}
35
36#[cfg(target_os = "fuchsia")]
37impl fidl::endpoints::SynchronousProxy for MouseSourceSynchronousProxy {
38    type Proxy = MouseSourceProxy;
39    type Protocol = MouseSourceMarker;
40
41    fn from_channel(inner: fidl::Channel) -> Self {
42        Self::new(inner)
43    }
44
45    fn into_channel(self) -> fidl::Channel {
46        self.client.into_channel()
47    }
48
49    fn as_channel(&self) -> &fidl::Channel {
50        self.client.as_channel()
51    }
52}
53
54#[cfg(target_os = "fuchsia")]
55impl MouseSourceSynchronousProxy {
56    pub fn new(channel: fidl::Channel) -> Self {
57        let protocol_name = <MouseSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
58        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
59    }
60
61    pub fn into_channel(self) -> fidl::Channel {
62        self.client.into_channel()
63    }
64
65    /// Waits until an event arrives and returns it. It is safe for other
66    /// threads to make concurrent requests while waiting for an event.
67    pub fn wait_for_event(
68        &self,
69        deadline: zx::MonotonicInstant,
70    ) -> Result<MouseSourceEvent, fidl::Error> {
71        MouseSourceEvent::decode(self.client.wait_for_event(deadline)?)
72    }
73
74    /// A method for a client to receive mouse pointer events.
75    ///
76    /// This call is formulated as a "hanging get" pattern: the client asks for
77    /// a set of recent events, and receives them via the callback. This
78    /// pull-based approach ensures that clients consume events at their own
79    /// pace; events don't clog up the channel in an unbounded manner.
80    ///
81    /// Flow control. The caller is allowed at most one in-flight |Watch| call
82    /// at a time; it is a logical error to have concurrent calls to |Watch|.
83    /// Non-compliance results in channel closure.
84    ///
85    /// Client pacing. The server will dispatch events to the caller on a FIFO,
86    /// lossless, best-effort basis, but the caller must allocate enough time to
87    /// keep up with new events.
88    ///
89    /// Event times. The timestamps on each event in the event vector are *not*
90    /// guaranteed monotonic; events from different devices may be injected into
91    /// Scenic at different times. Generally, events from a single device are
92    /// expected to have monotonically increasing timestamps.
93    ///
94    /// View parameters. Occasionally, changes in view or viewport require
95    /// notifying the client. If a |MouseEvent| carries |ViewParameters|, these
96    /// parameters apply to successive |MousePointerSample|s until the next
97    /// |ViewParameters|.
98    pub fn r#watch(
99        &self,
100        ___deadline: zx::MonotonicInstant,
101    ) -> Result<Vec<MouseEvent>, fidl::Error> {
102        let _response =
103            self.client.send_query::<fidl::encoding::EmptyPayload, MouseSourceWatchResponse>(
104                (),
105                0x5b1f6e917ac1abb4,
106                fidl::encoding::DynamicFlags::empty(),
107                ___deadline,
108            )?;
109        Ok(_response.events)
110    }
111}
112
113#[derive(Debug, Clone)]
114pub struct MouseSourceProxy {
115    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
116}
117
118impl fidl::endpoints::Proxy for MouseSourceProxy {
119    type Protocol = MouseSourceMarker;
120
121    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
122        Self::new(inner)
123    }
124
125    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
126        self.client.into_channel().map_err(|client| Self { client })
127    }
128
129    fn as_channel(&self) -> &::fidl::AsyncChannel {
130        self.client.as_channel()
131    }
132}
133
134impl MouseSourceProxy {
135    /// Create a new Proxy for fuchsia.ui.pointer/MouseSource.
136    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
137        let protocol_name = <MouseSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
138        Self { client: fidl::client::Client::new(channel, protocol_name) }
139    }
140
141    /// Get a Stream of events from the remote end of the protocol.
142    ///
143    /// # Panics
144    ///
145    /// Panics if the event stream was already taken.
146    pub fn take_event_stream(&self) -> MouseSourceEventStream {
147        MouseSourceEventStream { event_receiver: self.client.take_event_receiver() }
148    }
149
150    /// A method for a client to receive mouse pointer events.
151    ///
152    /// This call is formulated as a "hanging get" pattern: the client asks for
153    /// a set of recent events, and receives them via the callback. This
154    /// pull-based approach ensures that clients consume events at their own
155    /// pace; events don't clog up the channel in an unbounded manner.
156    ///
157    /// Flow control. The caller is allowed at most one in-flight |Watch| call
158    /// at a time; it is a logical error to have concurrent calls to |Watch|.
159    /// Non-compliance results in channel closure.
160    ///
161    /// Client pacing. The server will dispatch events to the caller on a FIFO,
162    /// lossless, best-effort basis, but the caller must allocate enough time to
163    /// keep up with new events.
164    ///
165    /// Event times. The timestamps on each event in the event vector are *not*
166    /// guaranteed monotonic; events from different devices may be injected into
167    /// Scenic at different times. Generally, events from a single device are
168    /// expected to have monotonically increasing timestamps.
169    ///
170    /// View parameters. Occasionally, changes in view or viewport require
171    /// notifying the client. If a |MouseEvent| carries |ViewParameters|, these
172    /// parameters apply to successive |MousePointerSample|s until the next
173    /// |ViewParameters|.
174    pub fn r#watch(
175        &self,
176    ) -> fidl::client::QueryResponseFut<
177        Vec<MouseEvent>,
178        fidl::encoding::DefaultFuchsiaResourceDialect,
179    > {
180        MouseSourceProxyInterface::r#watch(self)
181    }
182}
183
184impl MouseSourceProxyInterface for MouseSourceProxy {
185    type WatchResponseFut = fidl::client::QueryResponseFut<
186        Vec<MouseEvent>,
187        fidl::encoding::DefaultFuchsiaResourceDialect,
188    >;
189    fn r#watch(&self) -> Self::WatchResponseFut {
190        fn _decode(
191            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
192        ) -> Result<Vec<MouseEvent>, fidl::Error> {
193            let _response = fidl::client::decode_transaction_body::<
194                MouseSourceWatchResponse,
195                fidl::encoding::DefaultFuchsiaResourceDialect,
196                0x5b1f6e917ac1abb4,
197            >(_buf?)?;
198            Ok(_response.events)
199        }
200        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<MouseEvent>>(
201            (),
202            0x5b1f6e917ac1abb4,
203            fidl::encoding::DynamicFlags::empty(),
204            _decode,
205        )
206    }
207}
208
209pub struct MouseSourceEventStream {
210    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
211}
212
213impl std::marker::Unpin for MouseSourceEventStream {}
214
215impl futures::stream::FusedStream for MouseSourceEventStream {
216    fn is_terminated(&self) -> bool {
217        self.event_receiver.is_terminated()
218    }
219}
220
221impl futures::Stream for MouseSourceEventStream {
222    type Item = Result<MouseSourceEvent, fidl::Error>;
223
224    fn poll_next(
225        mut self: std::pin::Pin<&mut Self>,
226        cx: &mut std::task::Context<'_>,
227    ) -> std::task::Poll<Option<Self::Item>> {
228        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
229            &mut self.event_receiver,
230            cx
231        )?) {
232            Some(buf) => std::task::Poll::Ready(Some(MouseSourceEvent::decode(buf))),
233            None => std::task::Poll::Ready(None),
234        }
235    }
236}
237
238#[derive(Debug)]
239pub enum MouseSourceEvent {}
240
241impl MouseSourceEvent {
242    /// Decodes a message buffer as a [`MouseSourceEvent`].
243    fn decode(
244        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
245    ) -> Result<MouseSourceEvent, fidl::Error> {
246        let (bytes, _handles) = buf.split_mut();
247        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
248        debug_assert_eq!(tx_header.tx_id, 0);
249        match tx_header.ordinal {
250            _ => Err(fidl::Error::UnknownOrdinal {
251                ordinal: tx_header.ordinal,
252                protocol_name: <MouseSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
253            }),
254        }
255    }
256}
257
258/// A Stream of incoming requests for fuchsia.ui.pointer/MouseSource.
259pub struct MouseSourceRequestStream {
260    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
261    is_terminated: bool,
262}
263
264impl std::marker::Unpin for MouseSourceRequestStream {}
265
266impl futures::stream::FusedStream for MouseSourceRequestStream {
267    fn is_terminated(&self) -> bool {
268        self.is_terminated
269    }
270}
271
272impl fidl::endpoints::RequestStream for MouseSourceRequestStream {
273    type Protocol = MouseSourceMarker;
274    type ControlHandle = MouseSourceControlHandle;
275
276    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
277        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
278    }
279
280    fn control_handle(&self) -> Self::ControlHandle {
281        MouseSourceControlHandle { inner: self.inner.clone() }
282    }
283
284    fn into_inner(
285        self,
286    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
287    {
288        (self.inner, self.is_terminated)
289    }
290
291    fn from_inner(
292        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
293        is_terminated: bool,
294    ) -> Self {
295        Self { inner, is_terminated }
296    }
297}
298
299impl futures::Stream for MouseSourceRequestStream {
300    type Item = Result<MouseSourceRequest, fidl::Error>;
301
302    fn poll_next(
303        mut self: std::pin::Pin<&mut Self>,
304        cx: &mut std::task::Context<'_>,
305    ) -> std::task::Poll<Option<Self::Item>> {
306        let this = &mut *self;
307        if this.inner.check_shutdown(cx) {
308            this.is_terminated = true;
309            return std::task::Poll::Ready(None);
310        }
311        if this.is_terminated {
312            panic!("polled MouseSourceRequestStream after completion");
313        }
314        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
315            |bytes, handles| {
316                match this.inner.channel().read_etc(cx, bytes, handles) {
317                    std::task::Poll::Ready(Ok(())) => {}
318                    std::task::Poll::Pending => return std::task::Poll::Pending,
319                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
320                        this.is_terminated = true;
321                        return std::task::Poll::Ready(None);
322                    }
323                    std::task::Poll::Ready(Err(e)) => {
324                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
325                            e.into(),
326                        ))))
327                    }
328                }
329
330                // A message has been received from the channel
331                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
332
333                std::task::Poll::Ready(Some(match header.ordinal {
334                    0x5b1f6e917ac1abb4 => {
335                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
336                        let mut req = fidl::new_empty!(
337                            fidl::encoding::EmptyPayload,
338                            fidl::encoding::DefaultFuchsiaResourceDialect
339                        );
340                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
341                        let control_handle = MouseSourceControlHandle { inner: this.inner.clone() };
342                        Ok(MouseSourceRequest::Watch {
343                            responder: MouseSourceWatchResponder {
344                                control_handle: std::mem::ManuallyDrop::new(control_handle),
345                                tx_id: header.tx_id,
346                            },
347                        })
348                    }
349                    _ => Err(fidl::Error::UnknownOrdinal {
350                        ordinal: header.ordinal,
351                        protocol_name:
352                            <MouseSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
353                    }),
354                }))
355            },
356        )
357    }
358}
359
360/// A method for a client to receive mouse pointer events.
361///
362/// The position of a pointer event is defined in the context of a viewport,
363/// situated in the view. The dimensions of the view and viewport, and their
364/// spatial relationship (defined with a transform matrix), are supplied
365/// synchronously in a |ViewParameter| table. A view may retrieve a pointer's
366/// position in its local coordinate system by applying the viewport-to-view
367/// transform matrix.
368///
369/// The viewport is embedded in an independent and stable coordinate system,
370/// suitable for interpreting pointer events in a scale-independent manner;
371/// mouse movement will be observed at a constant scale, even under effects such
372/// as magnification or panning. However, other effects, such as enlargening the
373/// view's clip bounds, may trigger a change in the viewport extents.
374#[derive(Debug)]
375pub enum MouseSourceRequest {
376    /// A method for a client to receive mouse pointer events.
377    ///
378    /// This call is formulated as a "hanging get" pattern: the client asks for
379    /// a set of recent events, and receives them via the callback. This
380    /// pull-based approach ensures that clients consume events at their own
381    /// pace; events don't clog up the channel in an unbounded manner.
382    ///
383    /// Flow control. The caller is allowed at most one in-flight |Watch| call
384    /// at a time; it is a logical error to have concurrent calls to |Watch|.
385    /// Non-compliance results in channel closure.
386    ///
387    /// Client pacing. The server will dispatch events to the caller on a FIFO,
388    /// lossless, best-effort basis, but the caller must allocate enough time to
389    /// keep up with new events.
390    ///
391    /// Event times. The timestamps on each event in the event vector are *not*
392    /// guaranteed monotonic; events from different devices may be injected into
393    /// Scenic at different times. Generally, events from a single device are
394    /// expected to have monotonically increasing timestamps.
395    ///
396    /// View parameters. Occasionally, changes in view or viewport require
397    /// notifying the client. If a |MouseEvent| carries |ViewParameters|, these
398    /// parameters apply to successive |MousePointerSample|s until the next
399    /// |ViewParameters|.
400    Watch { responder: MouseSourceWatchResponder },
401}
402
403impl MouseSourceRequest {
404    #[allow(irrefutable_let_patterns)]
405    pub fn into_watch(self) -> Option<(MouseSourceWatchResponder)> {
406        if let MouseSourceRequest::Watch { responder } = self {
407            Some((responder))
408        } else {
409            None
410        }
411    }
412
413    /// Name of the method defined in FIDL
414    pub fn method_name(&self) -> &'static str {
415        match *self {
416            MouseSourceRequest::Watch { .. } => "watch",
417        }
418    }
419}
420
421#[derive(Debug, Clone)]
422pub struct MouseSourceControlHandle {
423    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
424}
425
426impl fidl::endpoints::ControlHandle for MouseSourceControlHandle {
427    fn shutdown(&self) {
428        self.inner.shutdown()
429    }
430    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
431        self.inner.shutdown_with_epitaph(status)
432    }
433
434    fn is_closed(&self) -> bool {
435        self.inner.channel().is_closed()
436    }
437    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
438        self.inner.channel().on_closed()
439    }
440
441    #[cfg(target_os = "fuchsia")]
442    fn signal_peer(
443        &self,
444        clear_mask: zx::Signals,
445        set_mask: zx::Signals,
446    ) -> Result<(), zx_status::Status> {
447        use fidl::Peered;
448        self.inner.channel().signal_peer(clear_mask, set_mask)
449    }
450}
451
452impl MouseSourceControlHandle {}
453
454#[must_use = "FIDL methods require a response to be sent"]
455#[derive(Debug)]
456pub struct MouseSourceWatchResponder {
457    control_handle: std::mem::ManuallyDrop<MouseSourceControlHandle>,
458    tx_id: u32,
459}
460
461/// Set the the channel to be shutdown (see [`MouseSourceControlHandle::shutdown`])
462/// if the responder is dropped without sending a response, so that the client
463/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
464impl std::ops::Drop for MouseSourceWatchResponder {
465    fn drop(&mut self) {
466        self.control_handle.shutdown();
467        // Safety: drops once, never accessed again
468        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
469    }
470}
471
472impl fidl::endpoints::Responder for MouseSourceWatchResponder {
473    type ControlHandle = MouseSourceControlHandle;
474
475    fn control_handle(&self) -> &MouseSourceControlHandle {
476        &self.control_handle
477    }
478
479    fn drop_without_shutdown(mut self) {
480        // Safety: drops once, never accessed again due to mem::forget
481        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
482        // Prevent Drop from running (which would shut down the channel)
483        std::mem::forget(self);
484    }
485}
486
487impl MouseSourceWatchResponder {
488    /// Sends a response to the FIDL transaction.
489    ///
490    /// Sets the channel to shutdown if an error occurs.
491    pub fn send(self, mut events: &[MouseEvent]) -> Result<(), fidl::Error> {
492        let _result = self.send_raw(events);
493        if _result.is_err() {
494            self.control_handle.shutdown();
495        }
496        self.drop_without_shutdown();
497        _result
498    }
499
500    /// Similar to "send" but does not shutdown the channel if an error occurs.
501    pub fn send_no_shutdown_on_err(self, mut events: &[MouseEvent]) -> Result<(), fidl::Error> {
502        let _result = self.send_raw(events);
503        self.drop_without_shutdown();
504        _result
505    }
506
507    fn send_raw(&self, mut events: &[MouseEvent]) -> Result<(), fidl::Error> {
508        self.control_handle.inner.send::<MouseSourceWatchResponse>(
509            (events,),
510            self.tx_id,
511            0x5b1f6e917ac1abb4,
512            fidl::encoding::DynamicFlags::empty(),
513        )
514    }
515}
516
517#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
518pub struct TouchSourceMarker;
519
520impl fidl::endpoints::ProtocolMarker for TouchSourceMarker {
521    type Proxy = TouchSourceProxy;
522    type RequestStream = TouchSourceRequestStream;
523    #[cfg(target_os = "fuchsia")]
524    type SynchronousProxy = TouchSourceSynchronousProxy;
525
526    const DEBUG_NAME: &'static str = "(anonymous) TouchSource";
527}
528
529pub trait TouchSourceProxyInterface: Send + Sync {
530    type WatchResponseFut: std::future::Future<Output = Result<Vec<TouchEvent>, fidl::Error>> + Send;
531    fn r#watch(&self, responses: &[TouchResponse]) -> Self::WatchResponseFut;
532    type UpdateResponseResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
533    fn r#update_response(
534        &self,
535        interaction: &TouchInteractionId,
536        response: &TouchResponse,
537    ) -> Self::UpdateResponseResponseFut;
538}
539#[derive(Debug)]
540#[cfg(target_os = "fuchsia")]
541pub struct TouchSourceSynchronousProxy {
542    client: fidl::client::sync::Client,
543}
544
545#[cfg(target_os = "fuchsia")]
546impl fidl::endpoints::SynchronousProxy for TouchSourceSynchronousProxy {
547    type Proxy = TouchSourceProxy;
548    type Protocol = TouchSourceMarker;
549
550    fn from_channel(inner: fidl::Channel) -> Self {
551        Self::new(inner)
552    }
553
554    fn into_channel(self) -> fidl::Channel {
555        self.client.into_channel()
556    }
557
558    fn as_channel(&self) -> &fidl::Channel {
559        self.client.as_channel()
560    }
561}
562
563#[cfg(target_os = "fuchsia")]
564impl TouchSourceSynchronousProxy {
565    pub fn new(channel: fidl::Channel) -> Self {
566        let protocol_name = <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
567        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
568    }
569
570    pub fn into_channel(self) -> fidl::Channel {
571        self.client.into_channel()
572    }
573
574    /// Waits until an event arrives and returns it. It is safe for other
575    /// threads to make concurrent requests while waiting for an event.
576    pub fn wait_for_event(
577        &self,
578        deadline: zx::MonotonicInstant,
579    ) -> Result<TouchSourceEvent, fidl::Error> {
580        TouchSourceEvent::decode(self.client.wait_for_event(deadline)?)
581    }
582
583    /// A method for a client to receive touch pointer events.
584    ///
585    /// This call is formulated as a "hanging get" pattern: the client asks for
586    /// a set of recent events, and receives them via the callback. This
587    /// pull-based approach ensures that clients consume events at their own
588    /// pace; events don't clog up the channel in an unbounded manner.
589    ///
590    /// Flow control. The caller is allowed at most one in-flight |Watch| call
591    /// at a time; it is a logical error to have concurrent calls to |Watch|.
592    /// Non-compliance results in channel closure.
593    ///
594    /// Client pacing. The server will dispatch events to the caller on a FIFO,
595    /// lossless, best-effort basis, but the caller must allocate enough time to
596    /// keep up with new events. An unresponsive client may be categorized as
597    /// "App Not Responding" and targeted for channel closure.
598    ///
599    /// Responses. The gesture disambiguation scheme relies on the server
600    /// receiving a |TouchResponse| for each |TouchEvent|.|TouchPointerSample|;
601    /// non-sample events should return an empty |TouchResponse| table to the
602    /// server. Responses for *previous* events are fed to the server on the
603    /// *next* call of |Watch| [1]. Each element in the |responses| vector is
604    /// interpreted as the pairwise response to the event in the previous
605    /// |events| vector; the vector lengths must match. Note that the client's
606    /// contract to respond to events starts as soon as it registers its
607    /// endpoint with scenic, NOT when it first calls `Watch()`.
608    ///
609    /// Initial response. The first call to |Watch| must be an empty vector.
610    ///
611    /// Event times. The timestamps on each event in the event vector are *not*
612    /// guaranteed monotonic; touch events from different devices may be
613    /// injected into Scenic at different times. Generally, events from a single
614    /// device are expected to have monotonically increasing timestamps.
615    ///
616    /// View parameters. Occasionally, changes in view or viewport require
617    /// notifying the client. If a |TouchEvent| carries |ViewParameters|, these
618    /// parameters apply to successive |TouchPointerSample|s until the next
619    /// |ViewParameters|.
620    ///
621    /// [1] The hanging get pattern enables straightforward API evolution, but
622    /// unfortunately does not admit an idiomatic matching of response to event.
623    pub fn r#watch(
624        &self,
625        mut responses: &[TouchResponse],
626        ___deadline: zx::MonotonicInstant,
627    ) -> Result<Vec<TouchEvent>, fidl::Error> {
628        let _response =
629            self.client.send_query::<TouchSourceWatchRequest, TouchSourceWatchResponse>(
630                (responses,),
631                0x38453127dd0fc7d,
632                fidl::encoding::DynamicFlags::empty(),
633                ___deadline,
634            )?;
635        Ok(_response.events)
636    }
637
638    /// The gesture protocol allows a client to enact a "hold" on an open
639    /// interaction of touch events; it prevents resolution of interaction
640    /// ownership, even after the interaction closes. This method updates the
641    /// client's previous "hold" by replacing it with a response that allows
642    /// ownership resolution to proceed.
643    ///
644    /// See |TouchInteractionId| for how a stream is structured into
645    /// interactions.
646    ///
647    /// Flow control. The caller is allowed at most one |UpdateResponse| call
648    /// per interaction, and it must be on a closed interaction. It is a logical
649    /// error to call |UpdateResponse| when a normal response is possible with
650    /// the |Watch| call.
651    ///
652    /// Validity. This TouchResponse must not be another "hold" response, and
653    /// the overwritten response is expected to be a "hold" response.
654    pub fn r#update_response(
655        &self,
656        mut interaction: &TouchInteractionId,
657        mut response: &TouchResponse,
658        ___deadline: zx::MonotonicInstant,
659    ) -> Result<(), fidl::Error> {
660        let _response = self
661            .client
662            .send_query::<TouchSourceUpdateResponseRequest, fidl::encoding::EmptyPayload>(
663                (interaction, response),
664                0x6c746a313b39898a,
665                fidl::encoding::DynamicFlags::empty(),
666                ___deadline,
667            )?;
668        Ok(_response)
669    }
670}
671
672#[derive(Debug, Clone)]
673pub struct TouchSourceProxy {
674    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
675}
676
677impl fidl::endpoints::Proxy for TouchSourceProxy {
678    type Protocol = TouchSourceMarker;
679
680    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
681        Self::new(inner)
682    }
683
684    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
685        self.client.into_channel().map_err(|client| Self { client })
686    }
687
688    fn as_channel(&self) -> &::fidl::AsyncChannel {
689        self.client.as_channel()
690    }
691}
692
693impl TouchSourceProxy {
694    /// Create a new Proxy for fuchsia.ui.pointer/TouchSource.
695    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
696        let protocol_name = <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
697        Self { client: fidl::client::Client::new(channel, protocol_name) }
698    }
699
700    /// Get a Stream of events from the remote end of the protocol.
701    ///
702    /// # Panics
703    ///
704    /// Panics if the event stream was already taken.
705    pub fn take_event_stream(&self) -> TouchSourceEventStream {
706        TouchSourceEventStream { event_receiver: self.client.take_event_receiver() }
707    }
708
709    /// A method for a client to receive touch pointer events.
710    ///
711    /// This call is formulated as a "hanging get" pattern: the client asks for
712    /// a set of recent events, and receives them via the callback. This
713    /// pull-based approach ensures that clients consume events at their own
714    /// pace; events don't clog up the channel in an unbounded manner.
715    ///
716    /// Flow control. The caller is allowed at most one in-flight |Watch| call
717    /// at a time; it is a logical error to have concurrent calls to |Watch|.
718    /// Non-compliance results in channel closure.
719    ///
720    /// Client pacing. The server will dispatch events to the caller on a FIFO,
721    /// lossless, best-effort basis, but the caller must allocate enough time to
722    /// keep up with new events. An unresponsive client may be categorized as
723    /// "App Not Responding" and targeted for channel closure.
724    ///
725    /// Responses. The gesture disambiguation scheme relies on the server
726    /// receiving a |TouchResponse| for each |TouchEvent|.|TouchPointerSample|;
727    /// non-sample events should return an empty |TouchResponse| table to the
728    /// server. Responses for *previous* events are fed to the server on the
729    /// *next* call of |Watch| [1]. Each element in the |responses| vector is
730    /// interpreted as the pairwise response to the event in the previous
731    /// |events| vector; the vector lengths must match. Note that the client's
732    /// contract to respond to events starts as soon as it registers its
733    /// endpoint with scenic, NOT when it first calls `Watch()`.
734    ///
735    /// Initial response. The first call to |Watch| must be an empty vector.
736    ///
737    /// Event times. The timestamps on each event in the event vector are *not*
738    /// guaranteed monotonic; touch events from different devices may be
739    /// injected into Scenic at different times. Generally, events from a single
740    /// device are expected to have monotonically increasing timestamps.
741    ///
742    /// View parameters. Occasionally, changes in view or viewport require
743    /// notifying the client. If a |TouchEvent| carries |ViewParameters|, these
744    /// parameters apply to successive |TouchPointerSample|s until the next
745    /// |ViewParameters|.
746    ///
747    /// [1] The hanging get pattern enables straightforward API evolution, but
748    /// unfortunately does not admit an idiomatic matching of response to event.
749    pub fn r#watch(
750        &self,
751        mut responses: &[TouchResponse],
752    ) -> fidl::client::QueryResponseFut<
753        Vec<TouchEvent>,
754        fidl::encoding::DefaultFuchsiaResourceDialect,
755    > {
756        TouchSourceProxyInterface::r#watch(self, responses)
757    }
758
759    /// The gesture protocol allows a client to enact a "hold" on an open
760    /// interaction of touch events; it prevents resolution of interaction
761    /// ownership, even after the interaction closes. This method updates the
762    /// client's previous "hold" by replacing it with a response that allows
763    /// ownership resolution to proceed.
764    ///
765    /// See |TouchInteractionId| for how a stream is structured into
766    /// interactions.
767    ///
768    /// Flow control. The caller is allowed at most one |UpdateResponse| call
769    /// per interaction, and it must be on a closed interaction. It is a logical
770    /// error to call |UpdateResponse| when a normal response is possible with
771    /// the |Watch| call.
772    ///
773    /// Validity. This TouchResponse must not be another "hold" response, and
774    /// the overwritten response is expected to be a "hold" response.
775    pub fn r#update_response(
776        &self,
777        mut interaction: &TouchInteractionId,
778        mut response: &TouchResponse,
779    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
780        TouchSourceProxyInterface::r#update_response(self, interaction, response)
781    }
782}
783
784impl TouchSourceProxyInterface for TouchSourceProxy {
785    type WatchResponseFut = fidl::client::QueryResponseFut<
786        Vec<TouchEvent>,
787        fidl::encoding::DefaultFuchsiaResourceDialect,
788    >;
789    fn r#watch(&self, mut responses: &[TouchResponse]) -> Self::WatchResponseFut {
790        fn _decode(
791            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
792        ) -> Result<Vec<TouchEvent>, fidl::Error> {
793            let _response = fidl::client::decode_transaction_body::<
794                TouchSourceWatchResponse,
795                fidl::encoding::DefaultFuchsiaResourceDialect,
796                0x38453127dd0fc7d,
797            >(_buf?)?;
798            Ok(_response.events)
799        }
800        self.client.send_query_and_decode::<TouchSourceWatchRequest, Vec<TouchEvent>>(
801            (responses,),
802            0x38453127dd0fc7d,
803            fidl::encoding::DynamicFlags::empty(),
804            _decode,
805        )
806    }
807
808    type UpdateResponseResponseFut =
809        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
810    fn r#update_response(
811        &self,
812        mut interaction: &TouchInteractionId,
813        mut response: &TouchResponse,
814    ) -> Self::UpdateResponseResponseFut {
815        fn _decode(
816            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
817        ) -> Result<(), fidl::Error> {
818            let _response = fidl::client::decode_transaction_body::<
819                fidl::encoding::EmptyPayload,
820                fidl::encoding::DefaultFuchsiaResourceDialect,
821                0x6c746a313b39898a,
822            >(_buf?)?;
823            Ok(_response)
824        }
825        self.client.send_query_and_decode::<TouchSourceUpdateResponseRequest, ()>(
826            (interaction, response),
827            0x6c746a313b39898a,
828            fidl::encoding::DynamicFlags::empty(),
829            _decode,
830        )
831    }
832}
833
834pub struct TouchSourceEventStream {
835    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
836}
837
838impl std::marker::Unpin for TouchSourceEventStream {}
839
840impl futures::stream::FusedStream for TouchSourceEventStream {
841    fn is_terminated(&self) -> bool {
842        self.event_receiver.is_terminated()
843    }
844}
845
846impl futures::Stream for TouchSourceEventStream {
847    type Item = Result<TouchSourceEvent, fidl::Error>;
848
849    fn poll_next(
850        mut self: std::pin::Pin<&mut Self>,
851        cx: &mut std::task::Context<'_>,
852    ) -> std::task::Poll<Option<Self::Item>> {
853        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
854            &mut self.event_receiver,
855            cx
856        )?) {
857            Some(buf) => std::task::Poll::Ready(Some(TouchSourceEvent::decode(buf))),
858            None => std::task::Poll::Ready(None),
859        }
860    }
861}
862
863#[derive(Debug)]
864pub enum TouchSourceEvent {}
865
866impl TouchSourceEvent {
867    /// Decodes a message buffer as a [`TouchSourceEvent`].
868    fn decode(
869        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
870    ) -> Result<TouchSourceEvent, fidl::Error> {
871        let (bytes, _handles) = buf.split_mut();
872        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
873        debug_assert_eq!(tx_header.tx_id, 0);
874        match tx_header.ordinal {
875            _ => Err(fidl::Error::UnknownOrdinal {
876                ordinal: tx_header.ordinal,
877                protocol_name: <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
878            }),
879        }
880    }
881}
882
883/// A Stream of incoming requests for fuchsia.ui.pointer/TouchSource.
884pub struct TouchSourceRequestStream {
885    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
886    is_terminated: bool,
887}
888
889impl std::marker::Unpin for TouchSourceRequestStream {}
890
891impl futures::stream::FusedStream for TouchSourceRequestStream {
892    fn is_terminated(&self) -> bool {
893        self.is_terminated
894    }
895}
896
897impl fidl::endpoints::RequestStream for TouchSourceRequestStream {
898    type Protocol = TouchSourceMarker;
899    type ControlHandle = TouchSourceControlHandle;
900
901    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
902        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
903    }
904
905    fn control_handle(&self) -> Self::ControlHandle {
906        TouchSourceControlHandle { inner: self.inner.clone() }
907    }
908
909    fn into_inner(
910        self,
911    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
912    {
913        (self.inner, self.is_terminated)
914    }
915
916    fn from_inner(
917        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
918        is_terminated: bool,
919    ) -> Self {
920        Self { inner, is_terminated }
921    }
922}
923
924impl futures::Stream for TouchSourceRequestStream {
925    type Item = Result<TouchSourceRequest, fidl::Error>;
926
927    fn poll_next(
928        mut self: std::pin::Pin<&mut Self>,
929        cx: &mut std::task::Context<'_>,
930    ) -> std::task::Poll<Option<Self::Item>> {
931        let this = &mut *self;
932        if this.inner.check_shutdown(cx) {
933            this.is_terminated = true;
934            return std::task::Poll::Ready(None);
935        }
936        if this.is_terminated {
937            panic!("polled TouchSourceRequestStream after completion");
938        }
939        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
940            |bytes, handles| {
941                match this.inner.channel().read_etc(cx, bytes, handles) {
942                    std::task::Poll::Ready(Ok(())) => {}
943                    std::task::Poll::Pending => return std::task::Poll::Pending,
944                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
945                        this.is_terminated = true;
946                        return std::task::Poll::Ready(None);
947                    }
948                    std::task::Poll::Ready(Err(e)) => {
949                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
950                            e.into(),
951                        ))))
952                    }
953                }
954
955                // A message has been received from the channel
956                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
957
958                std::task::Poll::Ready(Some(match header.ordinal {
959                    0x38453127dd0fc7d => {
960                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
961                        let mut req = fidl::new_empty!(
962                            TouchSourceWatchRequest,
963                            fidl::encoding::DefaultFuchsiaResourceDialect
964                        );
965                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TouchSourceWatchRequest>(&header, _body_bytes, handles, &mut req)?;
966                        let control_handle = TouchSourceControlHandle { inner: this.inner.clone() };
967                        Ok(TouchSourceRequest::Watch {
968                            responses: req.responses,
969
970                            responder: TouchSourceWatchResponder {
971                                control_handle: std::mem::ManuallyDrop::new(control_handle),
972                                tx_id: header.tx_id,
973                            },
974                        })
975                    }
976                    0x6c746a313b39898a => {
977                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
978                        let mut req = fidl::new_empty!(
979                            TouchSourceUpdateResponseRequest,
980                            fidl::encoding::DefaultFuchsiaResourceDialect
981                        );
982                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TouchSourceUpdateResponseRequest>(&header, _body_bytes, handles, &mut req)?;
983                        let control_handle = TouchSourceControlHandle { inner: this.inner.clone() };
984                        Ok(TouchSourceRequest::UpdateResponse {
985                            interaction: req.interaction,
986                            response: req.response,
987
988                            responder: TouchSourceUpdateResponseResponder {
989                                control_handle: std::mem::ManuallyDrop::new(control_handle),
990                                tx_id: header.tx_id,
991                            },
992                        })
993                    }
994                    _ => Err(fidl::Error::UnknownOrdinal {
995                        ordinal: header.ordinal,
996                        protocol_name:
997                            <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
998                    }),
999                }))
1000            },
1001        )
1002    }
1003}
1004
1005/// A method for a client to receive touch events and respond in a global
1006/// gesture disambiguation protocol.
1007///
1008/// The position of a touch event is defined in the context of a viewport,
1009/// situated in the view. The dimensions of the view and viewport, and their
1010/// spatial relationship (defined with a transform matrix), are supplied
1011/// synchronously in a |ViewParameter| table. A view may retrieve a pointer's
1012/// position in its local coordinate system by applying the viewport-to-view
1013/// transform matrix.
1014///
1015/// The viewport is embedded in an independent and stable coordinate system,
1016/// suitable for interpreting touch events in a scale-independent manner; a
1017/// swipe will be observed at a constant scale, even under effects such as
1018/// magnification or panning. However, other effects, such as enlargening the
1019/// view's clip bounds, may trigger a change in the viewport extents.
1020#[derive(Debug)]
1021pub enum TouchSourceRequest {
1022    /// A method for a client to receive touch pointer events.
1023    ///
1024    /// This call is formulated as a "hanging get" pattern: the client asks for
1025    /// a set of recent events, and receives them via the callback. This
1026    /// pull-based approach ensures that clients consume events at their own
1027    /// pace; events don't clog up the channel in an unbounded manner.
1028    ///
1029    /// Flow control. The caller is allowed at most one in-flight |Watch| call
1030    /// at a time; it is a logical error to have concurrent calls to |Watch|.
1031    /// Non-compliance results in channel closure.
1032    ///
1033    /// Client pacing. The server will dispatch events to the caller on a FIFO,
1034    /// lossless, best-effort basis, but the caller must allocate enough time to
1035    /// keep up with new events. An unresponsive client may be categorized as
1036    /// "App Not Responding" and targeted for channel closure.
1037    ///
1038    /// Responses. The gesture disambiguation scheme relies on the server
1039    /// receiving a |TouchResponse| for each |TouchEvent|.|TouchPointerSample|;
1040    /// non-sample events should return an empty |TouchResponse| table to the
1041    /// server. Responses for *previous* events are fed to the server on the
1042    /// *next* call of |Watch| [1]. Each element in the |responses| vector is
1043    /// interpreted as the pairwise response to the event in the previous
1044    /// |events| vector; the vector lengths must match. Note that the client's
1045    /// contract to respond to events starts as soon as it registers its
1046    /// endpoint with scenic, NOT when it first calls `Watch()`.
1047    ///
1048    /// Initial response. The first call to |Watch| must be an empty vector.
1049    ///
1050    /// Event times. The timestamps on each event in the event vector are *not*
1051    /// guaranteed monotonic; touch events from different devices may be
1052    /// injected into Scenic at different times. Generally, events from a single
1053    /// device are expected to have monotonically increasing timestamps.
1054    ///
1055    /// View parameters. Occasionally, changes in view or viewport require
1056    /// notifying the client. If a |TouchEvent| carries |ViewParameters|, these
1057    /// parameters apply to successive |TouchPointerSample|s until the next
1058    /// |ViewParameters|.
1059    ///
1060    /// [1] The hanging get pattern enables straightforward API evolution, but
1061    /// unfortunately does not admit an idiomatic matching of response to event.
1062    Watch { responses: Vec<TouchResponse>, responder: TouchSourceWatchResponder },
1063    /// The gesture protocol allows a client to enact a "hold" on an open
1064    /// interaction of touch events; it prevents resolution of interaction
1065    /// ownership, even after the interaction closes. This method updates the
1066    /// client's previous "hold" by replacing it with a response that allows
1067    /// ownership resolution to proceed.
1068    ///
1069    /// See |TouchInteractionId| for how a stream is structured into
1070    /// interactions.
1071    ///
1072    /// Flow control. The caller is allowed at most one |UpdateResponse| call
1073    /// per interaction, and it must be on a closed interaction. It is a logical
1074    /// error to call |UpdateResponse| when a normal response is possible with
1075    /// the |Watch| call.
1076    ///
1077    /// Validity. This TouchResponse must not be another "hold" response, and
1078    /// the overwritten response is expected to be a "hold" response.
1079    UpdateResponse {
1080        interaction: TouchInteractionId,
1081        response: TouchResponse,
1082        responder: TouchSourceUpdateResponseResponder,
1083    },
1084}
1085
1086impl TouchSourceRequest {
1087    #[allow(irrefutable_let_patterns)]
1088    pub fn into_watch(self) -> Option<(Vec<TouchResponse>, TouchSourceWatchResponder)> {
1089        if let TouchSourceRequest::Watch { responses, responder } = self {
1090            Some((responses, responder))
1091        } else {
1092            None
1093        }
1094    }
1095
1096    #[allow(irrefutable_let_patterns)]
1097    pub fn into_update_response(
1098        self,
1099    ) -> Option<(TouchInteractionId, TouchResponse, TouchSourceUpdateResponseResponder)> {
1100        if let TouchSourceRequest::UpdateResponse { interaction, response, responder } = self {
1101            Some((interaction, response, responder))
1102        } else {
1103            None
1104        }
1105    }
1106
1107    /// Name of the method defined in FIDL
1108    pub fn method_name(&self) -> &'static str {
1109        match *self {
1110            TouchSourceRequest::Watch { .. } => "watch",
1111            TouchSourceRequest::UpdateResponse { .. } => "update_response",
1112        }
1113    }
1114}
1115
1116#[derive(Debug, Clone)]
1117pub struct TouchSourceControlHandle {
1118    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1119}
1120
1121impl fidl::endpoints::ControlHandle for TouchSourceControlHandle {
1122    fn shutdown(&self) {
1123        self.inner.shutdown()
1124    }
1125    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1126        self.inner.shutdown_with_epitaph(status)
1127    }
1128
1129    fn is_closed(&self) -> bool {
1130        self.inner.channel().is_closed()
1131    }
1132    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1133        self.inner.channel().on_closed()
1134    }
1135
1136    #[cfg(target_os = "fuchsia")]
1137    fn signal_peer(
1138        &self,
1139        clear_mask: zx::Signals,
1140        set_mask: zx::Signals,
1141    ) -> Result<(), zx_status::Status> {
1142        use fidl::Peered;
1143        self.inner.channel().signal_peer(clear_mask, set_mask)
1144    }
1145}
1146
1147impl TouchSourceControlHandle {}
1148
1149#[must_use = "FIDL methods require a response to be sent"]
1150#[derive(Debug)]
1151pub struct TouchSourceWatchResponder {
1152    control_handle: std::mem::ManuallyDrop<TouchSourceControlHandle>,
1153    tx_id: u32,
1154}
1155
1156/// Set the the channel to be shutdown (see [`TouchSourceControlHandle::shutdown`])
1157/// if the responder is dropped without sending a response, so that the client
1158/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1159impl std::ops::Drop for TouchSourceWatchResponder {
1160    fn drop(&mut self) {
1161        self.control_handle.shutdown();
1162        // Safety: drops once, never accessed again
1163        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1164    }
1165}
1166
1167impl fidl::endpoints::Responder for TouchSourceWatchResponder {
1168    type ControlHandle = TouchSourceControlHandle;
1169
1170    fn control_handle(&self) -> &TouchSourceControlHandle {
1171        &self.control_handle
1172    }
1173
1174    fn drop_without_shutdown(mut self) {
1175        // Safety: drops once, never accessed again due to mem::forget
1176        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1177        // Prevent Drop from running (which would shut down the channel)
1178        std::mem::forget(self);
1179    }
1180}
1181
1182impl TouchSourceWatchResponder {
1183    /// Sends a response to the FIDL transaction.
1184    ///
1185    /// Sets the channel to shutdown if an error occurs.
1186    pub fn send(self, mut events: &[TouchEvent]) -> Result<(), fidl::Error> {
1187        let _result = self.send_raw(events);
1188        if _result.is_err() {
1189            self.control_handle.shutdown();
1190        }
1191        self.drop_without_shutdown();
1192        _result
1193    }
1194
1195    /// Similar to "send" but does not shutdown the channel if an error occurs.
1196    pub fn send_no_shutdown_on_err(self, mut events: &[TouchEvent]) -> Result<(), fidl::Error> {
1197        let _result = self.send_raw(events);
1198        self.drop_without_shutdown();
1199        _result
1200    }
1201
1202    fn send_raw(&self, mut events: &[TouchEvent]) -> Result<(), fidl::Error> {
1203        self.control_handle.inner.send::<TouchSourceWatchResponse>(
1204            (events,),
1205            self.tx_id,
1206            0x38453127dd0fc7d,
1207            fidl::encoding::DynamicFlags::empty(),
1208        )
1209    }
1210}
1211
1212#[must_use = "FIDL methods require a response to be sent"]
1213#[derive(Debug)]
1214pub struct TouchSourceUpdateResponseResponder {
1215    control_handle: std::mem::ManuallyDrop<TouchSourceControlHandle>,
1216    tx_id: u32,
1217}
1218
1219/// Set the the channel to be shutdown (see [`TouchSourceControlHandle::shutdown`])
1220/// if the responder is dropped without sending a response, so that the client
1221/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1222impl std::ops::Drop for TouchSourceUpdateResponseResponder {
1223    fn drop(&mut self) {
1224        self.control_handle.shutdown();
1225        // Safety: drops once, never accessed again
1226        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1227    }
1228}
1229
1230impl fidl::endpoints::Responder for TouchSourceUpdateResponseResponder {
1231    type ControlHandle = TouchSourceControlHandle;
1232
1233    fn control_handle(&self) -> &TouchSourceControlHandle {
1234        &self.control_handle
1235    }
1236
1237    fn drop_without_shutdown(mut self) {
1238        // Safety: drops once, never accessed again due to mem::forget
1239        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1240        // Prevent Drop from running (which would shut down the channel)
1241        std::mem::forget(self);
1242    }
1243}
1244
1245impl TouchSourceUpdateResponseResponder {
1246    /// Sends a response to the FIDL transaction.
1247    ///
1248    /// Sets the channel to shutdown if an error occurs.
1249    pub fn send(self) -> Result<(), fidl::Error> {
1250        let _result = self.send_raw();
1251        if _result.is_err() {
1252            self.control_handle.shutdown();
1253        }
1254        self.drop_without_shutdown();
1255        _result
1256    }
1257
1258    /// Similar to "send" but does not shutdown the channel if an error occurs.
1259    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1260        let _result = self.send_raw();
1261        self.drop_without_shutdown();
1262        _result
1263    }
1264
1265    fn send_raw(&self) -> Result<(), fidl::Error> {
1266        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1267            (),
1268            self.tx_id,
1269            0x6c746a313b39898a,
1270            fidl::encoding::DynamicFlags::empty(),
1271        )
1272    }
1273}
1274
1275mod internal {
1276    use super::*;
1277}