fidl_fuchsia_input_interaction/
fidl_fuchsia_input_interaction.rs1#![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_input_interaction__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct NotifierWatchStateResponse {
16 pub state: State,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20 for NotifierWatchStateResponse
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct NotifierMarker;
26
27impl fidl::endpoints::ProtocolMarker for NotifierMarker {
28 type Proxy = NotifierProxy;
29 type RequestStream = NotifierRequestStream;
30 #[cfg(target_os = "fuchsia")]
31 type SynchronousProxy = NotifierSynchronousProxy;
32
33 const DEBUG_NAME: &'static str = "fuchsia.input.interaction.Notifier";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for NotifierMarker {}
36
37pub trait NotifierProxyInterface: Send + Sync {
38 type WatchStateResponseFut: std::future::Future<Output = Result<State, fidl::Error>> + Send;
39 fn r#watch_state(&self) -> Self::WatchStateResponseFut;
40}
41#[derive(Debug)]
42#[cfg(target_os = "fuchsia")]
43pub struct NotifierSynchronousProxy {
44 client: fidl::client::sync::Client,
45}
46
47#[cfg(target_os = "fuchsia")]
48impl fidl::endpoints::SynchronousProxy for NotifierSynchronousProxy {
49 type Proxy = NotifierProxy;
50 type Protocol = NotifierMarker;
51
52 fn from_channel(inner: fidl::Channel) -> Self {
53 Self::new(inner)
54 }
55
56 fn into_channel(self) -> fidl::Channel {
57 self.client.into_channel()
58 }
59
60 fn as_channel(&self) -> &fidl::Channel {
61 self.client.as_channel()
62 }
63}
64
65#[cfg(target_os = "fuchsia")]
66impl NotifierSynchronousProxy {
67 pub fn new(channel: fidl::Channel) -> Self {
68 let protocol_name = <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
69 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
70 }
71
72 pub fn into_channel(self) -> fidl::Channel {
73 self.client.into_channel()
74 }
75
76 pub fn wait_for_event(
79 &self,
80 deadline: zx::MonotonicInstant,
81 ) -> Result<NotifierEvent, fidl::Error> {
82 NotifierEvent::decode(self.client.wait_for_event(deadline)?)
83 }
84
85 pub fn r#watch_state(&self, ___deadline: zx::MonotonicInstant) -> Result<State, fidl::Error> {
91 let _response =
92 self.client.send_query::<fidl::encoding::EmptyPayload, NotifierWatchStateResponse>(
93 (),
94 0xf379d6bc002e8ee,
95 fidl::encoding::DynamicFlags::empty(),
96 ___deadline,
97 )?;
98 Ok(_response.state)
99 }
100}
101
102#[cfg(target_os = "fuchsia")]
103impl From<NotifierSynchronousProxy> for zx::Handle {
104 fn from(value: NotifierSynchronousProxy) -> Self {
105 value.into_channel().into()
106 }
107}
108
109#[cfg(target_os = "fuchsia")]
110impl From<fidl::Channel> for NotifierSynchronousProxy {
111 fn from(value: fidl::Channel) -> Self {
112 Self::new(value)
113 }
114}
115
116#[cfg(target_os = "fuchsia")]
117impl fidl::endpoints::FromClient for NotifierSynchronousProxy {
118 type Protocol = NotifierMarker;
119
120 fn from_client(value: fidl::endpoints::ClientEnd<NotifierMarker>) -> Self {
121 Self::new(value.into_channel())
122 }
123}
124
125#[derive(Debug, Clone)]
126pub struct NotifierProxy {
127 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
128}
129
130impl fidl::endpoints::Proxy for NotifierProxy {
131 type Protocol = NotifierMarker;
132
133 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
134 Self::new(inner)
135 }
136
137 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
138 self.client.into_channel().map_err(|client| Self { client })
139 }
140
141 fn as_channel(&self) -> &::fidl::AsyncChannel {
142 self.client.as_channel()
143 }
144}
145
146impl NotifierProxy {
147 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
149 let protocol_name = <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
150 Self { client: fidl::client::Client::new(channel, protocol_name) }
151 }
152
153 pub fn take_event_stream(&self) -> NotifierEventStream {
159 NotifierEventStream { event_receiver: self.client.take_event_receiver() }
160 }
161
162 pub fn r#watch_state(
168 &self,
169 ) -> fidl::client::QueryResponseFut<State, fidl::encoding::DefaultFuchsiaResourceDialect> {
170 NotifierProxyInterface::r#watch_state(self)
171 }
172}
173
174impl NotifierProxyInterface for NotifierProxy {
175 type WatchStateResponseFut =
176 fidl::client::QueryResponseFut<State, fidl::encoding::DefaultFuchsiaResourceDialect>;
177 fn r#watch_state(&self) -> Self::WatchStateResponseFut {
178 fn _decode(
179 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
180 ) -> Result<State, fidl::Error> {
181 let _response = fidl::client::decode_transaction_body::<
182 NotifierWatchStateResponse,
183 fidl::encoding::DefaultFuchsiaResourceDialect,
184 0xf379d6bc002e8ee,
185 >(_buf?)?;
186 Ok(_response.state)
187 }
188 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, State>(
189 (),
190 0xf379d6bc002e8ee,
191 fidl::encoding::DynamicFlags::empty(),
192 _decode,
193 )
194 }
195}
196
197pub struct NotifierEventStream {
198 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
199}
200
201impl std::marker::Unpin for NotifierEventStream {}
202
203impl futures::stream::FusedStream for NotifierEventStream {
204 fn is_terminated(&self) -> bool {
205 self.event_receiver.is_terminated()
206 }
207}
208
209impl futures::Stream for NotifierEventStream {
210 type Item = Result<NotifierEvent, fidl::Error>;
211
212 fn poll_next(
213 mut self: std::pin::Pin<&mut Self>,
214 cx: &mut std::task::Context<'_>,
215 ) -> std::task::Poll<Option<Self::Item>> {
216 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
217 &mut self.event_receiver,
218 cx
219 )?) {
220 Some(buf) => std::task::Poll::Ready(Some(NotifierEvent::decode(buf))),
221 None => std::task::Poll::Ready(None),
222 }
223 }
224}
225
226#[derive(Debug)]
227pub enum NotifierEvent {}
228
229impl NotifierEvent {
230 fn decode(
232 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
233 ) -> Result<NotifierEvent, fidl::Error> {
234 let (bytes, _handles) = buf.split_mut();
235 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
236 debug_assert_eq!(tx_header.tx_id, 0);
237 match tx_header.ordinal {
238 _ => Err(fidl::Error::UnknownOrdinal {
239 ordinal: tx_header.ordinal,
240 protocol_name: <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
241 }),
242 }
243 }
244}
245
246pub struct NotifierRequestStream {
248 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
249 is_terminated: bool,
250}
251
252impl std::marker::Unpin for NotifierRequestStream {}
253
254impl futures::stream::FusedStream for NotifierRequestStream {
255 fn is_terminated(&self) -> bool {
256 self.is_terminated
257 }
258}
259
260impl fidl::endpoints::RequestStream for NotifierRequestStream {
261 type Protocol = NotifierMarker;
262 type ControlHandle = NotifierControlHandle;
263
264 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
265 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
266 }
267
268 fn control_handle(&self) -> Self::ControlHandle {
269 NotifierControlHandle { inner: self.inner.clone() }
270 }
271
272 fn into_inner(
273 self,
274 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
275 {
276 (self.inner, self.is_terminated)
277 }
278
279 fn from_inner(
280 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
281 is_terminated: bool,
282 ) -> Self {
283 Self { inner, is_terminated }
284 }
285}
286
287impl futures::Stream for NotifierRequestStream {
288 type Item = Result<NotifierRequest, fidl::Error>;
289
290 fn poll_next(
291 mut self: std::pin::Pin<&mut Self>,
292 cx: &mut std::task::Context<'_>,
293 ) -> std::task::Poll<Option<Self::Item>> {
294 let this = &mut *self;
295 if this.inner.check_shutdown(cx) {
296 this.is_terminated = true;
297 return std::task::Poll::Ready(None);
298 }
299 if this.is_terminated {
300 panic!("polled NotifierRequestStream after completion");
301 }
302 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
303 |bytes, handles| {
304 match this.inner.channel().read_etc(cx, bytes, handles) {
305 std::task::Poll::Ready(Ok(())) => {}
306 std::task::Poll::Pending => return std::task::Poll::Pending,
307 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
308 this.is_terminated = true;
309 return std::task::Poll::Ready(None);
310 }
311 std::task::Poll::Ready(Err(e)) => {
312 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
313 e.into(),
314 ))))
315 }
316 }
317
318 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
320
321 std::task::Poll::Ready(Some(match header.ordinal {
322 0xf379d6bc002e8ee => {
323 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
324 let mut req = fidl::new_empty!(
325 fidl::encoding::EmptyPayload,
326 fidl::encoding::DefaultFuchsiaResourceDialect
327 );
328 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
329 let control_handle = NotifierControlHandle { inner: this.inner.clone() };
330 Ok(NotifierRequest::WatchState {
331 responder: NotifierWatchStateResponder {
332 control_handle: std::mem::ManuallyDrop::new(control_handle),
333 tx_id: header.tx_id,
334 },
335 })
336 }
337 _ => Err(fidl::Error::UnknownOrdinal {
338 ordinal: header.ordinal,
339 protocol_name:
340 <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
341 }),
342 }))
343 },
344 )
345 }
346}
347
348#[derive(Debug)]
351pub enum NotifierRequest {
352 WatchState { responder: NotifierWatchStateResponder },
358}
359
360impl NotifierRequest {
361 #[allow(irrefutable_let_patterns)]
362 pub fn into_watch_state(self) -> Option<(NotifierWatchStateResponder)> {
363 if let NotifierRequest::WatchState { responder } = self {
364 Some((responder))
365 } else {
366 None
367 }
368 }
369
370 pub fn method_name(&self) -> &'static str {
372 match *self {
373 NotifierRequest::WatchState { .. } => "watch_state",
374 }
375 }
376}
377
378#[derive(Debug, Clone)]
379pub struct NotifierControlHandle {
380 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
381}
382
383impl fidl::endpoints::ControlHandle for NotifierControlHandle {
384 fn shutdown(&self) {
385 self.inner.shutdown()
386 }
387 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
388 self.inner.shutdown_with_epitaph(status)
389 }
390
391 fn is_closed(&self) -> bool {
392 self.inner.channel().is_closed()
393 }
394 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
395 self.inner.channel().on_closed()
396 }
397
398 #[cfg(target_os = "fuchsia")]
399 fn signal_peer(
400 &self,
401 clear_mask: zx::Signals,
402 set_mask: zx::Signals,
403 ) -> Result<(), zx_status::Status> {
404 use fidl::Peered;
405 self.inner.channel().signal_peer(clear_mask, set_mask)
406 }
407}
408
409impl NotifierControlHandle {}
410
411#[must_use = "FIDL methods require a response to be sent"]
412#[derive(Debug)]
413pub struct NotifierWatchStateResponder {
414 control_handle: std::mem::ManuallyDrop<NotifierControlHandle>,
415 tx_id: u32,
416}
417
418impl std::ops::Drop for NotifierWatchStateResponder {
422 fn drop(&mut self) {
423 self.control_handle.shutdown();
424 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
426 }
427}
428
429impl fidl::endpoints::Responder for NotifierWatchStateResponder {
430 type ControlHandle = NotifierControlHandle;
431
432 fn control_handle(&self) -> &NotifierControlHandle {
433 &self.control_handle
434 }
435
436 fn drop_without_shutdown(mut self) {
437 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
439 std::mem::forget(self);
441 }
442}
443
444impl NotifierWatchStateResponder {
445 pub fn send(self, mut state: State) -> Result<(), fidl::Error> {
449 let _result = self.send_raw(state);
450 if _result.is_err() {
451 self.control_handle.shutdown();
452 }
453 self.drop_without_shutdown();
454 _result
455 }
456
457 pub fn send_no_shutdown_on_err(self, mut state: State) -> Result<(), fidl::Error> {
459 let _result = self.send_raw(state);
460 self.drop_without_shutdown();
461 _result
462 }
463
464 fn send_raw(&self, mut state: State) -> Result<(), fidl::Error> {
465 self.control_handle.inner.send::<NotifierWatchStateResponse>(
466 (state,),
467 self.tx_id,
468 0xf379d6bc002e8ee,
469 fidl::encoding::DynamicFlags::empty(),
470 )
471 }
472}
473
474mod internal {
475 use super::*;
476
477 impl fidl::encoding::ResourceTypeMarker for NotifierWatchStateResponse {
478 type Borrowed<'a> = &'a mut Self;
479 fn take_or_borrow<'a>(
480 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
481 ) -> Self::Borrowed<'a> {
482 value
483 }
484 }
485
486 unsafe impl fidl::encoding::TypeMarker for NotifierWatchStateResponse {
487 type Owned = Self;
488
489 #[inline(always)]
490 fn inline_align(_context: fidl::encoding::Context) -> usize {
491 4
492 }
493
494 #[inline(always)]
495 fn inline_size(_context: fidl::encoding::Context) -> usize {
496 4
497 }
498 }
499
500 unsafe impl
501 fidl::encoding::Encode<
502 NotifierWatchStateResponse,
503 fidl::encoding::DefaultFuchsiaResourceDialect,
504 > for &mut NotifierWatchStateResponse
505 {
506 #[inline]
507 unsafe fn encode(
508 self,
509 encoder: &mut fidl::encoding::Encoder<
510 '_,
511 fidl::encoding::DefaultFuchsiaResourceDialect,
512 >,
513 offset: usize,
514 _depth: fidl::encoding::Depth,
515 ) -> fidl::Result<()> {
516 encoder.debug_check_bounds::<NotifierWatchStateResponse>(offset);
517 fidl::encoding::Encode::<
519 NotifierWatchStateResponse,
520 fidl::encoding::DefaultFuchsiaResourceDialect,
521 >::encode(
522 (<State as fidl::encoding::ValueTypeMarker>::borrow(&self.state),),
523 encoder,
524 offset,
525 _depth,
526 )
527 }
528 }
529 unsafe impl<T0: fidl::encoding::Encode<State, fidl::encoding::DefaultFuchsiaResourceDialect>>
530 fidl::encoding::Encode<
531 NotifierWatchStateResponse,
532 fidl::encoding::DefaultFuchsiaResourceDialect,
533 > for (T0,)
534 {
535 #[inline]
536 unsafe fn encode(
537 self,
538 encoder: &mut fidl::encoding::Encoder<
539 '_,
540 fidl::encoding::DefaultFuchsiaResourceDialect,
541 >,
542 offset: usize,
543 depth: fidl::encoding::Depth,
544 ) -> fidl::Result<()> {
545 encoder.debug_check_bounds::<NotifierWatchStateResponse>(offset);
546 self.0.encode(encoder, offset + 0, depth)?;
550 Ok(())
551 }
552 }
553
554 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
555 for NotifierWatchStateResponse
556 {
557 #[inline(always)]
558 fn new_empty() -> Self {
559 Self { state: fidl::new_empty!(State, fidl::encoding::DefaultFuchsiaResourceDialect) }
560 }
561
562 #[inline]
563 unsafe fn decode(
564 &mut self,
565 decoder: &mut fidl::encoding::Decoder<
566 '_,
567 fidl::encoding::DefaultFuchsiaResourceDialect,
568 >,
569 offset: usize,
570 _depth: fidl::encoding::Depth,
571 ) -> fidl::Result<()> {
572 decoder.debug_check_bounds::<Self>(offset);
573 fidl::decode!(
575 State,
576 fidl::encoding::DefaultFuchsiaResourceDialect,
577 &mut self.state,
578 decoder,
579 offset + 0,
580 _depth
581 )?;
582 Ok(())
583 }
584 }
585}