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_input3__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct KeyboardAddListenerRequest {
16 pub view_ref: fidl_fuchsia_ui_views::ViewRef,
17 pub listener: fidl::endpoints::ClientEnd<KeyboardListenerMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21 for KeyboardAddListenerRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct KeyEventInjectorMarker;
27
28impl fidl::endpoints::ProtocolMarker for KeyEventInjectorMarker {
29 type Proxy = KeyEventInjectorProxy;
30 type RequestStream = KeyEventInjectorRequestStream;
31 #[cfg(target_os = "fuchsia")]
32 type SynchronousProxy = KeyEventInjectorSynchronousProxy;
33
34 const DEBUG_NAME: &'static str = "fuchsia.ui.input3.KeyEventInjector";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for KeyEventInjectorMarker {}
37
38pub trait KeyEventInjectorProxyInterface: Send + Sync {
39 type InjectResponseFut: std::future::Future<Output = Result<KeyEventStatus, fidl::Error>> + Send;
40 fn r#inject(&self, key_event: &KeyEvent) -> Self::InjectResponseFut;
41}
42#[derive(Debug)]
43#[cfg(target_os = "fuchsia")]
44pub struct KeyEventInjectorSynchronousProxy {
45 client: fidl::client::sync::Client,
46}
47
48#[cfg(target_os = "fuchsia")]
49impl fidl::endpoints::SynchronousProxy for KeyEventInjectorSynchronousProxy {
50 type Proxy = KeyEventInjectorProxy;
51 type Protocol = KeyEventInjectorMarker;
52
53 fn from_channel(inner: fidl::Channel) -> Self {
54 Self::new(inner)
55 }
56
57 fn into_channel(self) -> fidl::Channel {
58 self.client.into_channel()
59 }
60
61 fn as_channel(&self) -> &fidl::Channel {
62 self.client.as_channel()
63 }
64}
65
66#[cfg(target_os = "fuchsia")]
67impl KeyEventInjectorSynchronousProxy {
68 pub fn new(channel: fidl::Channel) -> Self {
69 let protocol_name = <KeyEventInjectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
70 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
71 }
72
73 pub fn into_channel(self) -> fidl::Channel {
74 self.client.into_channel()
75 }
76
77 pub fn wait_for_event(
80 &self,
81 deadline: zx::MonotonicInstant,
82 ) -> Result<KeyEventInjectorEvent, fidl::Error> {
83 KeyEventInjectorEvent::decode(self.client.wait_for_event(deadline)?)
84 }
85
86 pub fn r#inject(
94 &self,
95 mut key_event: &KeyEvent,
96 ___deadline: zx::MonotonicInstant,
97 ) -> Result<KeyEventStatus, fidl::Error> {
98 let _response = self
99 .client
100 .send_query::<KeyEventInjectorInjectRequest, KeyEventInjectorInjectResponse>(
101 (key_event,),
102 0x1eb2c0d795c68949,
103 fidl::encoding::DynamicFlags::empty(),
104 ___deadline,
105 )?;
106 Ok(_response.status)
107 }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl From<KeyEventInjectorSynchronousProxy> for zx::Handle {
112 fn from(value: KeyEventInjectorSynchronousProxy) -> Self {
113 value.into_channel().into()
114 }
115}
116
117#[cfg(target_os = "fuchsia")]
118impl From<fidl::Channel> for KeyEventInjectorSynchronousProxy {
119 fn from(value: fidl::Channel) -> Self {
120 Self::new(value)
121 }
122}
123
124#[cfg(target_os = "fuchsia")]
125impl fidl::endpoints::FromClient for KeyEventInjectorSynchronousProxy {
126 type Protocol = KeyEventInjectorMarker;
127
128 fn from_client(value: fidl::endpoints::ClientEnd<KeyEventInjectorMarker>) -> Self {
129 Self::new(value.into_channel())
130 }
131}
132
133#[derive(Debug, Clone)]
134pub struct KeyEventInjectorProxy {
135 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
136}
137
138impl fidl::endpoints::Proxy for KeyEventInjectorProxy {
139 type Protocol = KeyEventInjectorMarker;
140
141 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
142 Self::new(inner)
143 }
144
145 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
146 self.client.into_channel().map_err(|client| Self { client })
147 }
148
149 fn as_channel(&self) -> &::fidl::AsyncChannel {
150 self.client.as_channel()
151 }
152}
153
154impl KeyEventInjectorProxy {
155 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
157 let protocol_name = <KeyEventInjectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
158 Self { client: fidl::client::Client::new(channel, protocol_name) }
159 }
160
161 pub fn take_event_stream(&self) -> KeyEventInjectorEventStream {
167 KeyEventInjectorEventStream { event_receiver: self.client.take_event_receiver() }
168 }
169
170 pub fn r#inject(
178 &self,
179 mut key_event: &KeyEvent,
180 ) -> fidl::client::QueryResponseFut<KeyEventStatus, fidl::encoding::DefaultFuchsiaResourceDialect>
181 {
182 KeyEventInjectorProxyInterface::r#inject(self, key_event)
183 }
184}
185
186impl KeyEventInjectorProxyInterface for KeyEventInjectorProxy {
187 type InjectResponseFut = fidl::client::QueryResponseFut<
188 KeyEventStatus,
189 fidl::encoding::DefaultFuchsiaResourceDialect,
190 >;
191 fn r#inject(&self, mut key_event: &KeyEvent) -> Self::InjectResponseFut {
192 fn _decode(
193 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
194 ) -> Result<KeyEventStatus, fidl::Error> {
195 let _response = fidl::client::decode_transaction_body::<
196 KeyEventInjectorInjectResponse,
197 fidl::encoding::DefaultFuchsiaResourceDialect,
198 0x1eb2c0d795c68949,
199 >(_buf?)?;
200 Ok(_response.status)
201 }
202 self.client.send_query_and_decode::<KeyEventInjectorInjectRequest, KeyEventStatus>(
203 (key_event,),
204 0x1eb2c0d795c68949,
205 fidl::encoding::DynamicFlags::empty(),
206 _decode,
207 )
208 }
209}
210
211pub struct KeyEventInjectorEventStream {
212 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
213}
214
215impl std::marker::Unpin for KeyEventInjectorEventStream {}
216
217impl futures::stream::FusedStream for KeyEventInjectorEventStream {
218 fn is_terminated(&self) -> bool {
219 self.event_receiver.is_terminated()
220 }
221}
222
223impl futures::Stream for KeyEventInjectorEventStream {
224 type Item = Result<KeyEventInjectorEvent, fidl::Error>;
225
226 fn poll_next(
227 mut self: std::pin::Pin<&mut Self>,
228 cx: &mut std::task::Context<'_>,
229 ) -> std::task::Poll<Option<Self::Item>> {
230 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
231 &mut self.event_receiver,
232 cx
233 )?) {
234 Some(buf) => std::task::Poll::Ready(Some(KeyEventInjectorEvent::decode(buf))),
235 None => std::task::Poll::Ready(None),
236 }
237 }
238}
239
240#[derive(Debug)]
241pub enum KeyEventInjectorEvent {}
242
243impl KeyEventInjectorEvent {
244 fn decode(
246 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
247 ) -> Result<KeyEventInjectorEvent, fidl::Error> {
248 let (bytes, _handles) = buf.split_mut();
249 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
250 debug_assert_eq!(tx_header.tx_id, 0);
251 match tx_header.ordinal {
252 _ => Err(fidl::Error::UnknownOrdinal {
253 ordinal: tx_header.ordinal,
254 protocol_name:
255 <KeyEventInjectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
256 }),
257 }
258 }
259}
260
261pub struct KeyEventInjectorRequestStream {
263 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
264 is_terminated: bool,
265}
266
267impl std::marker::Unpin for KeyEventInjectorRequestStream {}
268
269impl futures::stream::FusedStream for KeyEventInjectorRequestStream {
270 fn is_terminated(&self) -> bool {
271 self.is_terminated
272 }
273}
274
275impl fidl::endpoints::RequestStream for KeyEventInjectorRequestStream {
276 type Protocol = KeyEventInjectorMarker;
277 type ControlHandle = KeyEventInjectorControlHandle;
278
279 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
280 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
281 }
282
283 fn control_handle(&self) -> Self::ControlHandle {
284 KeyEventInjectorControlHandle { inner: self.inner.clone() }
285 }
286
287 fn into_inner(
288 self,
289 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
290 {
291 (self.inner, self.is_terminated)
292 }
293
294 fn from_inner(
295 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
296 is_terminated: bool,
297 ) -> Self {
298 Self { inner, is_terminated }
299 }
300}
301
302impl futures::Stream for KeyEventInjectorRequestStream {
303 type Item = Result<KeyEventInjectorRequest, fidl::Error>;
304
305 fn poll_next(
306 mut self: std::pin::Pin<&mut Self>,
307 cx: &mut std::task::Context<'_>,
308 ) -> std::task::Poll<Option<Self::Item>> {
309 let this = &mut *self;
310 if this.inner.check_shutdown(cx) {
311 this.is_terminated = true;
312 return std::task::Poll::Ready(None);
313 }
314 if this.is_terminated {
315 panic!("polled KeyEventInjectorRequestStream after completion");
316 }
317 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
318 |bytes, handles| {
319 match this.inner.channel().read_etc(cx, bytes, handles) {
320 std::task::Poll::Ready(Ok(())) => {}
321 std::task::Poll::Pending => return std::task::Poll::Pending,
322 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
323 this.is_terminated = true;
324 return std::task::Poll::Ready(None);
325 }
326 std::task::Poll::Ready(Err(e)) => {
327 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
328 e.into(),
329 ))))
330 }
331 }
332
333 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
335
336 std::task::Poll::Ready(Some(match header.ordinal {
337 0x1eb2c0d795c68949 => {
338 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
339 let mut req = fidl::new_empty!(
340 KeyEventInjectorInjectRequest,
341 fidl::encoding::DefaultFuchsiaResourceDialect
342 );
343 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<KeyEventInjectorInjectRequest>(&header, _body_bytes, handles, &mut req)?;
344 let control_handle =
345 KeyEventInjectorControlHandle { inner: this.inner.clone() };
346 Ok(KeyEventInjectorRequest::Inject {
347 key_event: req.key_event,
348
349 responder: KeyEventInjectorInjectResponder {
350 control_handle: std::mem::ManuallyDrop::new(control_handle),
351 tx_id: header.tx_id,
352 },
353 })
354 }
355 _ => Err(fidl::Error::UnknownOrdinal {
356 ordinal: header.ordinal,
357 protocol_name:
358 <KeyEventInjectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
359 }),
360 }))
361 },
362 )
363 }
364}
365
366#[derive(Debug)]
388pub enum KeyEventInjectorRequest {
389 Inject { key_event: KeyEvent, responder: KeyEventInjectorInjectResponder },
397}
398
399impl KeyEventInjectorRequest {
400 #[allow(irrefutable_let_patterns)]
401 pub fn into_inject(self) -> Option<(KeyEvent, KeyEventInjectorInjectResponder)> {
402 if let KeyEventInjectorRequest::Inject { key_event, responder } = self {
403 Some((key_event, responder))
404 } else {
405 None
406 }
407 }
408
409 pub fn method_name(&self) -> &'static str {
411 match *self {
412 KeyEventInjectorRequest::Inject { .. } => "inject",
413 }
414 }
415}
416
417#[derive(Debug, Clone)]
418pub struct KeyEventInjectorControlHandle {
419 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
420}
421
422impl fidl::endpoints::ControlHandle for KeyEventInjectorControlHandle {
423 fn shutdown(&self) {
424 self.inner.shutdown()
425 }
426 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
427 self.inner.shutdown_with_epitaph(status)
428 }
429
430 fn is_closed(&self) -> bool {
431 self.inner.channel().is_closed()
432 }
433 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
434 self.inner.channel().on_closed()
435 }
436
437 #[cfg(target_os = "fuchsia")]
438 fn signal_peer(
439 &self,
440 clear_mask: zx::Signals,
441 set_mask: zx::Signals,
442 ) -> Result<(), zx_status::Status> {
443 use fidl::Peered;
444 self.inner.channel().signal_peer(clear_mask, set_mask)
445 }
446}
447
448impl KeyEventInjectorControlHandle {}
449
450#[must_use = "FIDL methods require a response to be sent"]
451#[derive(Debug)]
452pub struct KeyEventInjectorInjectResponder {
453 control_handle: std::mem::ManuallyDrop<KeyEventInjectorControlHandle>,
454 tx_id: u32,
455}
456
457impl std::ops::Drop for KeyEventInjectorInjectResponder {
461 fn drop(&mut self) {
462 self.control_handle.shutdown();
463 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
465 }
466}
467
468impl fidl::endpoints::Responder for KeyEventInjectorInjectResponder {
469 type ControlHandle = KeyEventInjectorControlHandle;
470
471 fn control_handle(&self) -> &KeyEventInjectorControlHandle {
472 &self.control_handle
473 }
474
475 fn drop_without_shutdown(mut self) {
476 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
478 std::mem::forget(self);
480 }
481}
482
483impl KeyEventInjectorInjectResponder {
484 pub fn send(self, mut status: KeyEventStatus) -> Result<(), fidl::Error> {
488 let _result = self.send_raw(status);
489 if _result.is_err() {
490 self.control_handle.shutdown();
491 }
492 self.drop_without_shutdown();
493 _result
494 }
495
496 pub fn send_no_shutdown_on_err(self, mut status: KeyEventStatus) -> Result<(), fidl::Error> {
498 let _result = self.send_raw(status);
499 self.drop_without_shutdown();
500 _result
501 }
502
503 fn send_raw(&self, mut status: KeyEventStatus) -> Result<(), fidl::Error> {
504 self.control_handle.inner.send::<KeyEventInjectorInjectResponse>(
505 (status,),
506 self.tx_id,
507 0x1eb2c0d795c68949,
508 fidl::encoding::DynamicFlags::empty(),
509 )
510 }
511}
512
513#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
514pub struct KeyboardMarker;
515
516impl fidl::endpoints::ProtocolMarker for KeyboardMarker {
517 type Proxy = KeyboardProxy;
518 type RequestStream = KeyboardRequestStream;
519 #[cfg(target_os = "fuchsia")]
520 type SynchronousProxy = KeyboardSynchronousProxy;
521
522 const DEBUG_NAME: &'static str = "fuchsia.ui.input3.Keyboard";
523}
524impl fidl::endpoints::DiscoverableProtocolMarker for KeyboardMarker {}
525
526pub trait KeyboardProxyInterface: Send + Sync {
527 type AddListenerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
528 fn r#add_listener(
529 &self,
530 view_ref: fidl_fuchsia_ui_views::ViewRef,
531 listener: fidl::endpoints::ClientEnd<KeyboardListenerMarker>,
532 ) -> Self::AddListenerResponseFut;
533}
534#[derive(Debug)]
535#[cfg(target_os = "fuchsia")]
536pub struct KeyboardSynchronousProxy {
537 client: fidl::client::sync::Client,
538}
539
540#[cfg(target_os = "fuchsia")]
541impl fidl::endpoints::SynchronousProxy for KeyboardSynchronousProxy {
542 type Proxy = KeyboardProxy;
543 type Protocol = KeyboardMarker;
544
545 fn from_channel(inner: fidl::Channel) -> Self {
546 Self::new(inner)
547 }
548
549 fn into_channel(self) -> fidl::Channel {
550 self.client.into_channel()
551 }
552
553 fn as_channel(&self) -> &fidl::Channel {
554 self.client.as_channel()
555 }
556}
557
558#[cfg(target_os = "fuchsia")]
559impl KeyboardSynchronousProxy {
560 pub fn new(channel: fidl::Channel) -> Self {
561 let protocol_name = <KeyboardMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
562 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
563 }
564
565 pub fn into_channel(self) -> fidl::Channel {
566 self.client.into_channel()
567 }
568
569 pub fn wait_for_event(
572 &self,
573 deadline: zx::MonotonicInstant,
574 ) -> Result<KeyboardEvent, fidl::Error> {
575 KeyboardEvent::decode(self.client.wait_for_event(deadline)?)
576 }
577
578 pub fn r#add_listener(
586 &self,
587 mut view_ref: fidl_fuchsia_ui_views::ViewRef,
588 mut listener: fidl::endpoints::ClientEnd<KeyboardListenerMarker>,
589 ___deadline: zx::MonotonicInstant,
590 ) -> Result<(), fidl::Error> {
591 let _response =
592 self.client.send_query::<KeyboardAddListenerRequest, fidl::encoding::EmptyPayload>(
593 (&mut view_ref, listener),
594 0x3bc57587fc9b3d22,
595 fidl::encoding::DynamicFlags::empty(),
596 ___deadline,
597 )?;
598 Ok(_response)
599 }
600}
601
602#[cfg(target_os = "fuchsia")]
603impl From<KeyboardSynchronousProxy> for zx::Handle {
604 fn from(value: KeyboardSynchronousProxy) -> Self {
605 value.into_channel().into()
606 }
607}
608
609#[cfg(target_os = "fuchsia")]
610impl From<fidl::Channel> for KeyboardSynchronousProxy {
611 fn from(value: fidl::Channel) -> Self {
612 Self::new(value)
613 }
614}
615
616#[cfg(target_os = "fuchsia")]
617impl fidl::endpoints::FromClient for KeyboardSynchronousProxy {
618 type Protocol = KeyboardMarker;
619
620 fn from_client(value: fidl::endpoints::ClientEnd<KeyboardMarker>) -> Self {
621 Self::new(value.into_channel())
622 }
623}
624
625#[derive(Debug, Clone)]
626pub struct KeyboardProxy {
627 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
628}
629
630impl fidl::endpoints::Proxy for KeyboardProxy {
631 type Protocol = KeyboardMarker;
632
633 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
634 Self::new(inner)
635 }
636
637 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
638 self.client.into_channel().map_err(|client| Self { client })
639 }
640
641 fn as_channel(&self) -> &::fidl::AsyncChannel {
642 self.client.as_channel()
643 }
644}
645
646impl KeyboardProxy {
647 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
649 let protocol_name = <KeyboardMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
650 Self { client: fidl::client::Client::new(channel, protocol_name) }
651 }
652
653 pub fn take_event_stream(&self) -> KeyboardEventStream {
659 KeyboardEventStream { event_receiver: self.client.take_event_receiver() }
660 }
661
662 pub fn r#add_listener(
670 &self,
671 mut view_ref: fidl_fuchsia_ui_views::ViewRef,
672 mut listener: fidl::endpoints::ClientEnd<KeyboardListenerMarker>,
673 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
674 KeyboardProxyInterface::r#add_listener(self, view_ref, listener)
675 }
676}
677
678impl KeyboardProxyInterface for KeyboardProxy {
679 type AddListenerResponseFut =
680 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
681 fn r#add_listener(
682 &self,
683 mut view_ref: fidl_fuchsia_ui_views::ViewRef,
684 mut listener: fidl::endpoints::ClientEnd<KeyboardListenerMarker>,
685 ) -> Self::AddListenerResponseFut {
686 fn _decode(
687 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
688 ) -> Result<(), fidl::Error> {
689 let _response = fidl::client::decode_transaction_body::<
690 fidl::encoding::EmptyPayload,
691 fidl::encoding::DefaultFuchsiaResourceDialect,
692 0x3bc57587fc9b3d22,
693 >(_buf?)?;
694 Ok(_response)
695 }
696 self.client.send_query_and_decode::<KeyboardAddListenerRequest, ()>(
697 (&mut view_ref, listener),
698 0x3bc57587fc9b3d22,
699 fidl::encoding::DynamicFlags::empty(),
700 _decode,
701 )
702 }
703}
704
705pub struct KeyboardEventStream {
706 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
707}
708
709impl std::marker::Unpin for KeyboardEventStream {}
710
711impl futures::stream::FusedStream for KeyboardEventStream {
712 fn is_terminated(&self) -> bool {
713 self.event_receiver.is_terminated()
714 }
715}
716
717impl futures::Stream for KeyboardEventStream {
718 type Item = Result<KeyboardEvent, fidl::Error>;
719
720 fn poll_next(
721 mut self: std::pin::Pin<&mut Self>,
722 cx: &mut std::task::Context<'_>,
723 ) -> std::task::Poll<Option<Self::Item>> {
724 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
725 &mut self.event_receiver,
726 cx
727 )?) {
728 Some(buf) => std::task::Poll::Ready(Some(KeyboardEvent::decode(buf))),
729 None => std::task::Poll::Ready(None),
730 }
731 }
732}
733
734#[derive(Debug)]
735pub enum KeyboardEvent {}
736
737impl KeyboardEvent {
738 fn decode(
740 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
741 ) -> Result<KeyboardEvent, fidl::Error> {
742 let (bytes, _handles) = buf.split_mut();
743 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
744 debug_assert_eq!(tx_header.tx_id, 0);
745 match tx_header.ordinal {
746 _ => Err(fidl::Error::UnknownOrdinal {
747 ordinal: tx_header.ordinal,
748 protocol_name: <KeyboardMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
749 }),
750 }
751 }
752}
753
754pub struct KeyboardRequestStream {
756 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
757 is_terminated: bool,
758}
759
760impl std::marker::Unpin for KeyboardRequestStream {}
761
762impl futures::stream::FusedStream for KeyboardRequestStream {
763 fn is_terminated(&self) -> bool {
764 self.is_terminated
765 }
766}
767
768impl fidl::endpoints::RequestStream for KeyboardRequestStream {
769 type Protocol = KeyboardMarker;
770 type ControlHandle = KeyboardControlHandle;
771
772 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
773 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
774 }
775
776 fn control_handle(&self) -> Self::ControlHandle {
777 KeyboardControlHandle { inner: self.inner.clone() }
778 }
779
780 fn into_inner(
781 self,
782 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
783 {
784 (self.inner, self.is_terminated)
785 }
786
787 fn from_inner(
788 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
789 is_terminated: bool,
790 ) -> Self {
791 Self { inner, is_terminated }
792 }
793}
794
795impl futures::Stream for KeyboardRequestStream {
796 type Item = Result<KeyboardRequest, fidl::Error>;
797
798 fn poll_next(
799 mut self: std::pin::Pin<&mut Self>,
800 cx: &mut std::task::Context<'_>,
801 ) -> std::task::Poll<Option<Self::Item>> {
802 let this = &mut *self;
803 if this.inner.check_shutdown(cx) {
804 this.is_terminated = true;
805 return std::task::Poll::Ready(None);
806 }
807 if this.is_terminated {
808 panic!("polled KeyboardRequestStream after completion");
809 }
810 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
811 |bytes, handles| {
812 match this.inner.channel().read_etc(cx, bytes, handles) {
813 std::task::Poll::Ready(Ok(())) => {}
814 std::task::Poll::Pending => return std::task::Poll::Pending,
815 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
816 this.is_terminated = true;
817 return std::task::Poll::Ready(None);
818 }
819 std::task::Poll::Ready(Err(e)) => {
820 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
821 e.into(),
822 ))))
823 }
824 }
825
826 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
828
829 std::task::Poll::Ready(Some(match header.ordinal {
830 0x3bc57587fc9b3d22 => {
831 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
832 let mut req = fidl::new_empty!(
833 KeyboardAddListenerRequest,
834 fidl::encoding::DefaultFuchsiaResourceDialect
835 );
836 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<KeyboardAddListenerRequest>(&header, _body_bytes, handles, &mut req)?;
837 let control_handle = KeyboardControlHandle { inner: this.inner.clone() };
838 Ok(KeyboardRequest::AddListener {
839 view_ref: req.view_ref,
840 listener: req.listener,
841
842 responder: KeyboardAddListenerResponder {
843 control_handle: std::mem::ManuallyDrop::new(control_handle),
844 tx_id: header.tx_id,
845 },
846 })
847 }
848 _ => Err(fidl::Error::UnknownOrdinal {
849 ordinal: header.ordinal,
850 protocol_name:
851 <KeyboardMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
852 }),
853 }))
854 },
855 )
856 }
857}
858
859#[derive(Debug)]
862pub enum KeyboardRequest {
863 AddListener {
871 view_ref: fidl_fuchsia_ui_views::ViewRef,
872 listener: fidl::endpoints::ClientEnd<KeyboardListenerMarker>,
873 responder: KeyboardAddListenerResponder,
874 },
875}
876
877impl KeyboardRequest {
878 #[allow(irrefutable_let_patterns)]
879 pub fn into_add_listener(
880 self,
881 ) -> Option<(
882 fidl_fuchsia_ui_views::ViewRef,
883 fidl::endpoints::ClientEnd<KeyboardListenerMarker>,
884 KeyboardAddListenerResponder,
885 )> {
886 if let KeyboardRequest::AddListener { view_ref, listener, responder } = self {
887 Some((view_ref, listener, responder))
888 } else {
889 None
890 }
891 }
892
893 pub fn method_name(&self) -> &'static str {
895 match *self {
896 KeyboardRequest::AddListener { .. } => "add_listener",
897 }
898 }
899}
900
901#[derive(Debug, Clone)]
902pub struct KeyboardControlHandle {
903 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
904}
905
906impl fidl::endpoints::ControlHandle for KeyboardControlHandle {
907 fn shutdown(&self) {
908 self.inner.shutdown()
909 }
910 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
911 self.inner.shutdown_with_epitaph(status)
912 }
913
914 fn is_closed(&self) -> bool {
915 self.inner.channel().is_closed()
916 }
917 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
918 self.inner.channel().on_closed()
919 }
920
921 #[cfg(target_os = "fuchsia")]
922 fn signal_peer(
923 &self,
924 clear_mask: zx::Signals,
925 set_mask: zx::Signals,
926 ) -> Result<(), zx_status::Status> {
927 use fidl::Peered;
928 self.inner.channel().signal_peer(clear_mask, set_mask)
929 }
930}
931
932impl KeyboardControlHandle {}
933
934#[must_use = "FIDL methods require a response to be sent"]
935#[derive(Debug)]
936pub struct KeyboardAddListenerResponder {
937 control_handle: std::mem::ManuallyDrop<KeyboardControlHandle>,
938 tx_id: u32,
939}
940
941impl std::ops::Drop for KeyboardAddListenerResponder {
945 fn drop(&mut self) {
946 self.control_handle.shutdown();
947 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
949 }
950}
951
952impl fidl::endpoints::Responder for KeyboardAddListenerResponder {
953 type ControlHandle = KeyboardControlHandle;
954
955 fn control_handle(&self) -> &KeyboardControlHandle {
956 &self.control_handle
957 }
958
959 fn drop_without_shutdown(mut self) {
960 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
962 std::mem::forget(self);
964 }
965}
966
967impl KeyboardAddListenerResponder {
968 pub fn send(self) -> Result<(), fidl::Error> {
972 let _result = self.send_raw();
973 if _result.is_err() {
974 self.control_handle.shutdown();
975 }
976 self.drop_without_shutdown();
977 _result
978 }
979
980 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
982 let _result = self.send_raw();
983 self.drop_without_shutdown();
984 _result
985 }
986
987 fn send_raw(&self) -> Result<(), fidl::Error> {
988 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
989 (),
990 self.tx_id,
991 0x3bc57587fc9b3d22,
992 fidl::encoding::DynamicFlags::empty(),
993 )
994 }
995}
996
997#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
998pub struct KeyboardListenerMarker;
999
1000impl fidl::endpoints::ProtocolMarker for KeyboardListenerMarker {
1001 type Proxy = KeyboardListenerProxy;
1002 type RequestStream = KeyboardListenerRequestStream;
1003 #[cfg(target_os = "fuchsia")]
1004 type SynchronousProxy = KeyboardListenerSynchronousProxy;
1005
1006 const DEBUG_NAME: &'static str = "(anonymous) KeyboardListener";
1007}
1008
1009pub trait KeyboardListenerProxyInterface: Send + Sync {
1010 type OnKeyEventResponseFut: std::future::Future<Output = Result<KeyEventStatus, fidl::Error>>
1011 + Send;
1012 fn r#on_key_event(&self, event: &KeyEvent) -> Self::OnKeyEventResponseFut;
1013}
1014#[derive(Debug)]
1015#[cfg(target_os = "fuchsia")]
1016pub struct KeyboardListenerSynchronousProxy {
1017 client: fidl::client::sync::Client,
1018}
1019
1020#[cfg(target_os = "fuchsia")]
1021impl fidl::endpoints::SynchronousProxy for KeyboardListenerSynchronousProxy {
1022 type Proxy = KeyboardListenerProxy;
1023 type Protocol = KeyboardListenerMarker;
1024
1025 fn from_channel(inner: fidl::Channel) -> Self {
1026 Self::new(inner)
1027 }
1028
1029 fn into_channel(self) -> fidl::Channel {
1030 self.client.into_channel()
1031 }
1032
1033 fn as_channel(&self) -> &fidl::Channel {
1034 self.client.as_channel()
1035 }
1036}
1037
1038#[cfg(target_os = "fuchsia")]
1039impl KeyboardListenerSynchronousProxy {
1040 pub fn new(channel: fidl::Channel) -> Self {
1041 let protocol_name = <KeyboardListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1042 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1043 }
1044
1045 pub fn into_channel(self) -> fidl::Channel {
1046 self.client.into_channel()
1047 }
1048
1049 pub fn wait_for_event(
1052 &self,
1053 deadline: zx::MonotonicInstant,
1054 ) -> Result<KeyboardListenerEvent, fidl::Error> {
1055 KeyboardListenerEvent::decode(self.client.wait_for_event(deadline)?)
1056 }
1057
1058 pub fn r#on_key_event(
1072 &self,
1073 mut event: &KeyEvent,
1074 ___deadline: zx::MonotonicInstant,
1075 ) -> Result<KeyEventStatus, fidl::Error> {
1076 let _response = self
1077 .client
1078 .send_query::<KeyboardListenerOnKeyEventRequest, KeyboardListenerOnKeyEventResponse>(
1079 (event,),
1080 0x2ef2ee16ac509093,
1081 fidl::encoding::DynamicFlags::empty(),
1082 ___deadline,
1083 )?;
1084 Ok(_response.status)
1085 }
1086}
1087
1088#[cfg(target_os = "fuchsia")]
1089impl From<KeyboardListenerSynchronousProxy> for zx::Handle {
1090 fn from(value: KeyboardListenerSynchronousProxy) -> Self {
1091 value.into_channel().into()
1092 }
1093}
1094
1095#[cfg(target_os = "fuchsia")]
1096impl From<fidl::Channel> for KeyboardListenerSynchronousProxy {
1097 fn from(value: fidl::Channel) -> Self {
1098 Self::new(value)
1099 }
1100}
1101
1102#[cfg(target_os = "fuchsia")]
1103impl fidl::endpoints::FromClient for KeyboardListenerSynchronousProxy {
1104 type Protocol = KeyboardListenerMarker;
1105
1106 fn from_client(value: fidl::endpoints::ClientEnd<KeyboardListenerMarker>) -> Self {
1107 Self::new(value.into_channel())
1108 }
1109}
1110
1111#[derive(Debug, Clone)]
1112pub struct KeyboardListenerProxy {
1113 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1114}
1115
1116impl fidl::endpoints::Proxy for KeyboardListenerProxy {
1117 type Protocol = KeyboardListenerMarker;
1118
1119 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1120 Self::new(inner)
1121 }
1122
1123 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1124 self.client.into_channel().map_err(|client| Self { client })
1125 }
1126
1127 fn as_channel(&self) -> &::fidl::AsyncChannel {
1128 self.client.as_channel()
1129 }
1130}
1131
1132impl KeyboardListenerProxy {
1133 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1135 let protocol_name = <KeyboardListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1136 Self { client: fidl::client::Client::new(channel, protocol_name) }
1137 }
1138
1139 pub fn take_event_stream(&self) -> KeyboardListenerEventStream {
1145 KeyboardListenerEventStream { event_receiver: self.client.take_event_receiver() }
1146 }
1147
1148 pub fn r#on_key_event(
1162 &self,
1163 mut event: &KeyEvent,
1164 ) -> fidl::client::QueryResponseFut<KeyEventStatus, fidl::encoding::DefaultFuchsiaResourceDialect>
1165 {
1166 KeyboardListenerProxyInterface::r#on_key_event(self, event)
1167 }
1168}
1169
1170impl KeyboardListenerProxyInterface for KeyboardListenerProxy {
1171 type OnKeyEventResponseFut = fidl::client::QueryResponseFut<
1172 KeyEventStatus,
1173 fidl::encoding::DefaultFuchsiaResourceDialect,
1174 >;
1175 fn r#on_key_event(&self, mut event: &KeyEvent) -> Self::OnKeyEventResponseFut {
1176 fn _decode(
1177 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1178 ) -> Result<KeyEventStatus, fidl::Error> {
1179 let _response = fidl::client::decode_transaction_body::<
1180 KeyboardListenerOnKeyEventResponse,
1181 fidl::encoding::DefaultFuchsiaResourceDialect,
1182 0x2ef2ee16ac509093,
1183 >(_buf?)?;
1184 Ok(_response.status)
1185 }
1186 self.client.send_query_and_decode::<KeyboardListenerOnKeyEventRequest, KeyEventStatus>(
1187 (event,),
1188 0x2ef2ee16ac509093,
1189 fidl::encoding::DynamicFlags::empty(),
1190 _decode,
1191 )
1192 }
1193}
1194
1195pub struct KeyboardListenerEventStream {
1196 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1197}
1198
1199impl std::marker::Unpin for KeyboardListenerEventStream {}
1200
1201impl futures::stream::FusedStream for KeyboardListenerEventStream {
1202 fn is_terminated(&self) -> bool {
1203 self.event_receiver.is_terminated()
1204 }
1205}
1206
1207impl futures::Stream for KeyboardListenerEventStream {
1208 type Item = Result<KeyboardListenerEvent, fidl::Error>;
1209
1210 fn poll_next(
1211 mut self: std::pin::Pin<&mut Self>,
1212 cx: &mut std::task::Context<'_>,
1213 ) -> std::task::Poll<Option<Self::Item>> {
1214 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1215 &mut self.event_receiver,
1216 cx
1217 )?) {
1218 Some(buf) => std::task::Poll::Ready(Some(KeyboardListenerEvent::decode(buf))),
1219 None => std::task::Poll::Ready(None),
1220 }
1221 }
1222}
1223
1224#[derive(Debug)]
1225pub enum KeyboardListenerEvent {}
1226
1227impl KeyboardListenerEvent {
1228 fn decode(
1230 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1231 ) -> Result<KeyboardListenerEvent, fidl::Error> {
1232 let (bytes, _handles) = buf.split_mut();
1233 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1234 debug_assert_eq!(tx_header.tx_id, 0);
1235 match tx_header.ordinal {
1236 _ => Err(fidl::Error::UnknownOrdinal {
1237 ordinal: tx_header.ordinal,
1238 protocol_name:
1239 <KeyboardListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1240 }),
1241 }
1242 }
1243}
1244
1245pub struct KeyboardListenerRequestStream {
1247 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1248 is_terminated: bool,
1249}
1250
1251impl std::marker::Unpin for KeyboardListenerRequestStream {}
1252
1253impl futures::stream::FusedStream for KeyboardListenerRequestStream {
1254 fn is_terminated(&self) -> bool {
1255 self.is_terminated
1256 }
1257}
1258
1259impl fidl::endpoints::RequestStream for KeyboardListenerRequestStream {
1260 type Protocol = KeyboardListenerMarker;
1261 type ControlHandle = KeyboardListenerControlHandle;
1262
1263 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1264 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1265 }
1266
1267 fn control_handle(&self) -> Self::ControlHandle {
1268 KeyboardListenerControlHandle { inner: self.inner.clone() }
1269 }
1270
1271 fn into_inner(
1272 self,
1273 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1274 {
1275 (self.inner, self.is_terminated)
1276 }
1277
1278 fn from_inner(
1279 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1280 is_terminated: bool,
1281 ) -> Self {
1282 Self { inner, is_terminated }
1283 }
1284}
1285
1286impl futures::Stream for KeyboardListenerRequestStream {
1287 type Item = Result<KeyboardListenerRequest, fidl::Error>;
1288
1289 fn poll_next(
1290 mut self: std::pin::Pin<&mut Self>,
1291 cx: &mut std::task::Context<'_>,
1292 ) -> std::task::Poll<Option<Self::Item>> {
1293 let this = &mut *self;
1294 if this.inner.check_shutdown(cx) {
1295 this.is_terminated = true;
1296 return std::task::Poll::Ready(None);
1297 }
1298 if this.is_terminated {
1299 panic!("polled KeyboardListenerRequestStream after completion");
1300 }
1301 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1302 |bytes, handles| {
1303 match this.inner.channel().read_etc(cx, bytes, handles) {
1304 std::task::Poll::Ready(Ok(())) => {}
1305 std::task::Poll::Pending => return std::task::Poll::Pending,
1306 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1307 this.is_terminated = true;
1308 return std::task::Poll::Ready(None);
1309 }
1310 std::task::Poll::Ready(Err(e)) => {
1311 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1312 e.into(),
1313 ))))
1314 }
1315 }
1316
1317 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1319
1320 std::task::Poll::Ready(Some(match header.ordinal {
1321 0x2ef2ee16ac509093 => {
1322 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1323 let mut req = fidl::new_empty!(
1324 KeyboardListenerOnKeyEventRequest,
1325 fidl::encoding::DefaultFuchsiaResourceDialect
1326 );
1327 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<KeyboardListenerOnKeyEventRequest>(&header, _body_bytes, handles, &mut req)?;
1328 let control_handle =
1329 KeyboardListenerControlHandle { inner: this.inner.clone() };
1330 Ok(KeyboardListenerRequest::OnKeyEvent {
1331 event: req.event,
1332
1333 responder: KeyboardListenerOnKeyEventResponder {
1334 control_handle: std::mem::ManuallyDrop::new(control_handle),
1335 tx_id: header.tx_id,
1336 },
1337 })
1338 }
1339 _ => Err(fidl::Error::UnknownOrdinal {
1340 ordinal: header.ordinal,
1341 protocol_name:
1342 <KeyboardListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1343 }),
1344 }))
1345 },
1346 )
1347 }
1348}
1349
1350#[derive(Debug)]
1352pub enum KeyboardListenerRequest {
1353 OnKeyEvent { event: KeyEvent, responder: KeyboardListenerOnKeyEventResponder },
1367}
1368
1369impl KeyboardListenerRequest {
1370 #[allow(irrefutable_let_patterns)]
1371 pub fn into_on_key_event(self) -> Option<(KeyEvent, KeyboardListenerOnKeyEventResponder)> {
1372 if let KeyboardListenerRequest::OnKeyEvent { event, responder } = self {
1373 Some((event, responder))
1374 } else {
1375 None
1376 }
1377 }
1378
1379 pub fn method_name(&self) -> &'static str {
1381 match *self {
1382 KeyboardListenerRequest::OnKeyEvent { .. } => "on_key_event",
1383 }
1384 }
1385}
1386
1387#[derive(Debug, Clone)]
1388pub struct KeyboardListenerControlHandle {
1389 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1390}
1391
1392impl fidl::endpoints::ControlHandle for KeyboardListenerControlHandle {
1393 fn shutdown(&self) {
1394 self.inner.shutdown()
1395 }
1396 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1397 self.inner.shutdown_with_epitaph(status)
1398 }
1399
1400 fn is_closed(&self) -> bool {
1401 self.inner.channel().is_closed()
1402 }
1403 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1404 self.inner.channel().on_closed()
1405 }
1406
1407 #[cfg(target_os = "fuchsia")]
1408 fn signal_peer(
1409 &self,
1410 clear_mask: zx::Signals,
1411 set_mask: zx::Signals,
1412 ) -> Result<(), zx_status::Status> {
1413 use fidl::Peered;
1414 self.inner.channel().signal_peer(clear_mask, set_mask)
1415 }
1416}
1417
1418impl KeyboardListenerControlHandle {}
1419
1420#[must_use = "FIDL methods require a response to be sent"]
1421#[derive(Debug)]
1422pub struct KeyboardListenerOnKeyEventResponder {
1423 control_handle: std::mem::ManuallyDrop<KeyboardListenerControlHandle>,
1424 tx_id: u32,
1425}
1426
1427impl std::ops::Drop for KeyboardListenerOnKeyEventResponder {
1431 fn drop(&mut self) {
1432 self.control_handle.shutdown();
1433 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1435 }
1436}
1437
1438impl fidl::endpoints::Responder for KeyboardListenerOnKeyEventResponder {
1439 type ControlHandle = KeyboardListenerControlHandle;
1440
1441 fn control_handle(&self) -> &KeyboardListenerControlHandle {
1442 &self.control_handle
1443 }
1444
1445 fn drop_without_shutdown(mut self) {
1446 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1448 std::mem::forget(self);
1450 }
1451}
1452
1453impl KeyboardListenerOnKeyEventResponder {
1454 pub fn send(self, mut status: KeyEventStatus) -> Result<(), fidl::Error> {
1458 let _result = self.send_raw(status);
1459 if _result.is_err() {
1460 self.control_handle.shutdown();
1461 }
1462 self.drop_without_shutdown();
1463 _result
1464 }
1465
1466 pub fn send_no_shutdown_on_err(self, mut status: KeyEventStatus) -> Result<(), fidl::Error> {
1468 let _result = self.send_raw(status);
1469 self.drop_without_shutdown();
1470 _result
1471 }
1472
1473 fn send_raw(&self, mut status: KeyEventStatus) -> Result<(), fidl::Error> {
1474 self.control_handle.inner.send::<KeyboardListenerOnKeyEventResponse>(
1475 (status,),
1476 self.tx_id,
1477 0x2ef2ee16ac509093,
1478 fidl::encoding::DynamicFlags::empty(),
1479 )
1480 }
1481}
1482
1483mod internal {
1484 use super::*;
1485
1486 impl fidl::encoding::ResourceTypeMarker for KeyboardAddListenerRequest {
1487 type Borrowed<'a> = &'a mut Self;
1488 fn take_or_borrow<'a>(
1489 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1490 ) -> Self::Borrowed<'a> {
1491 value
1492 }
1493 }
1494
1495 unsafe impl fidl::encoding::TypeMarker for KeyboardAddListenerRequest {
1496 type Owned = Self;
1497
1498 #[inline(always)]
1499 fn inline_align(_context: fidl::encoding::Context) -> usize {
1500 4
1501 }
1502
1503 #[inline(always)]
1504 fn inline_size(_context: fidl::encoding::Context) -> usize {
1505 8
1506 }
1507 }
1508
1509 unsafe impl
1510 fidl::encoding::Encode<
1511 KeyboardAddListenerRequest,
1512 fidl::encoding::DefaultFuchsiaResourceDialect,
1513 > for &mut KeyboardAddListenerRequest
1514 {
1515 #[inline]
1516 unsafe fn encode(
1517 self,
1518 encoder: &mut fidl::encoding::Encoder<
1519 '_,
1520 fidl::encoding::DefaultFuchsiaResourceDialect,
1521 >,
1522 offset: usize,
1523 _depth: fidl::encoding::Depth,
1524 ) -> fidl::Result<()> {
1525 encoder.debug_check_bounds::<KeyboardAddListenerRequest>(offset);
1526 fidl::encoding::Encode::<KeyboardAddListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1528 (
1529 <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_ref),
1530 <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<KeyboardListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.listener),
1531 ),
1532 encoder, offset, _depth
1533 )
1534 }
1535 }
1536 unsafe impl<
1537 T0: fidl::encoding::Encode<
1538 fidl_fuchsia_ui_views::ViewRef,
1539 fidl::encoding::DefaultFuchsiaResourceDialect,
1540 >,
1541 T1: fidl::encoding::Encode<
1542 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<KeyboardListenerMarker>>,
1543 fidl::encoding::DefaultFuchsiaResourceDialect,
1544 >,
1545 >
1546 fidl::encoding::Encode<
1547 KeyboardAddListenerRequest,
1548 fidl::encoding::DefaultFuchsiaResourceDialect,
1549 > for (T0, T1)
1550 {
1551 #[inline]
1552 unsafe fn encode(
1553 self,
1554 encoder: &mut fidl::encoding::Encoder<
1555 '_,
1556 fidl::encoding::DefaultFuchsiaResourceDialect,
1557 >,
1558 offset: usize,
1559 depth: fidl::encoding::Depth,
1560 ) -> fidl::Result<()> {
1561 encoder.debug_check_bounds::<KeyboardAddListenerRequest>(offset);
1562 self.0.encode(encoder, offset + 0, depth)?;
1566 self.1.encode(encoder, offset + 4, depth)?;
1567 Ok(())
1568 }
1569 }
1570
1571 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1572 for KeyboardAddListenerRequest
1573 {
1574 #[inline(always)]
1575 fn new_empty() -> Self {
1576 Self {
1577 view_ref: fidl::new_empty!(
1578 fidl_fuchsia_ui_views::ViewRef,
1579 fidl::encoding::DefaultFuchsiaResourceDialect
1580 ),
1581 listener: fidl::new_empty!(
1582 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<KeyboardListenerMarker>>,
1583 fidl::encoding::DefaultFuchsiaResourceDialect
1584 ),
1585 }
1586 }
1587
1588 #[inline]
1589 unsafe fn decode(
1590 &mut self,
1591 decoder: &mut fidl::encoding::Decoder<
1592 '_,
1593 fidl::encoding::DefaultFuchsiaResourceDialect,
1594 >,
1595 offset: usize,
1596 _depth: fidl::encoding::Depth,
1597 ) -> fidl::Result<()> {
1598 decoder.debug_check_bounds::<Self>(offset);
1599 fidl::decode!(
1601 fidl_fuchsia_ui_views::ViewRef,
1602 fidl::encoding::DefaultFuchsiaResourceDialect,
1603 &mut self.view_ref,
1604 decoder,
1605 offset + 0,
1606 _depth
1607 )?;
1608 fidl::decode!(
1609 fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<KeyboardListenerMarker>>,
1610 fidl::encoding::DefaultFuchsiaResourceDialect,
1611 &mut self.listener,
1612 decoder,
1613 offset + 4,
1614 _depth
1615 )?;
1616 Ok(())
1617 }
1618 }
1619}