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_scope_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct RegistryRegisterScopedViewTreeWatcherRequest {
16 pub context_view: u64,
17 pub watcher:
18 fidl::endpoints::ServerEnd<fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker>,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
22 for RegistryRegisterScopedViewTreeWatcherRequest
23{
24}
25
26#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
27pub struct RegistryMarker;
28
29impl fidl::endpoints::ProtocolMarker for RegistryMarker {
30 type Proxy = RegistryProxy;
31 type RequestStream = RegistryRequestStream;
32 #[cfg(target_os = "fuchsia")]
33 type SynchronousProxy = RegistrySynchronousProxy;
34
35 const DEBUG_NAME: &'static str = "fuchsia.ui.observation.scope.Registry";
36}
37impl fidl::endpoints::DiscoverableProtocolMarker for RegistryMarker {}
38
39pub trait RegistryProxyInterface: Send + Sync {
40 type RegisterScopedViewTreeWatcherResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
41 + Send;
42 fn r#register_scoped_view_tree_watcher(
43 &self,
44 context_view: u64,
45 watcher: fidl::endpoints::ServerEnd<
46 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
47 >,
48 ) -> Self::RegisterScopedViewTreeWatcherResponseFut;
49}
50#[derive(Debug)]
51#[cfg(target_os = "fuchsia")]
52pub struct RegistrySynchronousProxy {
53 client: fidl::client::sync::Client,
54}
55
56#[cfg(target_os = "fuchsia")]
57impl fidl::endpoints::SynchronousProxy for RegistrySynchronousProxy {
58 type Proxy = RegistryProxy;
59 type Protocol = RegistryMarker;
60
61 fn from_channel(inner: fidl::Channel) -> Self {
62 Self::new(inner)
63 }
64
65 fn into_channel(self) -> fidl::Channel {
66 self.client.into_channel()
67 }
68
69 fn as_channel(&self) -> &fidl::Channel {
70 self.client.as_channel()
71 }
72}
73
74#[cfg(target_os = "fuchsia")]
75impl RegistrySynchronousProxy {
76 pub fn new(channel: fidl::Channel) -> Self {
77 let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
78 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
79 }
80
81 pub fn into_channel(self) -> fidl::Channel {
82 self.client.into_channel()
83 }
84
85 pub fn wait_for_event(
88 &self,
89 deadline: zx::MonotonicInstant,
90 ) -> Result<RegistryEvent, fidl::Error> {
91 RegistryEvent::decode(self.client.wait_for_event(deadline)?)
92 }
93
94 pub fn r#register_scoped_view_tree_watcher(
122 &self,
123 mut context_view: u64,
124 mut watcher: fidl::endpoints::ServerEnd<
125 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
126 >,
127 ___deadline: zx::MonotonicInstant,
128 ) -> Result<(), fidl::Error> {
129 let _response = self.client.send_query::<
130 RegistryRegisterScopedViewTreeWatcherRequest,
131 fidl::encoding::EmptyPayload,
132 >(
133 (context_view, watcher,),
134 0x7fcb9e2fd95ffc3d,
135 fidl::encoding::DynamicFlags::empty(),
136 ___deadline,
137 )?;
138 Ok(_response)
139 }
140}
141
142#[cfg(target_os = "fuchsia")]
143impl From<RegistrySynchronousProxy> for zx::Handle {
144 fn from(value: RegistrySynchronousProxy) -> Self {
145 value.into_channel().into()
146 }
147}
148
149#[cfg(target_os = "fuchsia")]
150impl From<fidl::Channel> for RegistrySynchronousProxy {
151 fn from(value: fidl::Channel) -> Self {
152 Self::new(value)
153 }
154}
155
156#[derive(Debug, Clone)]
157pub struct RegistryProxy {
158 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
159}
160
161impl fidl::endpoints::Proxy for RegistryProxy {
162 type Protocol = RegistryMarker;
163
164 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
165 Self::new(inner)
166 }
167
168 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
169 self.client.into_channel().map_err(|client| Self { client })
170 }
171
172 fn as_channel(&self) -> &::fidl::AsyncChannel {
173 self.client.as_channel()
174 }
175}
176
177impl RegistryProxy {
178 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
180 let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
181 Self { client: fidl::client::Client::new(channel, protocol_name) }
182 }
183
184 pub fn take_event_stream(&self) -> RegistryEventStream {
190 RegistryEventStream { event_receiver: self.client.take_event_receiver() }
191 }
192
193 pub fn r#register_scoped_view_tree_watcher(
221 &self,
222 mut context_view: u64,
223 mut watcher: fidl::endpoints::ServerEnd<
224 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
225 >,
226 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
227 RegistryProxyInterface::r#register_scoped_view_tree_watcher(self, context_view, watcher)
228 }
229}
230
231impl RegistryProxyInterface for RegistryProxy {
232 type RegisterScopedViewTreeWatcherResponseFut =
233 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
234 fn r#register_scoped_view_tree_watcher(
235 &self,
236 mut context_view: u64,
237 mut watcher: fidl::endpoints::ServerEnd<
238 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
239 >,
240 ) -> Self::RegisterScopedViewTreeWatcherResponseFut {
241 fn _decode(
242 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
243 ) -> Result<(), fidl::Error> {
244 let _response = fidl::client::decode_transaction_body::<
245 fidl::encoding::EmptyPayload,
246 fidl::encoding::DefaultFuchsiaResourceDialect,
247 0x7fcb9e2fd95ffc3d,
248 >(_buf?)?;
249 Ok(_response)
250 }
251 self.client.send_query_and_decode::<RegistryRegisterScopedViewTreeWatcherRequest, ()>(
252 (context_view, watcher),
253 0x7fcb9e2fd95ffc3d,
254 fidl::encoding::DynamicFlags::empty(),
255 _decode,
256 )
257 }
258}
259
260pub struct RegistryEventStream {
261 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
262}
263
264impl std::marker::Unpin for RegistryEventStream {}
265
266impl futures::stream::FusedStream for RegistryEventStream {
267 fn is_terminated(&self) -> bool {
268 self.event_receiver.is_terminated()
269 }
270}
271
272impl futures::Stream for RegistryEventStream {
273 type Item = Result<RegistryEvent, fidl::Error>;
274
275 fn poll_next(
276 mut self: std::pin::Pin<&mut Self>,
277 cx: &mut std::task::Context<'_>,
278 ) -> std::task::Poll<Option<Self::Item>> {
279 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
280 &mut self.event_receiver,
281 cx
282 )?) {
283 Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
284 None => std::task::Poll::Ready(None),
285 }
286 }
287}
288
289#[derive(Debug)]
290pub enum RegistryEvent {}
291
292impl RegistryEvent {
293 fn decode(
295 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
296 ) -> Result<RegistryEvent, fidl::Error> {
297 let (bytes, _handles) = buf.split_mut();
298 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
299 debug_assert_eq!(tx_header.tx_id, 0);
300 match tx_header.ordinal {
301 _ => Err(fidl::Error::UnknownOrdinal {
302 ordinal: tx_header.ordinal,
303 protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
304 }),
305 }
306 }
307}
308
309pub struct RegistryRequestStream {
311 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
312 is_terminated: bool,
313}
314
315impl std::marker::Unpin for RegistryRequestStream {}
316
317impl futures::stream::FusedStream for RegistryRequestStream {
318 fn is_terminated(&self) -> bool {
319 self.is_terminated
320 }
321}
322
323impl fidl::endpoints::RequestStream for RegistryRequestStream {
324 type Protocol = RegistryMarker;
325 type ControlHandle = RegistryControlHandle;
326
327 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
328 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
329 }
330
331 fn control_handle(&self) -> Self::ControlHandle {
332 RegistryControlHandle { inner: self.inner.clone() }
333 }
334
335 fn into_inner(
336 self,
337 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
338 {
339 (self.inner, self.is_terminated)
340 }
341
342 fn from_inner(
343 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
344 is_terminated: bool,
345 ) -> Self {
346 Self { inner, is_terminated }
347 }
348}
349
350impl futures::Stream for RegistryRequestStream {
351 type Item = Result<RegistryRequest, fidl::Error>;
352
353 fn poll_next(
354 mut self: std::pin::Pin<&mut Self>,
355 cx: &mut std::task::Context<'_>,
356 ) -> std::task::Poll<Option<Self::Item>> {
357 let this = &mut *self;
358 if this.inner.check_shutdown(cx) {
359 this.is_terminated = true;
360 return std::task::Poll::Ready(None);
361 }
362 if this.is_terminated {
363 panic!("polled RegistryRequestStream after completion");
364 }
365 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
366 |bytes, handles| {
367 match this.inner.channel().read_etc(cx, bytes, handles) {
368 std::task::Poll::Ready(Ok(())) => {}
369 std::task::Poll::Pending => return std::task::Poll::Pending,
370 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
371 this.is_terminated = true;
372 return std::task::Poll::Ready(None);
373 }
374 std::task::Poll::Ready(Err(e)) => {
375 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
376 e.into(),
377 ))))
378 }
379 }
380
381 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
383
384 std::task::Poll::Ready(Some(match header.ordinal {
385 0x7fcb9e2fd95ffc3d => {
386 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
387 let mut req = fidl::new_empty!(
388 RegistryRegisterScopedViewTreeWatcherRequest,
389 fidl::encoding::DefaultFuchsiaResourceDialect
390 );
391 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterScopedViewTreeWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
392 let control_handle = RegistryControlHandle { inner: this.inner.clone() };
393 Ok(RegistryRequest::RegisterScopedViewTreeWatcher {
394 context_view: req.context_view,
395 watcher: req.watcher,
396
397 responder: RegistryRegisterScopedViewTreeWatcherResponder {
398 control_handle: std::mem::ManuallyDrop::new(control_handle),
399 tx_id: header.tx_id,
400 },
401 })
402 }
403 _ => Err(fidl::Error::UnknownOrdinal {
404 ordinal: header.ordinal,
405 protocol_name:
406 <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
407 }),
408 }))
409 },
410 )
411 }
412}
413
414#[derive(Debug)]
423pub enum RegistryRequest {
424 RegisterScopedViewTreeWatcher {
452 context_view: u64,
453 watcher:
454 fidl::endpoints::ServerEnd<fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker>,
455 responder: RegistryRegisterScopedViewTreeWatcherResponder,
456 },
457}
458
459impl RegistryRequest {
460 #[allow(irrefutable_let_patterns)]
461 pub fn into_register_scoped_view_tree_watcher(
462 self,
463 ) -> Option<(
464 u64,
465 fidl::endpoints::ServerEnd<fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker>,
466 RegistryRegisterScopedViewTreeWatcherResponder,
467 )> {
468 if let RegistryRequest::RegisterScopedViewTreeWatcher { context_view, watcher, responder } =
469 self
470 {
471 Some((context_view, watcher, responder))
472 } else {
473 None
474 }
475 }
476
477 pub fn method_name(&self) -> &'static str {
479 match *self {
480 RegistryRequest::RegisterScopedViewTreeWatcher { .. } => {
481 "register_scoped_view_tree_watcher"
482 }
483 }
484 }
485}
486
487#[derive(Debug, Clone)]
488pub struct RegistryControlHandle {
489 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
490}
491
492impl fidl::endpoints::ControlHandle for RegistryControlHandle {
493 fn shutdown(&self) {
494 self.inner.shutdown()
495 }
496 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
497 self.inner.shutdown_with_epitaph(status)
498 }
499
500 fn is_closed(&self) -> bool {
501 self.inner.channel().is_closed()
502 }
503 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
504 self.inner.channel().on_closed()
505 }
506
507 #[cfg(target_os = "fuchsia")]
508 fn signal_peer(
509 &self,
510 clear_mask: zx::Signals,
511 set_mask: zx::Signals,
512 ) -> Result<(), zx_status::Status> {
513 use fidl::Peered;
514 self.inner.channel().signal_peer(clear_mask, set_mask)
515 }
516}
517
518impl RegistryControlHandle {}
519
520#[must_use = "FIDL methods require a response to be sent"]
521#[derive(Debug)]
522pub struct RegistryRegisterScopedViewTreeWatcherResponder {
523 control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
524 tx_id: u32,
525}
526
527impl std::ops::Drop for RegistryRegisterScopedViewTreeWatcherResponder {
531 fn drop(&mut self) {
532 self.control_handle.shutdown();
533 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
535 }
536}
537
538impl fidl::endpoints::Responder for RegistryRegisterScopedViewTreeWatcherResponder {
539 type ControlHandle = RegistryControlHandle;
540
541 fn control_handle(&self) -> &RegistryControlHandle {
542 &self.control_handle
543 }
544
545 fn drop_without_shutdown(mut self) {
546 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
548 std::mem::forget(self);
550 }
551}
552
553impl RegistryRegisterScopedViewTreeWatcherResponder {
554 pub fn send(self) -> Result<(), fidl::Error> {
558 let _result = self.send_raw();
559 if _result.is_err() {
560 self.control_handle.shutdown();
561 }
562 self.drop_without_shutdown();
563 _result
564 }
565
566 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
568 let _result = self.send_raw();
569 self.drop_without_shutdown();
570 _result
571 }
572
573 fn send_raw(&self) -> Result<(), fidl::Error> {
574 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
575 (),
576 self.tx_id,
577 0x7fcb9e2fd95ffc3d,
578 fidl::encoding::DynamicFlags::empty(),
579 )
580 }
581}
582
583mod internal {
584 use super::*;
585
586 impl fidl::encoding::ResourceTypeMarker for RegistryRegisterScopedViewTreeWatcherRequest {
587 type Borrowed<'a> = &'a mut Self;
588 fn take_or_borrow<'a>(
589 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
590 ) -> Self::Borrowed<'a> {
591 value
592 }
593 }
594
595 unsafe impl fidl::encoding::TypeMarker for RegistryRegisterScopedViewTreeWatcherRequest {
596 type Owned = Self;
597
598 #[inline(always)]
599 fn inline_align(_context: fidl::encoding::Context) -> usize {
600 8
601 }
602
603 #[inline(always)]
604 fn inline_size(_context: fidl::encoding::Context) -> usize {
605 16
606 }
607 }
608
609 unsafe impl
610 fidl::encoding::Encode<
611 RegistryRegisterScopedViewTreeWatcherRequest,
612 fidl::encoding::DefaultFuchsiaResourceDialect,
613 > for &mut RegistryRegisterScopedViewTreeWatcherRequest
614 {
615 #[inline]
616 unsafe fn encode(
617 self,
618 encoder: &mut fidl::encoding::Encoder<
619 '_,
620 fidl::encoding::DefaultFuchsiaResourceDialect,
621 >,
622 offset: usize,
623 _depth: fidl::encoding::Depth,
624 ) -> fidl::Result<()> {
625 encoder.debug_check_bounds::<RegistryRegisterScopedViewTreeWatcherRequest>(offset);
626 fidl::encoding::Encode::<
628 RegistryRegisterScopedViewTreeWatcherRequest,
629 fidl::encoding::DefaultFuchsiaResourceDialect,
630 >::encode(
631 (
632 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.context_view),
633 <fidl::encoding::Endpoint<
634 fidl::endpoints::ServerEnd<
635 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
636 >,
637 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
638 &mut self.watcher
639 ),
640 ),
641 encoder,
642 offset,
643 _depth,
644 )
645 }
646 }
647 unsafe impl<
648 T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
649 T1: fidl::encoding::Encode<
650 fidl::encoding::Endpoint<
651 fidl::endpoints::ServerEnd<
652 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
653 >,
654 >,
655 fidl::encoding::DefaultFuchsiaResourceDialect,
656 >,
657 >
658 fidl::encoding::Encode<
659 RegistryRegisterScopedViewTreeWatcherRequest,
660 fidl::encoding::DefaultFuchsiaResourceDialect,
661 > for (T0, T1)
662 {
663 #[inline]
664 unsafe fn encode(
665 self,
666 encoder: &mut fidl::encoding::Encoder<
667 '_,
668 fidl::encoding::DefaultFuchsiaResourceDialect,
669 >,
670 offset: usize,
671 depth: fidl::encoding::Depth,
672 ) -> fidl::Result<()> {
673 encoder.debug_check_bounds::<RegistryRegisterScopedViewTreeWatcherRequest>(offset);
674 unsafe {
677 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
678 (ptr as *mut u64).write_unaligned(0);
679 }
680 self.0.encode(encoder, offset + 0, depth)?;
682 self.1.encode(encoder, offset + 8, depth)?;
683 Ok(())
684 }
685 }
686
687 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
688 for RegistryRegisterScopedViewTreeWatcherRequest
689 {
690 #[inline(always)]
691 fn new_empty() -> Self {
692 Self {
693 context_view: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
694 watcher: fidl::new_empty!(
695 fidl::encoding::Endpoint<
696 fidl::endpoints::ServerEnd<
697 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
698 >,
699 >,
700 fidl::encoding::DefaultFuchsiaResourceDialect
701 ),
702 }
703 }
704
705 #[inline]
706 unsafe fn decode(
707 &mut self,
708 decoder: &mut fidl::encoding::Decoder<
709 '_,
710 fidl::encoding::DefaultFuchsiaResourceDialect,
711 >,
712 offset: usize,
713 _depth: fidl::encoding::Depth,
714 ) -> fidl::Result<()> {
715 decoder.debug_check_bounds::<Self>(offset);
716 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
718 let padval = unsafe { (ptr as *const u64).read_unaligned() };
719 let mask = 0xffffffff00000000u64;
720 let maskedval = padval & mask;
721 if maskedval != 0 {
722 return Err(fidl::Error::NonZeroPadding {
723 padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
724 });
725 }
726 fidl::decode!(
727 u64,
728 fidl::encoding::DefaultFuchsiaResourceDialect,
729 &mut self.context_view,
730 decoder,
731 offset + 0,
732 _depth
733 )?;
734 fidl::decode!(
735 fidl::encoding::Endpoint<
736 fidl::endpoints::ServerEnd<
737 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
738 >,
739 >,
740 fidl::encoding::DefaultFuchsiaResourceDialect,
741 &mut self.watcher,
742 decoder,
743 offset + 8,
744 _depth
745 )?;
746 Ok(())
747 }
748 }
749}