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 { Some((responder)) } else { None }
430 }
431
432 pub fn method_name(&self) -> &'static str {
434 match *self {
435 MouseSourceRequest::Watch { .. } => "watch",
436 }
437 }
438}
439
440#[derive(Debug, Clone)]
441pub struct MouseSourceControlHandle {
442 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
443}
444
445impl fidl::endpoints::ControlHandle for MouseSourceControlHandle {
446 fn shutdown(&self) {
447 self.inner.shutdown()
448 }
449 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
450 self.inner.shutdown_with_epitaph(status)
451 }
452
453 fn is_closed(&self) -> bool {
454 self.inner.channel().is_closed()
455 }
456 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
457 self.inner.channel().on_closed()
458 }
459
460 #[cfg(target_os = "fuchsia")]
461 fn signal_peer(
462 &self,
463 clear_mask: zx::Signals,
464 set_mask: zx::Signals,
465 ) -> Result<(), zx_status::Status> {
466 use fidl::Peered;
467 self.inner.channel().signal_peer(clear_mask, set_mask)
468 }
469}
470
471impl MouseSourceControlHandle {}
472
473#[must_use = "FIDL methods require a response to be sent"]
474#[derive(Debug)]
475pub struct MouseSourceWatchResponder {
476 control_handle: std::mem::ManuallyDrop<MouseSourceControlHandle>,
477 tx_id: u32,
478}
479
480impl std::ops::Drop for MouseSourceWatchResponder {
484 fn drop(&mut self) {
485 self.control_handle.shutdown();
486 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
488 }
489}
490
491impl fidl::endpoints::Responder for MouseSourceWatchResponder {
492 type ControlHandle = MouseSourceControlHandle;
493
494 fn control_handle(&self) -> &MouseSourceControlHandle {
495 &self.control_handle
496 }
497
498 fn drop_without_shutdown(mut self) {
499 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
501 std::mem::forget(self);
503 }
504}
505
506impl MouseSourceWatchResponder {
507 pub fn send(self, mut events: &[MouseEvent]) -> Result<(), fidl::Error> {
511 let _result = self.send_raw(events);
512 if _result.is_err() {
513 self.control_handle.shutdown();
514 }
515 self.drop_without_shutdown();
516 _result
517 }
518
519 pub fn send_no_shutdown_on_err(self, mut events: &[MouseEvent]) -> Result<(), fidl::Error> {
521 let _result = self.send_raw(events);
522 self.drop_without_shutdown();
523 _result
524 }
525
526 fn send_raw(&self, mut events: &[MouseEvent]) -> Result<(), fidl::Error> {
527 self.control_handle.inner.send::<MouseSourceWatchResponse>(
528 (events,),
529 self.tx_id,
530 0x5b1f6e917ac1abb4,
531 fidl::encoding::DynamicFlags::empty(),
532 )
533 }
534}
535
536#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
537pub struct TouchSourceMarker;
538
539impl fidl::endpoints::ProtocolMarker for TouchSourceMarker {
540 type Proxy = TouchSourceProxy;
541 type RequestStream = TouchSourceRequestStream;
542 #[cfg(target_os = "fuchsia")]
543 type SynchronousProxy = TouchSourceSynchronousProxy;
544
545 const DEBUG_NAME: &'static str = "(anonymous) TouchSource";
546}
547
548pub trait TouchSourceProxyInterface: Send + Sync {
549 type WatchResponseFut: std::future::Future<Output = Result<Vec<TouchEvent>, fidl::Error>> + Send;
550 fn r#watch(&self, responses: &[TouchResponse]) -> Self::WatchResponseFut;
551 type UpdateResponseResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
552 fn r#update_response(
553 &self,
554 interaction: &TouchInteractionId,
555 response: &TouchResponse,
556 ) -> Self::UpdateResponseResponseFut;
557}
558#[derive(Debug)]
559#[cfg(target_os = "fuchsia")]
560pub struct TouchSourceSynchronousProxy {
561 client: fidl::client::sync::Client,
562}
563
564#[cfg(target_os = "fuchsia")]
565impl fidl::endpoints::SynchronousProxy for TouchSourceSynchronousProxy {
566 type Proxy = TouchSourceProxy;
567 type Protocol = TouchSourceMarker;
568
569 fn from_channel(inner: fidl::Channel) -> Self {
570 Self::new(inner)
571 }
572
573 fn into_channel(self) -> fidl::Channel {
574 self.client.into_channel()
575 }
576
577 fn as_channel(&self) -> &fidl::Channel {
578 self.client.as_channel()
579 }
580}
581
582#[cfg(target_os = "fuchsia")]
583impl TouchSourceSynchronousProxy {
584 pub fn new(channel: fidl::Channel) -> Self {
585 let protocol_name = <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
586 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
587 }
588
589 pub fn into_channel(self) -> fidl::Channel {
590 self.client.into_channel()
591 }
592
593 pub fn wait_for_event(
596 &self,
597 deadline: zx::MonotonicInstant,
598 ) -> Result<TouchSourceEvent, fidl::Error> {
599 TouchSourceEvent::decode(self.client.wait_for_event(deadline)?)
600 }
601
602 pub fn r#watch(
643 &self,
644 mut responses: &[TouchResponse],
645 ___deadline: zx::MonotonicInstant,
646 ) -> Result<Vec<TouchEvent>, fidl::Error> {
647 let _response =
648 self.client.send_query::<TouchSourceWatchRequest, TouchSourceWatchResponse>(
649 (responses,),
650 0x38453127dd0fc7d,
651 fidl::encoding::DynamicFlags::empty(),
652 ___deadline,
653 )?;
654 Ok(_response.events)
655 }
656
657 pub fn r#update_response(
674 &self,
675 mut interaction: &TouchInteractionId,
676 mut response: &TouchResponse,
677 ___deadline: zx::MonotonicInstant,
678 ) -> Result<(), fidl::Error> {
679 let _response = self
680 .client
681 .send_query::<TouchSourceUpdateResponseRequest, fidl::encoding::EmptyPayload>(
682 (interaction, response),
683 0x6c746a313b39898a,
684 fidl::encoding::DynamicFlags::empty(),
685 ___deadline,
686 )?;
687 Ok(_response)
688 }
689}
690
691#[cfg(target_os = "fuchsia")]
692impl From<TouchSourceSynchronousProxy> for zx::Handle {
693 fn from(value: TouchSourceSynchronousProxy) -> Self {
694 value.into_channel().into()
695 }
696}
697
698#[cfg(target_os = "fuchsia")]
699impl From<fidl::Channel> for TouchSourceSynchronousProxy {
700 fn from(value: fidl::Channel) -> Self {
701 Self::new(value)
702 }
703}
704
705#[cfg(target_os = "fuchsia")]
706impl fidl::endpoints::FromClient for TouchSourceSynchronousProxy {
707 type Protocol = TouchSourceMarker;
708
709 fn from_client(value: fidl::endpoints::ClientEnd<TouchSourceMarker>) -> Self {
710 Self::new(value.into_channel())
711 }
712}
713
714#[derive(Debug, Clone)]
715pub struct TouchSourceProxy {
716 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
717}
718
719impl fidl::endpoints::Proxy for TouchSourceProxy {
720 type Protocol = TouchSourceMarker;
721
722 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
723 Self::new(inner)
724 }
725
726 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
727 self.client.into_channel().map_err(|client| Self { client })
728 }
729
730 fn as_channel(&self) -> &::fidl::AsyncChannel {
731 self.client.as_channel()
732 }
733}
734
735impl TouchSourceProxy {
736 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
738 let protocol_name = <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
739 Self { client: fidl::client::Client::new(channel, protocol_name) }
740 }
741
742 pub fn take_event_stream(&self) -> TouchSourceEventStream {
748 TouchSourceEventStream { event_receiver: self.client.take_event_receiver() }
749 }
750
751 pub fn r#watch(
792 &self,
793 mut responses: &[TouchResponse],
794 ) -> fidl::client::QueryResponseFut<
795 Vec<TouchEvent>,
796 fidl::encoding::DefaultFuchsiaResourceDialect,
797 > {
798 TouchSourceProxyInterface::r#watch(self, responses)
799 }
800
801 pub fn r#update_response(
818 &self,
819 mut interaction: &TouchInteractionId,
820 mut response: &TouchResponse,
821 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
822 TouchSourceProxyInterface::r#update_response(self, interaction, response)
823 }
824}
825
826impl TouchSourceProxyInterface for TouchSourceProxy {
827 type WatchResponseFut = fidl::client::QueryResponseFut<
828 Vec<TouchEvent>,
829 fidl::encoding::DefaultFuchsiaResourceDialect,
830 >;
831 fn r#watch(&self, mut responses: &[TouchResponse]) -> Self::WatchResponseFut {
832 fn _decode(
833 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
834 ) -> Result<Vec<TouchEvent>, fidl::Error> {
835 let _response = fidl::client::decode_transaction_body::<
836 TouchSourceWatchResponse,
837 fidl::encoding::DefaultFuchsiaResourceDialect,
838 0x38453127dd0fc7d,
839 >(_buf?)?;
840 Ok(_response.events)
841 }
842 self.client.send_query_and_decode::<TouchSourceWatchRequest, Vec<TouchEvent>>(
843 (responses,),
844 0x38453127dd0fc7d,
845 fidl::encoding::DynamicFlags::empty(),
846 _decode,
847 )
848 }
849
850 type UpdateResponseResponseFut =
851 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
852 fn r#update_response(
853 &self,
854 mut interaction: &TouchInteractionId,
855 mut response: &TouchResponse,
856 ) -> Self::UpdateResponseResponseFut {
857 fn _decode(
858 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
859 ) -> Result<(), fidl::Error> {
860 let _response = fidl::client::decode_transaction_body::<
861 fidl::encoding::EmptyPayload,
862 fidl::encoding::DefaultFuchsiaResourceDialect,
863 0x6c746a313b39898a,
864 >(_buf?)?;
865 Ok(_response)
866 }
867 self.client.send_query_and_decode::<TouchSourceUpdateResponseRequest, ()>(
868 (interaction, response),
869 0x6c746a313b39898a,
870 fidl::encoding::DynamicFlags::empty(),
871 _decode,
872 )
873 }
874}
875
876pub struct TouchSourceEventStream {
877 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
878}
879
880impl std::marker::Unpin for TouchSourceEventStream {}
881
882impl futures::stream::FusedStream for TouchSourceEventStream {
883 fn is_terminated(&self) -> bool {
884 self.event_receiver.is_terminated()
885 }
886}
887
888impl futures::Stream for TouchSourceEventStream {
889 type Item = Result<TouchSourceEvent, fidl::Error>;
890
891 fn poll_next(
892 mut self: std::pin::Pin<&mut Self>,
893 cx: &mut std::task::Context<'_>,
894 ) -> std::task::Poll<Option<Self::Item>> {
895 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
896 &mut self.event_receiver,
897 cx
898 )?) {
899 Some(buf) => std::task::Poll::Ready(Some(TouchSourceEvent::decode(buf))),
900 None => std::task::Poll::Ready(None),
901 }
902 }
903}
904
905#[derive(Debug)]
906pub enum TouchSourceEvent {}
907
908impl TouchSourceEvent {
909 fn decode(
911 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
912 ) -> Result<TouchSourceEvent, fidl::Error> {
913 let (bytes, _handles) = buf.split_mut();
914 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
915 debug_assert_eq!(tx_header.tx_id, 0);
916 match tx_header.ordinal {
917 _ => Err(fidl::Error::UnknownOrdinal {
918 ordinal: tx_header.ordinal,
919 protocol_name: <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
920 }),
921 }
922 }
923}
924
925pub struct TouchSourceRequestStream {
927 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
928 is_terminated: bool,
929}
930
931impl std::marker::Unpin for TouchSourceRequestStream {}
932
933impl futures::stream::FusedStream for TouchSourceRequestStream {
934 fn is_terminated(&self) -> bool {
935 self.is_terminated
936 }
937}
938
939impl fidl::endpoints::RequestStream for TouchSourceRequestStream {
940 type Protocol = TouchSourceMarker;
941 type ControlHandle = TouchSourceControlHandle;
942
943 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
944 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
945 }
946
947 fn control_handle(&self) -> Self::ControlHandle {
948 TouchSourceControlHandle { inner: self.inner.clone() }
949 }
950
951 fn into_inner(
952 self,
953 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
954 {
955 (self.inner, self.is_terminated)
956 }
957
958 fn from_inner(
959 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
960 is_terminated: bool,
961 ) -> Self {
962 Self { inner, is_terminated }
963 }
964}
965
966impl futures::Stream for TouchSourceRequestStream {
967 type Item = Result<TouchSourceRequest, fidl::Error>;
968
969 fn poll_next(
970 mut self: std::pin::Pin<&mut Self>,
971 cx: &mut std::task::Context<'_>,
972 ) -> std::task::Poll<Option<Self::Item>> {
973 let this = &mut *self;
974 if this.inner.check_shutdown(cx) {
975 this.is_terminated = true;
976 return std::task::Poll::Ready(None);
977 }
978 if this.is_terminated {
979 panic!("polled TouchSourceRequestStream after completion");
980 }
981 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
982 |bytes, handles| {
983 match this.inner.channel().read_etc(cx, bytes, handles) {
984 std::task::Poll::Ready(Ok(())) => {}
985 std::task::Poll::Pending => return std::task::Poll::Pending,
986 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
987 this.is_terminated = true;
988 return std::task::Poll::Ready(None);
989 }
990 std::task::Poll::Ready(Err(e)) => {
991 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
992 e.into(),
993 ))));
994 }
995 }
996
997 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
999
1000 std::task::Poll::Ready(Some(match header.ordinal {
1001 0x38453127dd0fc7d => {
1002 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1003 let mut req = fidl::new_empty!(
1004 TouchSourceWatchRequest,
1005 fidl::encoding::DefaultFuchsiaResourceDialect
1006 );
1007 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TouchSourceWatchRequest>(&header, _body_bytes, handles, &mut req)?;
1008 let control_handle = TouchSourceControlHandle { inner: this.inner.clone() };
1009 Ok(TouchSourceRequest::Watch {
1010 responses: req.responses,
1011
1012 responder: TouchSourceWatchResponder {
1013 control_handle: std::mem::ManuallyDrop::new(control_handle),
1014 tx_id: header.tx_id,
1015 },
1016 })
1017 }
1018 0x6c746a313b39898a => {
1019 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1020 let mut req = fidl::new_empty!(
1021 TouchSourceUpdateResponseRequest,
1022 fidl::encoding::DefaultFuchsiaResourceDialect
1023 );
1024 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TouchSourceUpdateResponseRequest>(&header, _body_bytes, handles, &mut req)?;
1025 let control_handle = TouchSourceControlHandle { inner: this.inner.clone() };
1026 Ok(TouchSourceRequest::UpdateResponse {
1027 interaction: req.interaction,
1028 response: req.response,
1029
1030 responder: TouchSourceUpdateResponseResponder {
1031 control_handle: std::mem::ManuallyDrop::new(control_handle),
1032 tx_id: header.tx_id,
1033 },
1034 })
1035 }
1036 _ => Err(fidl::Error::UnknownOrdinal {
1037 ordinal: header.ordinal,
1038 protocol_name:
1039 <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1040 }),
1041 }))
1042 },
1043 )
1044 }
1045}
1046
1047#[derive(Debug)]
1063pub enum TouchSourceRequest {
1064 Watch { responses: Vec<TouchResponse>, responder: TouchSourceWatchResponder },
1105 UpdateResponse {
1122 interaction: TouchInteractionId,
1123 response: TouchResponse,
1124 responder: TouchSourceUpdateResponseResponder,
1125 },
1126}
1127
1128impl TouchSourceRequest {
1129 #[allow(irrefutable_let_patterns)]
1130 pub fn into_watch(self) -> Option<(Vec<TouchResponse>, TouchSourceWatchResponder)> {
1131 if let TouchSourceRequest::Watch { responses, responder } = self {
1132 Some((responses, responder))
1133 } else {
1134 None
1135 }
1136 }
1137
1138 #[allow(irrefutable_let_patterns)]
1139 pub fn into_update_response(
1140 self,
1141 ) -> Option<(TouchInteractionId, TouchResponse, TouchSourceUpdateResponseResponder)> {
1142 if let TouchSourceRequest::UpdateResponse { interaction, response, responder } = self {
1143 Some((interaction, response, responder))
1144 } else {
1145 None
1146 }
1147 }
1148
1149 pub fn method_name(&self) -> &'static str {
1151 match *self {
1152 TouchSourceRequest::Watch { .. } => "watch",
1153 TouchSourceRequest::UpdateResponse { .. } => "update_response",
1154 }
1155 }
1156}
1157
1158#[derive(Debug, Clone)]
1159pub struct TouchSourceControlHandle {
1160 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1161}
1162
1163impl fidl::endpoints::ControlHandle for TouchSourceControlHandle {
1164 fn shutdown(&self) {
1165 self.inner.shutdown()
1166 }
1167 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1168 self.inner.shutdown_with_epitaph(status)
1169 }
1170
1171 fn is_closed(&self) -> bool {
1172 self.inner.channel().is_closed()
1173 }
1174 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1175 self.inner.channel().on_closed()
1176 }
1177
1178 #[cfg(target_os = "fuchsia")]
1179 fn signal_peer(
1180 &self,
1181 clear_mask: zx::Signals,
1182 set_mask: zx::Signals,
1183 ) -> Result<(), zx_status::Status> {
1184 use fidl::Peered;
1185 self.inner.channel().signal_peer(clear_mask, set_mask)
1186 }
1187}
1188
1189impl TouchSourceControlHandle {}
1190
1191#[must_use = "FIDL methods require a response to be sent"]
1192#[derive(Debug)]
1193pub struct TouchSourceWatchResponder {
1194 control_handle: std::mem::ManuallyDrop<TouchSourceControlHandle>,
1195 tx_id: u32,
1196}
1197
1198impl std::ops::Drop for TouchSourceWatchResponder {
1202 fn drop(&mut self) {
1203 self.control_handle.shutdown();
1204 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1206 }
1207}
1208
1209impl fidl::endpoints::Responder for TouchSourceWatchResponder {
1210 type ControlHandle = TouchSourceControlHandle;
1211
1212 fn control_handle(&self) -> &TouchSourceControlHandle {
1213 &self.control_handle
1214 }
1215
1216 fn drop_without_shutdown(mut self) {
1217 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1219 std::mem::forget(self);
1221 }
1222}
1223
1224impl TouchSourceWatchResponder {
1225 pub fn send(self, mut events: &[TouchEvent]) -> Result<(), fidl::Error> {
1229 let _result = self.send_raw(events);
1230 if _result.is_err() {
1231 self.control_handle.shutdown();
1232 }
1233 self.drop_without_shutdown();
1234 _result
1235 }
1236
1237 pub fn send_no_shutdown_on_err(self, mut events: &[TouchEvent]) -> Result<(), fidl::Error> {
1239 let _result = self.send_raw(events);
1240 self.drop_without_shutdown();
1241 _result
1242 }
1243
1244 fn send_raw(&self, mut events: &[TouchEvent]) -> Result<(), fidl::Error> {
1245 self.control_handle.inner.send::<TouchSourceWatchResponse>(
1246 (events,),
1247 self.tx_id,
1248 0x38453127dd0fc7d,
1249 fidl::encoding::DynamicFlags::empty(),
1250 )
1251 }
1252}
1253
1254#[must_use = "FIDL methods require a response to be sent"]
1255#[derive(Debug)]
1256pub struct TouchSourceUpdateResponseResponder {
1257 control_handle: std::mem::ManuallyDrop<TouchSourceControlHandle>,
1258 tx_id: u32,
1259}
1260
1261impl std::ops::Drop for TouchSourceUpdateResponseResponder {
1265 fn drop(&mut self) {
1266 self.control_handle.shutdown();
1267 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1269 }
1270}
1271
1272impl fidl::endpoints::Responder for TouchSourceUpdateResponseResponder {
1273 type ControlHandle = TouchSourceControlHandle;
1274
1275 fn control_handle(&self) -> &TouchSourceControlHandle {
1276 &self.control_handle
1277 }
1278
1279 fn drop_without_shutdown(mut self) {
1280 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1282 std::mem::forget(self);
1284 }
1285}
1286
1287impl TouchSourceUpdateResponseResponder {
1288 pub fn send(self) -> Result<(), fidl::Error> {
1292 let _result = self.send_raw();
1293 if _result.is_err() {
1294 self.control_handle.shutdown();
1295 }
1296 self.drop_without_shutdown();
1297 _result
1298 }
1299
1300 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1302 let _result = self.send_raw();
1303 self.drop_without_shutdown();
1304 _result
1305 }
1306
1307 fn send_raw(&self) -> Result<(), fidl::Error> {
1308 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1309 (),
1310 self.tx_id,
1311 0x6c746a313b39898a,
1312 fidl::encoding::DynamicFlags::empty(),
1313 )
1314 }
1315}
1316
1317mod internal {
1318 use super::*;
1319}