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::NullableHandle {
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
431 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
432 self.inner.shutdown_with_epitaph(status)
433 }
434
435 fn is_closed(&self) -> bool {
436 self.inner.channel().is_closed()
437 }
438 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
439 self.inner.channel().on_closed()
440 }
441
442 #[cfg(target_os = "fuchsia")]
443 fn signal_peer(
444 &self,
445 clear_mask: zx::Signals,
446 set_mask: zx::Signals,
447 ) -> Result<(), zx_status::Status> {
448 use fidl::Peered;
449 self.inner.channel().signal_peer(clear_mask, set_mask)
450 }
451}
452
453impl ControllerControlHandle {}
454
455#[must_use = "FIDL methods require a response to be sent"]
456#[derive(Debug)]
457pub struct ControllerNotifyResponder {
458 control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
459 tx_id: u32,
460}
461
462impl std::ops::Drop for ControllerNotifyResponder {
466 fn drop(&mut self) {
467 self.control_handle.shutdown();
468 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
470 }
471}
472
473impl fidl::endpoints::Responder for ControllerNotifyResponder {
474 type ControlHandle = ControllerControlHandle;
475
476 fn control_handle(&self) -> &ControllerControlHandle {
477 &self.control_handle
478 }
479
480 fn drop_without_shutdown(mut self) {
481 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
483 std::mem::forget(self);
485 }
486}
487
488impl ControllerNotifyResponder {
489 pub fn send(self) -> Result<(), fidl::Error> {
493 let _result = self.send_raw();
494 if _result.is_err() {
495 self.control_handle.shutdown();
496 }
497 self.drop_without_shutdown();
498 _result
499 }
500
501 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
503 let _result = self.send_raw();
504 self.drop_without_shutdown();
505 _result
506 }
507
508 fn send_raw(&self) -> Result<(), fidl::Error> {
509 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
510 (),
511 self.tx_id,
512 0xdab35302eed5de5,
513 fidl::encoding::DynamicFlags::empty(),
514 )
515 }
516}
517
518mod internal {
519 use super::*;
520
521 impl fidl::encoding::ResourceTypeMarker for ControllerNotifyRequest {
522 type Borrowed<'a> = &'a mut Self;
523 fn take_or_borrow<'a>(
524 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
525 ) -> Self::Borrowed<'a> {
526 value
527 }
528 }
529
530 unsafe impl fidl::encoding::TypeMarker for ControllerNotifyRequest {
531 type Owned = Self;
532
533 #[inline(always)]
534 fn inline_align(_context: fidl::encoding::Context) -> usize {
535 4
536 }
537
538 #[inline(always)]
539 fn inline_size(_context: fidl::encoding::Context) -> usize {
540 4
541 }
542 }
543
544 unsafe impl
545 fidl::encoding::Encode<
546 ControllerNotifyRequest,
547 fidl::encoding::DefaultFuchsiaResourceDialect,
548 > for &mut ControllerNotifyRequest
549 {
550 #[inline]
551 unsafe fn encode(
552 self,
553 encoder: &mut fidl::encoding::Encoder<
554 '_,
555 fidl::encoding::DefaultFuchsiaResourceDialect,
556 >,
557 offset: usize,
558 _depth: fidl::encoding::Depth,
559 ) -> fidl::Result<()> {
560 encoder.debug_check_bounds::<ControllerNotifyRequest>(offset);
561 fidl::encoding::Encode::<ControllerNotifyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
563 (
564 <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_ref),
565 ),
566 encoder, offset, _depth
567 )
568 }
569 }
570 unsafe impl<
571 T0: fidl::encoding::Encode<
572 fidl_fuchsia_ui_views::ViewRef,
573 fidl::encoding::DefaultFuchsiaResourceDialect,
574 >,
575 >
576 fidl::encoding::Encode<
577 ControllerNotifyRequest,
578 fidl::encoding::DefaultFuchsiaResourceDialect,
579 > for (T0,)
580 {
581 #[inline]
582 unsafe fn encode(
583 self,
584 encoder: &mut fidl::encoding::Encoder<
585 '_,
586 fidl::encoding::DefaultFuchsiaResourceDialect,
587 >,
588 offset: usize,
589 depth: fidl::encoding::Depth,
590 ) -> fidl::Result<()> {
591 encoder.debug_check_bounds::<ControllerNotifyRequest>(offset);
592 self.0.encode(encoder, offset + 0, depth)?;
596 Ok(())
597 }
598 }
599
600 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
601 for ControllerNotifyRequest
602 {
603 #[inline(always)]
604 fn new_empty() -> Self {
605 Self {
606 view_ref: fidl::new_empty!(
607 fidl_fuchsia_ui_views::ViewRef,
608 fidl::encoding::DefaultFuchsiaResourceDialect
609 ),
610 }
611 }
612
613 #[inline]
614 unsafe fn decode(
615 &mut self,
616 decoder: &mut fidl::encoding::Decoder<
617 '_,
618 fidl::encoding::DefaultFuchsiaResourceDialect,
619 >,
620 offset: usize,
621 _depth: fidl::encoding::Depth,
622 ) -> fidl::Result<()> {
623 decoder.debug_check_bounds::<Self>(offset);
624 fidl::decode!(
626 fidl_fuchsia_ui_views::ViewRef,
627 fidl::encoding::DefaultFuchsiaResourceDialect,
628 &mut self.view_ref,
629 decoder,
630 offset + 0,
631 _depth
632 )?;
633 Ok(())
634 }
635 }
636}