1#![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 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 pub fn r#watch(
99 &self,
100 ___deadline: zx::MonotonicInstant,
101 ) -> Result<Vec<MouseEvent>, fidl::Error> {
102 let _response =
103 self.client.send_query::<fidl::encoding::EmptyPayload, MouseSourceWatchResponse>(
104 (),
105 0x5b1f6e917ac1abb4,
106 fidl::encoding::DynamicFlags::empty(),
107 ___deadline,
108 )?;
109 Ok(_response.events)
110 }
111}
112
113#[derive(Debug, Clone)]
114pub struct MouseSourceProxy {
115 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
116}
117
118impl fidl::endpoints::Proxy for MouseSourceProxy {
119 type Protocol = MouseSourceMarker;
120
121 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
122 Self::new(inner)
123 }
124
125 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
126 self.client.into_channel().map_err(|client| Self { client })
127 }
128
129 fn as_channel(&self) -> &::fidl::AsyncChannel {
130 self.client.as_channel()
131 }
132}
133
134impl MouseSourceProxy {
135 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
137 let protocol_name = <MouseSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
138 Self { client: fidl::client::Client::new(channel, protocol_name) }
139 }
140
141 pub fn take_event_stream(&self) -> MouseSourceEventStream {
147 MouseSourceEventStream { event_receiver: self.client.take_event_receiver() }
148 }
149
150 pub fn r#watch(
175 &self,
176 ) -> fidl::client::QueryResponseFut<
177 Vec<MouseEvent>,
178 fidl::encoding::DefaultFuchsiaResourceDialect,
179 > {
180 MouseSourceProxyInterface::r#watch(self)
181 }
182}
183
184impl MouseSourceProxyInterface for MouseSourceProxy {
185 type WatchResponseFut = fidl::client::QueryResponseFut<
186 Vec<MouseEvent>,
187 fidl::encoding::DefaultFuchsiaResourceDialect,
188 >;
189 fn r#watch(&self) -> Self::WatchResponseFut {
190 fn _decode(
191 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
192 ) -> Result<Vec<MouseEvent>, fidl::Error> {
193 let _response = fidl::client::decode_transaction_body::<
194 MouseSourceWatchResponse,
195 fidl::encoding::DefaultFuchsiaResourceDialect,
196 0x5b1f6e917ac1abb4,
197 >(_buf?)?;
198 Ok(_response.events)
199 }
200 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<MouseEvent>>(
201 (),
202 0x5b1f6e917ac1abb4,
203 fidl::encoding::DynamicFlags::empty(),
204 _decode,
205 )
206 }
207}
208
209pub struct MouseSourceEventStream {
210 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
211}
212
213impl std::marker::Unpin for MouseSourceEventStream {}
214
215impl futures::stream::FusedStream for MouseSourceEventStream {
216 fn is_terminated(&self) -> bool {
217 self.event_receiver.is_terminated()
218 }
219}
220
221impl futures::Stream for MouseSourceEventStream {
222 type Item = Result<MouseSourceEvent, fidl::Error>;
223
224 fn poll_next(
225 mut self: std::pin::Pin<&mut Self>,
226 cx: &mut std::task::Context<'_>,
227 ) -> std::task::Poll<Option<Self::Item>> {
228 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
229 &mut self.event_receiver,
230 cx
231 )?) {
232 Some(buf) => std::task::Poll::Ready(Some(MouseSourceEvent::decode(buf))),
233 None => std::task::Poll::Ready(None),
234 }
235 }
236}
237
238#[derive(Debug)]
239pub enum MouseSourceEvent {}
240
241impl MouseSourceEvent {
242 fn decode(
244 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
245 ) -> Result<MouseSourceEvent, fidl::Error> {
246 let (bytes, _handles) = buf.split_mut();
247 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
248 debug_assert_eq!(tx_header.tx_id, 0);
249 match tx_header.ordinal {
250 _ => Err(fidl::Error::UnknownOrdinal {
251 ordinal: tx_header.ordinal,
252 protocol_name: <MouseSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
253 }),
254 }
255 }
256}
257
258pub struct MouseSourceRequestStream {
260 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
261 is_terminated: bool,
262}
263
264impl std::marker::Unpin for MouseSourceRequestStream {}
265
266impl futures::stream::FusedStream for MouseSourceRequestStream {
267 fn is_terminated(&self) -> bool {
268 self.is_terminated
269 }
270}
271
272impl fidl::endpoints::RequestStream for MouseSourceRequestStream {
273 type Protocol = MouseSourceMarker;
274 type ControlHandle = MouseSourceControlHandle;
275
276 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
277 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
278 }
279
280 fn control_handle(&self) -> Self::ControlHandle {
281 MouseSourceControlHandle { inner: self.inner.clone() }
282 }
283
284 fn into_inner(
285 self,
286 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
287 {
288 (self.inner, self.is_terminated)
289 }
290
291 fn from_inner(
292 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
293 is_terminated: bool,
294 ) -> Self {
295 Self { inner, is_terminated }
296 }
297}
298
299impl futures::Stream for MouseSourceRequestStream {
300 type Item = Result<MouseSourceRequest, fidl::Error>;
301
302 fn poll_next(
303 mut self: std::pin::Pin<&mut Self>,
304 cx: &mut std::task::Context<'_>,
305 ) -> std::task::Poll<Option<Self::Item>> {
306 let this = &mut *self;
307 if this.inner.check_shutdown(cx) {
308 this.is_terminated = true;
309 return std::task::Poll::Ready(None);
310 }
311 if this.is_terminated {
312 panic!("polled MouseSourceRequestStream after completion");
313 }
314 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
315 |bytes, handles| {
316 match this.inner.channel().read_etc(cx, bytes, handles) {
317 std::task::Poll::Ready(Ok(())) => {}
318 std::task::Poll::Pending => return std::task::Poll::Pending,
319 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
320 this.is_terminated = true;
321 return std::task::Poll::Ready(None);
322 }
323 std::task::Poll::Ready(Err(e)) => {
324 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
325 e.into(),
326 ))))
327 }
328 }
329
330 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
332
333 std::task::Poll::Ready(Some(match header.ordinal {
334 0x5b1f6e917ac1abb4 => {
335 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
336 let mut req = fidl::new_empty!(
337 fidl::encoding::EmptyPayload,
338 fidl::encoding::DefaultFuchsiaResourceDialect
339 );
340 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
341 let control_handle = MouseSourceControlHandle { inner: this.inner.clone() };
342 Ok(MouseSourceRequest::Watch {
343 responder: MouseSourceWatchResponder {
344 control_handle: std::mem::ManuallyDrop::new(control_handle),
345 tx_id: header.tx_id,
346 },
347 })
348 }
349 _ => Err(fidl::Error::UnknownOrdinal {
350 ordinal: header.ordinal,
351 protocol_name:
352 <MouseSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
353 }),
354 }))
355 },
356 )
357 }
358}
359
360#[derive(Debug)]
375pub enum MouseSourceRequest {
376 Watch { responder: MouseSourceWatchResponder },
401}
402
403impl MouseSourceRequest {
404 #[allow(irrefutable_let_patterns)]
405 pub fn into_watch(self) -> Option<(MouseSourceWatchResponder)> {
406 if let MouseSourceRequest::Watch { responder } = self {
407 Some((responder))
408 } else {
409 None
410 }
411 }
412
413 pub fn method_name(&self) -> &'static str {
415 match *self {
416 MouseSourceRequest::Watch { .. } => "watch",
417 }
418 }
419}
420
421#[derive(Debug, Clone)]
422pub struct MouseSourceControlHandle {
423 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
424}
425
426impl fidl::endpoints::ControlHandle for MouseSourceControlHandle {
427 fn shutdown(&self) {
428 self.inner.shutdown()
429 }
430 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
431 self.inner.shutdown_with_epitaph(status)
432 }
433
434 fn is_closed(&self) -> bool {
435 self.inner.channel().is_closed()
436 }
437 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
438 self.inner.channel().on_closed()
439 }
440
441 #[cfg(target_os = "fuchsia")]
442 fn signal_peer(
443 &self,
444 clear_mask: zx::Signals,
445 set_mask: zx::Signals,
446 ) -> Result<(), zx_status::Status> {
447 use fidl::Peered;
448 self.inner.channel().signal_peer(clear_mask, set_mask)
449 }
450}
451
452impl MouseSourceControlHandle {}
453
454#[must_use = "FIDL methods require a response to be sent"]
455#[derive(Debug)]
456pub struct MouseSourceWatchResponder {
457 control_handle: std::mem::ManuallyDrop<MouseSourceControlHandle>,
458 tx_id: u32,
459}
460
461impl std::ops::Drop for MouseSourceWatchResponder {
465 fn drop(&mut self) {
466 self.control_handle.shutdown();
467 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
469 }
470}
471
472impl fidl::endpoints::Responder for MouseSourceWatchResponder {
473 type ControlHandle = MouseSourceControlHandle;
474
475 fn control_handle(&self) -> &MouseSourceControlHandle {
476 &self.control_handle
477 }
478
479 fn drop_without_shutdown(mut self) {
480 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
482 std::mem::forget(self);
484 }
485}
486
487impl MouseSourceWatchResponder {
488 pub fn send(self, mut events: &[MouseEvent]) -> Result<(), fidl::Error> {
492 let _result = self.send_raw(events);
493 if _result.is_err() {
494 self.control_handle.shutdown();
495 }
496 self.drop_without_shutdown();
497 _result
498 }
499
500 pub fn send_no_shutdown_on_err(self, mut events: &[MouseEvent]) -> Result<(), fidl::Error> {
502 let _result = self.send_raw(events);
503 self.drop_without_shutdown();
504 _result
505 }
506
507 fn send_raw(&self, mut events: &[MouseEvent]) -> Result<(), fidl::Error> {
508 self.control_handle.inner.send::<MouseSourceWatchResponse>(
509 (events,),
510 self.tx_id,
511 0x5b1f6e917ac1abb4,
512 fidl::encoding::DynamicFlags::empty(),
513 )
514 }
515}
516
517#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
518pub struct TouchSourceMarker;
519
520impl fidl::endpoints::ProtocolMarker for TouchSourceMarker {
521 type Proxy = TouchSourceProxy;
522 type RequestStream = TouchSourceRequestStream;
523 #[cfg(target_os = "fuchsia")]
524 type SynchronousProxy = TouchSourceSynchronousProxy;
525
526 const DEBUG_NAME: &'static str = "(anonymous) TouchSource";
527}
528
529pub trait TouchSourceProxyInterface: Send + Sync {
530 type WatchResponseFut: std::future::Future<Output = Result<Vec<TouchEvent>, fidl::Error>> + Send;
531 fn r#watch(&self, responses: &[TouchResponse]) -> Self::WatchResponseFut;
532 type UpdateResponseResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
533 fn r#update_response(
534 &self,
535 interaction: &TouchInteractionId,
536 response: &TouchResponse,
537 ) -> Self::UpdateResponseResponseFut;
538}
539#[derive(Debug)]
540#[cfg(target_os = "fuchsia")]
541pub struct TouchSourceSynchronousProxy {
542 client: fidl::client::sync::Client,
543}
544
545#[cfg(target_os = "fuchsia")]
546impl fidl::endpoints::SynchronousProxy for TouchSourceSynchronousProxy {
547 type Proxy = TouchSourceProxy;
548 type Protocol = TouchSourceMarker;
549
550 fn from_channel(inner: fidl::Channel) -> Self {
551 Self::new(inner)
552 }
553
554 fn into_channel(self) -> fidl::Channel {
555 self.client.into_channel()
556 }
557
558 fn as_channel(&self) -> &fidl::Channel {
559 self.client.as_channel()
560 }
561}
562
563#[cfg(target_os = "fuchsia")]
564impl TouchSourceSynchronousProxy {
565 pub fn new(channel: fidl::Channel) -> Self {
566 let protocol_name = <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
567 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
568 }
569
570 pub fn into_channel(self) -> fidl::Channel {
571 self.client.into_channel()
572 }
573
574 pub fn wait_for_event(
577 &self,
578 deadline: zx::MonotonicInstant,
579 ) -> Result<TouchSourceEvent, fidl::Error> {
580 TouchSourceEvent::decode(self.client.wait_for_event(deadline)?)
581 }
582
583 pub fn r#watch(
624 &self,
625 mut responses: &[TouchResponse],
626 ___deadline: zx::MonotonicInstant,
627 ) -> Result<Vec<TouchEvent>, fidl::Error> {
628 let _response =
629 self.client.send_query::<TouchSourceWatchRequest, TouchSourceWatchResponse>(
630 (responses,),
631 0x38453127dd0fc7d,
632 fidl::encoding::DynamicFlags::empty(),
633 ___deadline,
634 )?;
635 Ok(_response.events)
636 }
637
638 pub fn r#update_response(
655 &self,
656 mut interaction: &TouchInteractionId,
657 mut response: &TouchResponse,
658 ___deadline: zx::MonotonicInstant,
659 ) -> Result<(), fidl::Error> {
660 let _response = self
661 .client
662 .send_query::<TouchSourceUpdateResponseRequest, fidl::encoding::EmptyPayload>(
663 (interaction, response),
664 0x6c746a313b39898a,
665 fidl::encoding::DynamicFlags::empty(),
666 ___deadline,
667 )?;
668 Ok(_response)
669 }
670}
671
672#[derive(Debug, Clone)]
673pub struct TouchSourceProxy {
674 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
675}
676
677impl fidl::endpoints::Proxy for TouchSourceProxy {
678 type Protocol = TouchSourceMarker;
679
680 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
681 Self::new(inner)
682 }
683
684 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
685 self.client.into_channel().map_err(|client| Self { client })
686 }
687
688 fn as_channel(&self) -> &::fidl::AsyncChannel {
689 self.client.as_channel()
690 }
691}
692
693impl TouchSourceProxy {
694 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
696 let protocol_name = <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
697 Self { client: fidl::client::Client::new(channel, protocol_name) }
698 }
699
700 pub fn take_event_stream(&self) -> TouchSourceEventStream {
706 TouchSourceEventStream { event_receiver: self.client.take_event_receiver() }
707 }
708
709 pub fn r#watch(
750 &self,
751 mut responses: &[TouchResponse],
752 ) -> fidl::client::QueryResponseFut<
753 Vec<TouchEvent>,
754 fidl::encoding::DefaultFuchsiaResourceDialect,
755 > {
756 TouchSourceProxyInterface::r#watch(self, responses)
757 }
758
759 pub fn r#update_response(
776 &self,
777 mut interaction: &TouchInteractionId,
778 mut response: &TouchResponse,
779 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
780 TouchSourceProxyInterface::r#update_response(self, interaction, response)
781 }
782}
783
784impl TouchSourceProxyInterface for TouchSourceProxy {
785 type WatchResponseFut = fidl::client::QueryResponseFut<
786 Vec<TouchEvent>,
787 fidl::encoding::DefaultFuchsiaResourceDialect,
788 >;
789 fn r#watch(&self, mut responses: &[TouchResponse]) -> Self::WatchResponseFut {
790 fn _decode(
791 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
792 ) -> Result<Vec<TouchEvent>, fidl::Error> {
793 let _response = fidl::client::decode_transaction_body::<
794 TouchSourceWatchResponse,
795 fidl::encoding::DefaultFuchsiaResourceDialect,
796 0x38453127dd0fc7d,
797 >(_buf?)?;
798 Ok(_response.events)
799 }
800 self.client.send_query_and_decode::<TouchSourceWatchRequest, Vec<TouchEvent>>(
801 (responses,),
802 0x38453127dd0fc7d,
803 fidl::encoding::DynamicFlags::empty(),
804 _decode,
805 )
806 }
807
808 type UpdateResponseResponseFut =
809 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
810 fn r#update_response(
811 &self,
812 mut interaction: &TouchInteractionId,
813 mut response: &TouchResponse,
814 ) -> Self::UpdateResponseResponseFut {
815 fn _decode(
816 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
817 ) -> Result<(), fidl::Error> {
818 let _response = fidl::client::decode_transaction_body::<
819 fidl::encoding::EmptyPayload,
820 fidl::encoding::DefaultFuchsiaResourceDialect,
821 0x6c746a313b39898a,
822 >(_buf?)?;
823 Ok(_response)
824 }
825 self.client.send_query_and_decode::<TouchSourceUpdateResponseRequest, ()>(
826 (interaction, response),
827 0x6c746a313b39898a,
828 fidl::encoding::DynamicFlags::empty(),
829 _decode,
830 )
831 }
832}
833
834pub struct TouchSourceEventStream {
835 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
836}
837
838impl std::marker::Unpin for TouchSourceEventStream {}
839
840impl futures::stream::FusedStream for TouchSourceEventStream {
841 fn is_terminated(&self) -> bool {
842 self.event_receiver.is_terminated()
843 }
844}
845
846impl futures::Stream for TouchSourceEventStream {
847 type Item = Result<TouchSourceEvent, fidl::Error>;
848
849 fn poll_next(
850 mut self: std::pin::Pin<&mut Self>,
851 cx: &mut std::task::Context<'_>,
852 ) -> std::task::Poll<Option<Self::Item>> {
853 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
854 &mut self.event_receiver,
855 cx
856 )?) {
857 Some(buf) => std::task::Poll::Ready(Some(TouchSourceEvent::decode(buf))),
858 None => std::task::Poll::Ready(None),
859 }
860 }
861}
862
863#[derive(Debug)]
864pub enum TouchSourceEvent {}
865
866impl TouchSourceEvent {
867 fn decode(
869 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
870 ) -> Result<TouchSourceEvent, fidl::Error> {
871 let (bytes, _handles) = buf.split_mut();
872 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
873 debug_assert_eq!(tx_header.tx_id, 0);
874 match tx_header.ordinal {
875 _ => Err(fidl::Error::UnknownOrdinal {
876 ordinal: tx_header.ordinal,
877 protocol_name: <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
878 }),
879 }
880 }
881}
882
883pub struct TouchSourceRequestStream {
885 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
886 is_terminated: bool,
887}
888
889impl std::marker::Unpin for TouchSourceRequestStream {}
890
891impl futures::stream::FusedStream for TouchSourceRequestStream {
892 fn is_terminated(&self) -> bool {
893 self.is_terminated
894 }
895}
896
897impl fidl::endpoints::RequestStream for TouchSourceRequestStream {
898 type Protocol = TouchSourceMarker;
899 type ControlHandle = TouchSourceControlHandle;
900
901 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
902 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
903 }
904
905 fn control_handle(&self) -> Self::ControlHandle {
906 TouchSourceControlHandle { inner: self.inner.clone() }
907 }
908
909 fn into_inner(
910 self,
911 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
912 {
913 (self.inner, self.is_terminated)
914 }
915
916 fn from_inner(
917 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
918 is_terminated: bool,
919 ) -> Self {
920 Self { inner, is_terminated }
921 }
922}
923
924impl futures::Stream for TouchSourceRequestStream {
925 type Item = Result<TouchSourceRequest, fidl::Error>;
926
927 fn poll_next(
928 mut self: std::pin::Pin<&mut Self>,
929 cx: &mut std::task::Context<'_>,
930 ) -> std::task::Poll<Option<Self::Item>> {
931 let this = &mut *self;
932 if this.inner.check_shutdown(cx) {
933 this.is_terminated = true;
934 return std::task::Poll::Ready(None);
935 }
936 if this.is_terminated {
937 panic!("polled TouchSourceRequestStream after completion");
938 }
939 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
940 |bytes, handles| {
941 match this.inner.channel().read_etc(cx, bytes, handles) {
942 std::task::Poll::Ready(Ok(())) => {}
943 std::task::Poll::Pending => return std::task::Poll::Pending,
944 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
945 this.is_terminated = true;
946 return std::task::Poll::Ready(None);
947 }
948 std::task::Poll::Ready(Err(e)) => {
949 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
950 e.into(),
951 ))))
952 }
953 }
954
955 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
957
958 std::task::Poll::Ready(Some(match header.ordinal {
959 0x38453127dd0fc7d => {
960 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
961 let mut req = fidl::new_empty!(
962 TouchSourceWatchRequest,
963 fidl::encoding::DefaultFuchsiaResourceDialect
964 );
965 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TouchSourceWatchRequest>(&header, _body_bytes, handles, &mut req)?;
966 let control_handle = TouchSourceControlHandle { inner: this.inner.clone() };
967 Ok(TouchSourceRequest::Watch {
968 responses: req.responses,
969
970 responder: TouchSourceWatchResponder {
971 control_handle: std::mem::ManuallyDrop::new(control_handle),
972 tx_id: header.tx_id,
973 },
974 })
975 }
976 0x6c746a313b39898a => {
977 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
978 let mut req = fidl::new_empty!(
979 TouchSourceUpdateResponseRequest,
980 fidl::encoding::DefaultFuchsiaResourceDialect
981 );
982 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TouchSourceUpdateResponseRequest>(&header, _body_bytes, handles, &mut req)?;
983 let control_handle = TouchSourceControlHandle { inner: this.inner.clone() };
984 Ok(TouchSourceRequest::UpdateResponse {
985 interaction: req.interaction,
986 response: req.response,
987
988 responder: TouchSourceUpdateResponseResponder {
989 control_handle: std::mem::ManuallyDrop::new(control_handle),
990 tx_id: header.tx_id,
991 },
992 })
993 }
994 _ => Err(fidl::Error::UnknownOrdinal {
995 ordinal: header.ordinal,
996 protocol_name:
997 <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
998 }),
999 }))
1000 },
1001 )
1002 }
1003}
1004
1005#[derive(Debug)]
1021pub enum TouchSourceRequest {
1022 Watch { responses: Vec<TouchResponse>, responder: TouchSourceWatchResponder },
1063 UpdateResponse {
1080 interaction: TouchInteractionId,
1081 response: TouchResponse,
1082 responder: TouchSourceUpdateResponseResponder,
1083 },
1084}
1085
1086impl TouchSourceRequest {
1087 #[allow(irrefutable_let_patterns)]
1088 pub fn into_watch(self) -> Option<(Vec<TouchResponse>, TouchSourceWatchResponder)> {
1089 if let TouchSourceRequest::Watch { responses, responder } = self {
1090 Some((responses, responder))
1091 } else {
1092 None
1093 }
1094 }
1095
1096 #[allow(irrefutable_let_patterns)]
1097 pub fn into_update_response(
1098 self,
1099 ) -> Option<(TouchInteractionId, TouchResponse, TouchSourceUpdateResponseResponder)> {
1100 if let TouchSourceRequest::UpdateResponse { interaction, response, responder } = self {
1101 Some((interaction, response, responder))
1102 } else {
1103 None
1104 }
1105 }
1106
1107 pub fn method_name(&self) -> &'static str {
1109 match *self {
1110 TouchSourceRequest::Watch { .. } => "watch",
1111 TouchSourceRequest::UpdateResponse { .. } => "update_response",
1112 }
1113 }
1114}
1115
1116#[derive(Debug, Clone)]
1117pub struct TouchSourceControlHandle {
1118 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1119}
1120
1121impl fidl::endpoints::ControlHandle for TouchSourceControlHandle {
1122 fn shutdown(&self) {
1123 self.inner.shutdown()
1124 }
1125 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1126 self.inner.shutdown_with_epitaph(status)
1127 }
1128
1129 fn is_closed(&self) -> bool {
1130 self.inner.channel().is_closed()
1131 }
1132 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1133 self.inner.channel().on_closed()
1134 }
1135
1136 #[cfg(target_os = "fuchsia")]
1137 fn signal_peer(
1138 &self,
1139 clear_mask: zx::Signals,
1140 set_mask: zx::Signals,
1141 ) -> Result<(), zx_status::Status> {
1142 use fidl::Peered;
1143 self.inner.channel().signal_peer(clear_mask, set_mask)
1144 }
1145}
1146
1147impl TouchSourceControlHandle {}
1148
1149#[must_use = "FIDL methods require a response to be sent"]
1150#[derive(Debug)]
1151pub struct TouchSourceWatchResponder {
1152 control_handle: std::mem::ManuallyDrop<TouchSourceControlHandle>,
1153 tx_id: u32,
1154}
1155
1156impl std::ops::Drop for TouchSourceWatchResponder {
1160 fn drop(&mut self) {
1161 self.control_handle.shutdown();
1162 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1164 }
1165}
1166
1167impl fidl::endpoints::Responder for TouchSourceWatchResponder {
1168 type ControlHandle = TouchSourceControlHandle;
1169
1170 fn control_handle(&self) -> &TouchSourceControlHandle {
1171 &self.control_handle
1172 }
1173
1174 fn drop_without_shutdown(mut self) {
1175 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1177 std::mem::forget(self);
1179 }
1180}
1181
1182impl TouchSourceWatchResponder {
1183 pub fn send(self, mut events: &[TouchEvent]) -> Result<(), fidl::Error> {
1187 let _result = self.send_raw(events);
1188 if _result.is_err() {
1189 self.control_handle.shutdown();
1190 }
1191 self.drop_without_shutdown();
1192 _result
1193 }
1194
1195 pub fn send_no_shutdown_on_err(self, mut events: &[TouchEvent]) -> Result<(), fidl::Error> {
1197 let _result = self.send_raw(events);
1198 self.drop_without_shutdown();
1199 _result
1200 }
1201
1202 fn send_raw(&self, mut events: &[TouchEvent]) -> Result<(), fidl::Error> {
1203 self.control_handle.inner.send::<TouchSourceWatchResponse>(
1204 (events,),
1205 self.tx_id,
1206 0x38453127dd0fc7d,
1207 fidl::encoding::DynamicFlags::empty(),
1208 )
1209 }
1210}
1211
1212#[must_use = "FIDL methods require a response to be sent"]
1213#[derive(Debug)]
1214pub struct TouchSourceUpdateResponseResponder {
1215 control_handle: std::mem::ManuallyDrop<TouchSourceControlHandle>,
1216 tx_id: u32,
1217}
1218
1219impl std::ops::Drop for TouchSourceUpdateResponseResponder {
1223 fn drop(&mut self) {
1224 self.control_handle.shutdown();
1225 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1227 }
1228}
1229
1230impl fidl::endpoints::Responder for TouchSourceUpdateResponseResponder {
1231 type ControlHandle = TouchSourceControlHandle;
1232
1233 fn control_handle(&self) -> &TouchSourceControlHandle {
1234 &self.control_handle
1235 }
1236
1237 fn drop_without_shutdown(mut self) {
1238 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1240 std::mem::forget(self);
1242 }
1243}
1244
1245impl TouchSourceUpdateResponseResponder {
1246 pub fn send(self) -> Result<(), fidl::Error> {
1250 let _result = self.send_raw();
1251 if _result.is_err() {
1252 self.control_handle.shutdown();
1253 }
1254 self.drop_without_shutdown();
1255 _result
1256 }
1257
1258 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1260 let _result = self.send_raw();
1261 self.drop_without_shutdown();
1262 _result
1263 }
1264
1265 fn send_raw(&self) -> Result<(), fidl::Error> {
1266 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1267 (),
1268 self.tx_id,
1269 0x6c746a313b39898a,
1270 fidl::encoding::DynamicFlags::empty(),
1271 )
1272 }
1273}
1274
1275mod internal {
1276 use super::*;
1277}