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_keyboard_focus__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ControllerNotifyRequest {
16 pub view_ref: fidl_fuchsia_ui_views::ViewRef,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ControllerNotifyRequest {}
20
21#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
22pub struct ControllerMarker;
23
24impl fidl::endpoints::ProtocolMarker for ControllerMarker {
25 type Proxy = ControllerProxy;
26 type RequestStream = ControllerRequestStream;
27 #[cfg(target_os = "fuchsia")]
28 type SynchronousProxy = ControllerSynchronousProxy;
29
30 const DEBUG_NAME: &'static str = "fuchsia.ui.keyboard.focus.Controller";
31}
32impl fidl::endpoints::DiscoverableProtocolMarker for ControllerMarker {}
33
34pub trait ControllerProxyInterface: Send + Sync {
35 type NotifyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
36 fn r#notify(&self, view_ref: fidl_fuchsia_ui_views::ViewRef) -> Self::NotifyResponseFut;
37}
38#[derive(Debug)]
39#[cfg(target_os = "fuchsia")]
40pub struct ControllerSynchronousProxy {
41 client: fidl::client::sync::Client,
42}
43
44#[cfg(target_os = "fuchsia")]
45impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
46 type Proxy = ControllerProxy;
47 type Protocol = ControllerMarker;
48
49 fn from_channel(inner: fidl::Channel) -> Self {
50 Self::new(inner)
51 }
52
53 fn into_channel(self) -> fidl::Channel {
54 self.client.into_channel()
55 }
56
57 fn as_channel(&self) -> &fidl::Channel {
58 self.client.as_channel()
59 }
60}
61
62#[cfg(target_os = "fuchsia")]
63impl ControllerSynchronousProxy {
64 pub fn new(channel: fidl::Channel) -> Self {
65 let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
66 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
67 }
68
69 pub fn into_channel(self) -> fidl::Channel {
70 self.client.into_channel()
71 }
72
73 pub fn wait_for_event(
76 &self,
77 deadline: zx::MonotonicInstant,
78 ) -> Result<ControllerEvent, fidl::Error> {
79 ControllerEvent::decode(self.client.wait_for_event(deadline)?)
80 }
81
82 pub fn r#notify(
97 &self,
98 mut view_ref: fidl_fuchsia_ui_views::ViewRef,
99 ___deadline: zx::MonotonicInstant,
100 ) -> Result<(), fidl::Error> {
101 let _response =
102 self.client.send_query::<ControllerNotifyRequest, fidl::encoding::EmptyPayload>(
103 (&mut view_ref,),
104 0xdab35302eed5de5,
105 fidl::encoding::DynamicFlags::empty(),
106 ___deadline,
107 )?;
108 Ok(_response)
109 }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl From<ControllerSynchronousProxy> for zx::Handle {
114 fn from(value: ControllerSynchronousProxy) -> Self {
115 value.into_channel().into()
116 }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl From<fidl::Channel> for ControllerSynchronousProxy {
121 fn from(value: fidl::Channel) -> Self {
122 Self::new(value)
123 }
124}
125
126#[cfg(target_os = "fuchsia")]
127impl fidl::endpoints::FromClient for ControllerSynchronousProxy {
128 type Protocol = ControllerMarker;
129
130 fn from_client(value: fidl::endpoints::ClientEnd<ControllerMarker>) -> Self {
131 Self::new(value.into_channel())
132 }
133}
134
135#[derive(Debug, Clone)]
136pub struct ControllerProxy {
137 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
138}
139
140impl fidl::endpoints::Proxy for ControllerProxy {
141 type Protocol = ControllerMarker;
142
143 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
144 Self::new(inner)
145 }
146
147 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
148 self.client.into_channel().map_err(|client| Self { client })
149 }
150
151 fn as_channel(&self) -> &::fidl::AsyncChannel {
152 self.client.as_channel()
153 }
154}
155
156impl ControllerProxy {
157 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
159 let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
160 Self { client: fidl::client::Client::new(channel, protocol_name) }
161 }
162
163 pub fn take_event_stream(&self) -> ControllerEventStream {
169 ControllerEventStream { event_receiver: self.client.take_event_receiver() }
170 }
171
172 pub fn r#notify(
187 &self,
188 mut view_ref: fidl_fuchsia_ui_views::ViewRef,
189 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
190 ControllerProxyInterface::r#notify(self, view_ref)
191 }
192}
193
194impl ControllerProxyInterface for ControllerProxy {
195 type NotifyResponseFut =
196 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
197 fn r#notify(&self, mut view_ref: fidl_fuchsia_ui_views::ViewRef) -> Self::NotifyResponseFut {
198 fn _decode(
199 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
200 ) -> Result<(), fidl::Error> {
201 let _response = fidl::client::decode_transaction_body::<
202 fidl::encoding::EmptyPayload,
203 fidl::encoding::DefaultFuchsiaResourceDialect,
204 0xdab35302eed5de5,
205 >(_buf?)?;
206 Ok(_response)
207 }
208 self.client.send_query_and_decode::<ControllerNotifyRequest, ()>(
209 (&mut view_ref,),
210 0xdab35302eed5de5,
211 fidl::encoding::DynamicFlags::empty(),
212 _decode,
213 )
214 }
215}
216
217pub struct ControllerEventStream {
218 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
219}
220
221impl std::marker::Unpin for ControllerEventStream {}
222
223impl futures::stream::FusedStream for ControllerEventStream {
224 fn is_terminated(&self) -> bool {
225 self.event_receiver.is_terminated()
226 }
227}
228
229impl futures::Stream for ControllerEventStream {
230 type Item = Result<ControllerEvent, fidl::Error>;
231
232 fn poll_next(
233 mut self: std::pin::Pin<&mut Self>,
234 cx: &mut std::task::Context<'_>,
235 ) -> std::task::Poll<Option<Self::Item>> {
236 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
237 &mut self.event_receiver,
238 cx
239 )?) {
240 Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
241 None => std::task::Poll::Ready(None),
242 }
243 }
244}
245
246#[derive(Debug)]
247pub enum ControllerEvent {}
248
249impl ControllerEvent {
250 fn decode(
252 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
253 ) -> Result<ControllerEvent, fidl::Error> {
254 let (bytes, _handles) = buf.split_mut();
255 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
256 debug_assert_eq!(tx_header.tx_id, 0);
257 match tx_header.ordinal {
258 _ => Err(fidl::Error::UnknownOrdinal {
259 ordinal: tx_header.ordinal,
260 protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
261 }),
262 }
263 }
264}
265
266pub struct ControllerRequestStream {
268 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
269 is_terminated: bool,
270}
271
272impl std::marker::Unpin for ControllerRequestStream {}
273
274impl futures::stream::FusedStream for ControllerRequestStream {
275 fn is_terminated(&self) -> bool {
276 self.is_terminated
277 }
278}
279
280impl fidl::endpoints::RequestStream for ControllerRequestStream {
281 type Protocol = ControllerMarker;
282 type ControlHandle = ControllerControlHandle;
283
284 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
285 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
286 }
287
288 fn control_handle(&self) -> Self::ControlHandle {
289 ControllerControlHandle { inner: self.inner.clone() }
290 }
291
292 fn into_inner(
293 self,
294 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
295 {
296 (self.inner, self.is_terminated)
297 }
298
299 fn from_inner(
300 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
301 is_terminated: bool,
302 ) -> Self {
303 Self { inner, is_terminated }
304 }
305}
306
307impl futures::Stream for ControllerRequestStream {
308 type Item = Result<ControllerRequest, fidl::Error>;
309
310 fn poll_next(
311 mut self: std::pin::Pin<&mut Self>,
312 cx: &mut std::task::Context<'_>,
313 ) -> std::task::Poll<Option<Self::Item>> {
314 let this = &mut *self;
315 if this.inner.check_shutdown(cx) {
316 this.is_terminated = true;
317 return std::task::Poll::Ready(None);
318 }
319 if this.is_terminated {
320 panic!("polled ControllerRequestStream after completion");
321 }
322 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
323 |bytes, handles| {
324 match this.inner.channel().read_etc(cx, bytes, handles) {
325 std::task::Poll::Ready(Ok(())) => {}
326 std::task::Poll::Pending => return std::task::Poll::Pending,
327 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
328 this.is_terminated = true;
329 return std::task::Poll::Ready(None);
330 }
331 std::task::Poll::Ready(Err(e)) => {
332 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
333 e.into(),
334 ))))
335 }
336 }
337
338 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
340
341 std::task::Poll::Ready(Some(match header.ordinal {
342 0xdab35302eed5de5 => {
343 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
344 let mut req = fidl::new_empty!(
345 ControllerNotifyRequest,
346 fidl::encoding::DefaultFuchsiaResourceDialect
347 );
348 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerNotifyRequest>(&header, _body_bytes, handles, &mut req)?;
349 let control_handle = ControllerControlHandle { inner: this.inner.clone() };
350 Ok(ControllerRequest::Notify {
351 view_ref: req.view_ref,
352
353 responder: ControllerNotifyResponder {
354 control_handle: std::mem::ManuallyDrop::new(control_handle),
355 tx_id: header.tx_id,
356 },
357 })
358 }
359 _ => Err(fidl::Error::UnknownOrdinal {
360 ordinal: header.ordinal,
361 protocol_name:
362 <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
363 }),
364 }))
365 },
366 )
367 }
368}
369
370#[derive(Debug)]
383pub enum ControllerRequest {
384 Notify { view_ref: fidl_fuchsia_ui_views::ViewRef, responder: ControllerNotifyResponder },
399}
400
401impl ControllerRequest {
402 #[allow(irrefutable_let_patterns)]
403 pub fn into_notify(
404 self,
405 ) -> Option<(fidl_fuchsia_ui_views::ViewRef, ControllerNotifyResponder)> {
406 if let ControllerRequest::Notify { view_ref, responder } = self {
407 Some((view_ref, responder))
408 } else {
409 None
410 }
411 }
412
413 pub fn method_name(&self) -> &'static str {
415 match *self {
416 ControllerRequest::Notify { .. } => "notify",
417 }
418 }
419}
420
421#[derive(Debug, Clone)]
422pub struct ControllerControlHandle {
423 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
424}
425
426impl fidl::endpoints::ControlHandle for ControllerControlHandle {
427 fn shutdown(&self) {
428 self.inner.shutdown()
429 }
430 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
431 self.inner.shutdown_with_epitaph(status)
432 }
433
434 fn is_closed(&self) -> bool {
435 self.inner.channel().is_closed()
436 }
437 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
438 self.inner.channel().on_closed()
439 }
440
441 #[cfg(target_os = "fuchsia")]
442 fn signal_peer(
443 &self,
444 clear_mask: zx::Signals,
445 set_mask: zx::Signals,
446 ) -> Result<(), zx_status::Status> {
447 use fidl::Peered;
448 self.inner.channel().signal_peer(clear_mask, set_mask)
449 }
450}
451
452impl ControllerControlHandle {}
453
454#[must_use = "FIDL methods require a response to be sent"]
455#[derive(Debug)]
456pub struct ControllerNotifyResponder {
457 control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
458 tx_id: u32,
459}
460
461impl std::ops::Drop for ControllerNotifyResponder {
465 fn drop(&mut self) {
466 self.control_handle.shutdown();
467 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
469 }
470}
471
472impl fidl::endpoints::Responder for ControllerNotifyResponder {
473 type ControlHandle = ControllerControlHandle;
474
475 fn control_handle(&self) -> &ControllerControlHandle {
476 &self.control_handle
477 }
478
479 fn drop_without_shutdown(mut self) {
480 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
482 std::mem::forget(self);
484 }
485}
486
487impl ControllerNotifyResponder {
488 pub fn send(self) -> Result<(), fidl::Error> {
492 let _result = self.send_raw();
493 if _result.is_err() {
494 self.control_handle.shutdown();
495 }
496 self.drop_without_shutdown();
497 _result
498 }
499
500 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
502 let _result = self.send_raw();
503 self.drop_without_shutdown();
504 _result
505 }
506
507 fn send_raw(&self) -> Result<(), fidl::Error> {
508 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
509 (),
510 self.tx_id,
511 0xdab35302eed5de5,
512 fidl::encoding::DynamicFlags::empty(),
513 )
514 }
515}
516
517mod internal {
518 use super::*;
519
520 impl fidl::encoding::ResourceTypeMarker for ControllerNotifyRequest {
521 type Borrowed<'a> = &'a mut Self;
522 fn take_or_borrow<'a>(
523 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
524 ) -> Self::Borrowed<'a> {
525 value
526 }
527 }
528
529 unsafe impl fidl::encoding::TypeMarker for ControllerNotifyRequest {
530 type Owned = Self;
531
532 #[inline(always)]
533 fn inline_align(_context: fidl::encoding::Context) -> usize {
534 4
535 }
536
537 #[inline(always)]
538 fn inline_size(_context: fidl::encoding::Context) -> usize {
539 4
540 }
541 }
542
543 unsafe impl
544 fidl::encoding::Encode<
545 ControllerNotifyRequest,
546 fidl::encoding::DefaultFuchsiaResourceDialect,
547 > for &mut ControllerNotifyRequest
548 {
549 #[inline]
550 unsafe fn encode(
551 self,
552 encoder: &mut fidl::encoding::Encoder<
553 '_,
554 fidl::encoding::DefaultFuchsiaResourceDialect,
555 >,
556 offset: usize,
557 _depth: fidl::encoding::Depth,
558 ) -> fidl::Result<()> {
559 encoder.debug_check_bounds::<ControllerNotifyRequest>(offset);
560 fidl::encoding::Encode::<ControllerNotifyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
562 (
563 <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_ref),
564 ),
565 encoder, offset, _depth
566 )
567 }
568 }
569 unsafe impl<
570 T0: fidl::encoding::Encode<
571 fidl_fuchsia_ui_views::ViewRef,
572 fidl::encoding::DefaultFuchsiaResourceDialect,
573 >,
574 >
575 fidl::encoding::Encode<
576 ControllerNotifyRequest,
577 fidl::encoding::DefaultFuchsiaResourceDialect,
578 > for (T0,)
579 {
580 #[inline]
581 unsafe fn encode(
582 self,
583 encoder: &mut fidl::encoding::Encoder<
584 '_,
585 fidl::encoding::DefaultFuchsiaResourceDialect,
586 >,
587 offset: usize,
588 depth: fidl::encoding::Depth,
589 ) -> fidl::Result<()> {
590 encoder.debug_check_bounds::<ControllerNotifyRequest>(offset);
591 self.0.encode(encoder, offset + 0, depth)?;
595 Ok(())
596 }
597 }
598
599 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
600 for ControllerNotifyRequest
601 {
602 #[inline(always)]
603 fn new_empty() -> Self {
604 Self {
605 view_ref: fidl::new_empty!(
606 fidl_fuchsia_ui_views::ViewRef,
607 fidl::encoding::DefaultFuchsiaResourceDialect
608 ),
609 }
610 }
611
612 #[inline]
613 unsafe fn decode(
614 &mut self,
615 decoder: &mut fidl::encoding::Decoder<
616 '_,
617 fidl::encoding::DefaultFuchsiaResourceDialect,
618 >,
619 offset: usize,
620 _depth: fidl::encoding::Depth,
621 ) -> fidl::Result<()> {
622 decoder.debug_check_bounds::<Self>(offset);
623 fidl::decode!(
625 fidl_fuchsia_ui_views::ViewRef,
626 fidl::encoding::DefaultFuchsiaResourceDialect,
627 &mut self.view_ref,
628 decoder,
629 offset + 0,
630 _depth
631 )?;
632 Ok(())
633 }
634 }
635}