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