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#[derive(Debug, Clone)]
125pub struct RegistryProxy {
126 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
127}
128
129impl fidl::endpoints::Proxy for RegistryProxy {
130 type Protocol = RegistryMarker;
131
132 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
133 Self::new(inner)
134 }
135
136 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
137 self.client.into_channel().map_err(|client| Self { client })
138 }
139
140 fn as_channel(&self) -> &::fidl::AsyncChannel {
141 self.client.as_channel()
142 }
143}
144
145impl RegistryProxy {
146 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
148 let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
149 Self { client: fidl::client::Client::new(channel, protocol_name) }
150 }
151
152 pub fn take_event_stream(&self) -> RegistryEventStream {
158 RegistryEventStream { event_receiver: self.client.take_event_receiver() }
159 }
160
161 pub fn r#register_global_view_tree_watcher(
174 &self,
175 mut watcher: fidl::endpoints::ServerEnd<
176 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
177 >,
178 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
179 RegistryProxyInterface::r#register_global_view_tree_watcher(self, watcher)
180 }
181}
182
183impl RegistryProxyInterface for RegistryProxy {
184 type RegisterGlobalViewTreeWatcherResponseFut =
185 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
186 fn r#register_global_view_tree_watcher(
187 &self,
188 mut watcher: fidl::endpoints::ServerEnd<
189 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
190 >,
191 ) -> Self::RegisterGlobalViewTreeWatcherResponseFut {
192 fn _decode(
193 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
194 ) -> Result<(), fidl::Error> {
195 let _response = fidl::client::decode_transaction_body::<
196 fidl::encoding::EmptyPayload,
197 fidl::encoding::DefaultFuchsiaResourceDialect,
198 0xf1f7057ba311944,
199 >(_buf?)?;
200 Ok(_response)
201 }
202 self.client.send_query_and_decode::<RegistryRegisterGlobalViewTreeWatcherRequest, ()>(
203 (watcher,),
204 0xf1f7057ba311944,
205 fidl::encoding::DynamicFlags::empty(),
206 _decode,
207 )
208 }
209}
210
211pub struct RegistryEventStream {
212 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
213}
214
215impl std::marker::Unpin for RegistryEventStream {}
216
217impl futures::stream::FusedStream for RegistryEventStream {
218 fn is_terminated(&self) -> bool {
219 self.event_receiver.is_terminated()
220 }
221}
222
223impl futures::Stream for RegistryEventStream {
224 type Item = Result<RegistryEvent, fidl::Error>;
225
226 fn poll_next(
227 mut self: std::pin::Pin<&mut Self>,
228 cx: &mut std::task::Context<'_>,
229 ) -> std::task::Poll<Option<Self::Item>> {
230 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
231 &mut self.event_receiver,
232 cx
233 )?) {
234 Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
235 None => std::task::Poll::Ready(None),
236 }
237 }
238}
239
240#[derive(Debug)]
241pub enum RegistryEvent {}
242
243impl RegistryEvent {
244 fn decode(
246 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
247 ) -> Result<RegistryEvent, fidl::Error> {
248 let (bytes, _handles) = buf.split_mut();
249 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
250 debug_assert_eq!(tx_header.tx_id, 0);
251 match tx_header.ordinal {
252 _ => Err(fidl::Error::UnknownOrdinal {
253 ordinal: tx_header.ordinal,
254 protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
255 }),
256 }
257 }
258}
259
260pub struct RegistryRequestStream {
262 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
263 is_terminated: bool,
264}
265
266impl std::marker::Unpin for RegistryRequestStream {}
267
268impl futures::stream::FusedStream for RegistryRequestStream {
269 fn is_terminated(&self) -> bool {
270 self.is_terminated
271 }
272}
273
274impl fidl::endpoints::RequestStream for RegistryRequestStream {
275 type Protocol = RegistryMarker;
276 type ControlHandle = RegistryControlHandle;
277
278 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
279 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
280 }
281
282 fn control_handle(&self) -> Self::ControlHandle {
283 RegistryControlHandle { inner: self.inner.clone() }
284 }
285
286 fn into_inner(
287 self,
288 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
289 {
290 (self.inner, self.is_terminated)
291 }
292
293 fn from_inner(
294 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
295 is_terminated: bool,
296 ) -> Self {
297 Self { inner, is_terminated }
298 }
299}
300
301impl futures::Stream for RegistryRequestStream {
302 type Item = Result<RegistryRequest, fidl::Error>;
303
304 fn poll_next(
305 mut self: std::pin::Pin<&mut Self>,
306 cx: &mut std::task::Context<'_>,
307 ) -> std::task::Poll<Option<Self::Item>> {
308 let this = &mut *self;
309 if this.inner.check_shutdown(cx) {
310 this.is_terminated = true;
311 return std::task::Poll::Ready(None);
312 }
313 if this.is_terminated {
314 panic!("polled RegistryRequestStream after completion");
315 }
316 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
317 |bytes, handles| {
318 match this.inner.channel().read_etc(cx, bytes, handles) {
319 std::task::Poll::Ready(Ok(())) => {}
320 std::task::Poll::Pending => return std::task::Poll::Pending,
321 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
322 this.is_terminated = true;
323 return std::task::Poll::Ready(None);
324 }
325 std::task::Poll::Ready(Err(e)) => {
326 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
327 e.into(),
328 ))))
329 }
330 }
331
332 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
334
335 std::task::Poll::Ready(Some(match header.ordinal {
336 0xf1f7057ba311944 => {
337 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
338 let mut req = fidl::new_empty!(
339 RegistryRegisterGlobalViewTreeWatcherRequest,
340 fidl::encoding::DefaultFuchsiaResourceDialect
341 );
342 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterGlobalViewTreeWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
343 let control_handle = RegistryControlHandle { inner: this.inner.clone() };
344 Ok(RegistryRequest::RegisterGlobalViewTreeWatcher {
345 watcher: req.watcher,
346
347 responder: RegistryRegisterGlobalViewTreeWatcherResponder {
348 control_handle: std::mem::ManuallyDrop::new(control_handle),
349 tx_id: header.tx_id,
350 },
351 })
352 }
353 _ => Err(fidl::Error::UnknownOrdinal {
354 ordinal: header.ordinal,
355 protocol_name:
356 <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
357 }),
358 }))
359 },
360 )
361 }
362}
363
364#[derive(Debug)]
372pub enum RegistryRequest {
373 RegisterGlobalViewTreeWatcher {
386 watcher:
387 fidl::endpoints::ServerEnd<fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker>,
388 responder: RegistryRegisterGlobalViewTreeWatcherResponder,
389 },
390}
391
392impl RegistryRequest {
393 #[allow(irrefutable_let_patterns)]
394 pub fn into_register_global_view_tree_watcher(
395 self,
396 ) -> Option<(
397 fidl::endpoints::ServerEnd<fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker>,
398 RegistryRegisterGlobalViewTreeWatcherResponder,
399 )> {
400 if let RegistryRequest::RegisterGlobalViewTreeWatcher { watcher, responder } = self {
401 Some((watcher, responder))
402 } else {
403 None
404 }
405 }
406
407 pub fn method_name(&self) -> &'static str {
409 match *self {
410 RegistryRequest::RegisterGlobalViewTreeWatcher { .. } => {
411 "register_global_view_tree_watcher"
412 }
413 }
414 }
415}
416
417#[derive(Debug, Clone)]
418pub struct RegistryControlHandle {
419 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
420}
421
422impl fidl::endpoints::ControlHandle for RegistryControlHandle {
423 fn shutdown(&self) {
424 self.inner.shutdown()
425 }
426 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
427 self.inner.shutdown_with_epitaph(status)
428 }
429
430 fn is_closed(&self) -> bool {
431 self.inner.channel().is_closed()
432 }
433 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
434 self.inner.channel().on_closed()
435 }
436
437 #[cfg(target_os = "fuchsia")]
438 fn signal_peer(
439 &self,
440 clear_mask: zx::Signals,
441 set_mask: zx::Signals,
442 ) -> Result<(), zx_status::Status> {
443 use fidl::Peered;
444 self.inner.channel().signal_peer(clear_mask, set_mask)
445 }
446}
447
448impl RegistryControlHandle {}
449
450#[must_use = "FIDL methods require a response to be sent"]
451#[derive(Debug)]
452pub struct RegistryRegisterGlobalViewTreeWatcherResponder {
453 control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
454 tx_id: u32,
455}
456
457impl std::ops::Drop for RegistryRegisterGlobalViewTreeWatcherResponder {
461 fn drop(&mut self) {
462 self.control_handle.shutdown();
463 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
465 }
466}
467
468impl fidl::endpoints::Responder for RegistryRegisterGlobalViewTreeWatcherResponder {
469 type ControlHandle = RegistryControlHandle;
470
471 fn control_handle(&self) -> &RegistryControlHandle {
472 &self.control_handle
473 }
474
475 fn drop_without_shutdown(mut self) {
476 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
478 std::mem::forget(self);
480 }
481}
482
483impl RegistryRegisterGlobalViewTreeWatcherResponder {
484 pub fn send(self) -> Result<(), fidl::Error> {
488 let _result = self.send_raw();
489 if _result.is_err() {
490 self.control_handle.shutdown();
491 }
492 self.drop_without_shutdown();
493 _result
494 }
495
496 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
498 let _result = self.send_raw();
499 self.drop_without_shutdown();
500 _result
501 }
502
503 fn send_raw(&self) -> Result<(), fidl::Error> {
504 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
505 (),
506 self.tx_id,
507 0xf1f7057ba311944,
508 fidl::encoding::DynamicFlags::empty(),
509 )
510 }
511}
512
513mod internal {
514 use super::*;
515
516 impl fidl::encoding::ResourceTypeMarker for RegistryRegisterGlobalViewTreeWatcherRequest {
517 type Borrowed<'a> = &'a mut Self;
518 fn take_or_borrow<'a>(
519 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
520 ) -> Self::Borrowed<'a> {
521 value
522 }
523 }
524
525 unsafe impl fidl::encoding::TypeMarker for RegistryRegisterGlobalViewTreeWatcherRequest {
526 type Owned = Self;
527
528 #[inline(always)]
529 fn inline_align(_context: fidl::encoding::Context) -> usize {
530 4
531 }
532
533 #[inline(always)]
534 fn inline_size(_context: fidl::encoding::Context) -> usize {
535 4
536 }
537 }
538
539 unsafe impl
540 fidl::encoding::Encode<
541 RegistryRegisterGlobalViewTreeWatcherRequest,
542 fidl::encoding::DefaultFuchsiaResourceDialect,
543 > for &mut RegistryRegisterGlobalViewTreeWatcherRequest
544 {
545 #[inline]
546 unsafe fn encode(
547 self,
548 encoder: &mut fidl::encoding::Encoder<
549 '_,
550 fidl::encoding::DefaultFuchsiaResourceDialect,
551 >,
552 offset: usize,
553 _depth: fidl::encoding::Depth,
554 ) -> fidl::Result<()> {
555 encoder.debug_check_bounds::<RegistryRegisterGlobalViewTreeWatcherRequest>(offset);
556 fidl::encoding::Encode::<
558 RegistryRegisterGlobalViewTreeWatcherRequest,
559 fidl::encoding::DefaultFuchsiaResourceDialect,
560 >::encode(
561 (<fidl::encoding::Endpoint<
562 fidl::endpoints::ServerEnd<
563 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
564 >,
565 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
566 &mut self.watcher
567 ),),
568 encoder,
569 offset,
570 _depth,
571 )
572 }
573 }
574 unsafe impl<
575 T0: fidl::encoding::Encode<
576 fidl::encoding::Endpoint<
577 fidl::endpoints::ServerEnd<
578 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
579 >,
580 >,
581 fidl::encoding::DefaultFuchsiaResourceDialect,
582 >,
583 >
584 fidl::encoding::Encode<
585 RegistryRegisterGlobalViewTreeWatcherRequest,
586 fidl::encoding::DefaultFuchsiaResourceDialect,
587 > for (T0,)
588 {
589 #[inline]
590 unsafe fn encode(
591 self,
592 encoder: &mut fidl::encoding::Encoder<
593 '_,
594 fidl::encoding::DefaultFuchsiaResourceDialect,
595 >,
596 offset: usize,
597 depth: fidl::encoding::Depth,
598 ) -> fidl::Result<()> {
599 encoder.debug_check_bounds::<RegistryRegisterGlobalViewTreeWatcherRequest>(offset);
600 self.0.encode(encoder, offset + 0, depth)?;
604 Ok(())
605 }
606 }
607
608 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
609 for RegistryRegisterGlobalViewTreeWatcherRequest
610 {
611 #[inline(always)]
612 fn new_empty() -> Self {
613 Self {
614 watcher: fidl::new_empty!(
615 fidl::encoding::Endpoint<
616 fidl::endpoints::ServerEnd<
617 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
618 >,
619 >,
620 fidl::encoding::DefaultFuchsiaResourceDialect
621 ),
622 }
623 }
624
625 #[inline]
626 unsafe fn decode(
627 &mut self,
628 decoder: &mut fidl::encoding::Decoder<
629 '_,
630 fidl::encoding::DefaultFuchsiaResourceDialect,
631 >,
632 offset: usize,
633 _depth: fidl::encoding::Depth,
634 ) -> fidl::Result<()> {
635 decoder.debug_check_bounds::<Self>(offset);
636 fidl::decode!(
638 fidl::encoding::Endpoint<
639 fidl::endpoints::ServerEnd<
640 fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
641 >,
642 >,
643 fidl::encoding::DefaultFuchsiaResourceDialect,
644 &mut self.watcher,
645 decoder,
646 offset + 0,
647 _depth
648 )?;
649 Ok(())
650 }
651 }
652}