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