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