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 { Some((responder)) } else { None }
364 }
365
366 pub fn method_name(&self) -> &'static str {
368 match *self {
369 NotifierRequest::WatchState { .. } => "watch_state",
370 }
371 }
372}
373
374#[derive(Debug, Clone)]
375pub struct NotifierControlHandle {
376 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
377}
378
379impl fidl::endpoints::ControlHandle for NotifierControlHandle {
380 fn shutdown(&self) {
381 self.inner.shutdown()
382 }
383 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
384 self.inner.shutdown_with_epitaph(status)
385 }
386
387 fn is_closed(&self) -> bool {
388 self.inner.channel().is_closed()
389 }
390 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
391 self.inner.channel().on_closed()
392 }
393
394 #[cfg(target_os = "fuchsia")]
395 fn signal_peer(
396 &self,
397 clear_mask: zx::Signals,
398 set_mask: zx::Signals,
399 ) -> Result<(), zx_status::Status> {
400 use fidl::Peered;
401 self.inner.channel().signal_peer(clear_mask, set_mask)
402 }
403}
404
405impl NotifierControlHandle {}
406
407#[must_use = "FIDL methods require a response to be sent"]
408#[derive(Debug)]
409pub struct NotifierWatchStateResponder {
410 control_handle: std::mem::ManuallyDrop<NotifierControlHandle>,
411 tx_id: u32,
412}
413
414impl std::ops::Drop for NotifierWatchStateResponder {
418 fn drop(&mut self) {
419 self.control_handle.shutdown();
420 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
422 }
423}
424
425impl fidl::endpoints::Responder for NotifierWatchStateResponder {
426 type ControlHandle = NotifierControlHandle;
427
428 fn control_handle(&self) -> &NotifierControlHandle {
429 &self.control_handle
430 }
431
432 fn drop_without_shutdown(mut self) {
433 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
435 std::mem::forget(self);
437 }
438}
439
440impl NotifierWatchStateResponder {
441 pub fn send(self, mut state: State) -> Result<(), fidl::Error> {
445 let _result = self.send_raw(state);
446 if _result.is_err() {
447 self.control_handle.shutdown();
448 }
449 self.drop_without_shutdown();
450 _result
451 }
452
453 pub fn send_no_shutdown_on_err(self, mut state: State) -> Result<(), fidl::Error> {
455 let _result = self.send_raw(state);
456 self.drop_without_shutdown();
457 _result
458 }
459
460 fn send_raw(&self, mut state: State) -> Result<(), fidl::Error> {
461 self.control_handle.inner.send::<NotifierWatchStateResponse>(
462 (state,),
463 self.tx_id,
464 0xf379d6bc002e8ee,
465 fidl::encoding::DynamicFlags::empty(),
466 )
467 }
468}
469
470mod internal {
471 use super::*;
472
473 impl fidl::encoding::ResourceTypeMarker for NotifierWatchStateResponse {
474 type Borrowed<'a> = &'a mut Self;
475 fn take_or_borrow<'a>(
476 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
477 ) -> Self::Borrowed<'a> {
478 value
479 }
480 }
481
482 unsafe impl fidl::encoding::TypeMarker for NotifierWatchStateResponse {
483 type Owned = Self;
484
485 #[inline(always)]
486 fn inline_align(_context: fidl::encoding::Context) -> usize {
487 4
488 }
489
490 #[inline(always)]
491 fn inline_size(_context: fidl::encoding::Context) -> usize {
492 4
493 }
494 }
495
496 unsafe impl
497 fidl::encoding::Encode<
498 NotifierWatchStateResponse,
499 fidl::encoding::DefaultFuchsiaResourceDialect,
500 > for &mut NotifierWatchStateResponse
501 {
502 #[inline]
503 unsafe fn encode(
504 self,
505 encoder: &mut fidl::encoding::Encoder<
506 '_,
507 fidl::encoding::DefaultFuchsiaResourceDialect,
508 >,
509 offset: usize,
510 _depth: fidl::encoding::Depth,
511 ) -> fidl::Result<()> {
512 encoder.debug_check_bounds::<NotifierWatchStateResponse>(offset);
513 fidl::encoding::Encode::<
515 NotifierWatchStateResponse,
516 fidl::encoding::DefaultFuchsiaResourceDialect,
517 >::encode(
518 (<State as fidl::encoding::ValueTypeMarker>::borrow(&self.state),),
519 encoder,
520 offset,
521 _depth,
522 )
523 }
524 }
525 unsafe impl<T0: fidl::encoding::Encode<State, fidl::encoding::DefaultFuchsiaResourceDialect>>
526 fidl::encoding::Encode<
527 NotifierWatchStateResponse,
528 fidl::encoding::DefaultFuchsiaResourceDialect,
529 > for (T0,)
530 {
531 #[inline]
532 unsafe fn encode(
533 self,
534 encoder: &mut fidl::encoding::Encoder<
535 '_,
536 fidl::encoding::DefaultFuchsiaResourceDialect,
537 >,
538 offset: usize,
539 depth: fidl::encoding::Depth,
540 ) -> fidl::Result<()> {
541 encoder.debug_check_bounds::<NotifierWatchStateResponse>(offset);
542 self.0.encode(encoder, offset + 0, depth)?;
546 Ok(())
547 }
548 }
549
550 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
551 for NotifierWatchStateResponse
552 {
553 #[inline(always)]
554 fn new_empty() -> Self {
555 Self { state: fidl::new_empty!(State, fidl::encoding::DefaultFuchsiaResourceDialect) }
556 }
557
558 #[inline]
559 unsafe fn decode(
560 &mut self,
561 decoder: &mut fidl::encoding::Decoder<
562 '_,
563 fidl::encoding::DefaultFuchsiaResourceDialect,
564 >,
565 offset: usize,
566 _depth: fidl::encoding::Depth,
567 ) -> fidl::Result<()> {
568 decoder.debug_check_bounds::<Self>(offset);
569 fidl::decode!(
571 State,
572 fidl::encoding::DefaultFuchsiaResourceDialect,
573 &mut self.state,
574 decoder,
575 offset + 0,
576 _depth
577 )?;
578 Ok(())
579 }
580 }
581}