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#[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 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 pub fn take_event_stream(&self) -> MouseSourceEventStream {
170 MouseSourceEventStream { event_receiver: self.client.take_event_receiver() }
171 }
172
173 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 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
281pub 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 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#[derive(Debug)]
398pub enum MouseSourceRequest {
399 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 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
484impl std::ops::Drop for MouseSourceWatchResponder {
488 fn drop(&mut self) {
489 self.control_handle.shutdown();
490 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 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
505 std::mem::forget(self);
507 }
508}
509
510impl MouseSourceWatchResponder {
511 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 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 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 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 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 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 pub fn take_event_stream(&self) -> TouchSourceEventStream {
752 TouchSourceEventStream { event_receiver: self.client.take_event_receiver() }
753 }
754
755 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 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 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
929pub 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 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#[derive(Debug)]
1067pub enum TouchSourceRequest {
1068 Watch { responses: Vec<TouchResponse>, responder: TouchSourceWatchResponder },
1109 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 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
1202impl std::ops::Drop for TouchSourceWatchResponder {
1206 fn drop(&mut self) {
1207 self.control_handle.shutdown();
1208 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 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1223 std::mem::forget(self);
1225 }
1226}
1227
1228impl TouchSourceWatchResponder {
1229 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 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
1265impl std::ops::Drop for TouchSourceUpdateResponseResponder {
1269 fn drop(&mut self) {
1270 self.control_handle.shutdown();
1271 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 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1286 std::mem::forget(self);
1288 }
1289}
1290
1291impl TouchSourceUpdateResponseResponder {
1292 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 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}