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