fidl_fuchsia_ui_observation_geometry/
fidl_fuchsia_ui_observation_geometry.rs1#![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_geometry__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ViewTreeWatcherMarker;
16
17impl fidl::endpoints::ProtocolMarker for ViewTreeWatcherMarker {
18 type Proxy = ViewTreeWatcherProxy;
19 type RequestStream = ViewTreeWatcherRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ViewTreeWatcherSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "(anonymous) ViewTreeWatcher";
24}
25
26pub trait ViewTreeWatcherProxyInterface: Send + Sync {
27 type WatchResponseFut: std::future::Future<Output = Result<WatchResponse, fidl::Error>> + Send;
28 fn r#watch(&self) -> Self::WatchResponseFut;
29}
30#[derive(Debug)]
31#[cfg(target_os = "fuchsia")]
32pub struct ViewTreeWatcherSynchronousProxy {
33 client: fidl::client::sync::Client,
34}
35
36#[cfg(target_os = "fuchsia")]
37impl fidl::endpoints::SynchronousProxy for ViewTreeWatcherSynchronousProxy {
38 type Proxy = ViewTreeWatcherProxy;
39 type Protocol = ViewTreeWatcherMarker;
40
41 fn from_channel(inner: fidl::Channel) -> Self {
42 Self::new(inner)
43 }
44
45 fn into_channel(self) -> fidl::Channel {
46 self.client.into_channel()
47 }
48
49 fn as_channel(&self) -> &fidl::Channel {
50 self.client.as_channel()
51 }
52}
53
54#[cfg(target_os = "fuchsia")]
55impl ViewTreeWatcherSynchronousProxy {
56 pub fn new(channel: fidl::Channel) -> Self {
57 let protocol_name = <ViewTreeWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
58 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
59 }
60
61 pub fn into_channel(self) -> fidl::Channel {
62 self.client.into_channel()
63 }
64
65 pub fn wait_for_event(
68 &self,
69 deadline: zx::MonotonicInstant,
70 ) -> Result<ViewTreeWatcherEvent, fidl::Error> {
71 ViewTreeWatcherEvent::decode(self.client.wait_for_event(deadline)?)
72 }
73
74 pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<WatchResponse, fidl::Error> {
92 let _response = self.client.send_query::<fidl::encoding::EmptyPayload, WatchResponse>(
93 (),
94 0x3c7670983418477b,
95 fidl::encoding::DynamicFlags::empty(),
96 ___deadline,
97 )?;
98 Ok(_response)
99 }
100}
101
102#[cfg(target_os = "fuchsia")]
103impl From<ViewTreeWatcherSynchronousProxy> for zx::Handle {
104 fn from(value: ViewTreeWatcherSynchronousProxy) -> Self {
105 value.into_channel().into()
106 }
107}
108
109#[cfg(target_os = "fuchsia")]
110impl From<fidl::Channel> for ViewTreeWatcherSynchronousProxy {
111 fn from(value: fidl::Channel) -> Self {
112 Self::new(value)
113 }
114}
115
116#[cfg(target_os = "fuchsia")]
117impl fidl::endpoints::FromClient for ViewTreeWatcherSynchronousProxy {
118 type Protocol = ViewTreeWatcherMarker;
119
120 fn from_client(value: fidl::endpoints::ClientEnd<ViewTreeWatcherMarker>) -> Self {
121 Self::new(value.into_channel())
122 }
123}
124
125#[derive(Debug, Clone)]
126pub struct ViewTreeWatcherProxy {
127 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
128}
129
130impl fidl::endpoints::Proxy for ViewTreeWatcherProxy {
131 type Protocol = ViewTreeWatcherMarker;
132
133 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
134 Self::new(inner)
135 }
136
137 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
138 self.client.into_channel().map_err(|client| Self { client })
139 }
140
141 fn as_channel(&self) -> &::fidl::AsyncChannel {
142 self.client.as_channel()
143 }
144}
145
146impl ViewTreeWatcherProxy {
147 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
149 let protocol_name = <ViewTreeWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
150 Self { client: fidl::client::Client::new(channel, protocol_name) }
151 }
152
153 pub fn take_event_stream(&self) -> ViewTreeWatcherEventStream {
159 ViewTreeWatcherEventStream { event_receiver: self.client.take_event_receiver() }
160 }
161
162 pub fn r#watch(
180 &self,
181 ) -> fidl::client::QueryResponseFut<WatchResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
182 {
183 ViewTreeWatcherProxyInterface::r#watch(self)
184 }
185}
186
187impl ViewTreeWatcherProxyInterface for ViewTreeWatcherProxy {
188 type WatchResponseFut = fidl::client::QueryResponseFut<
189 WatchResponse,
190 fidl::encoding::DefaultFuchsiaResourceDialect,
191 >;
192 fn r#watch(&self) -> Self::WatchResponseFut {
193 fn _decode(
194 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
195 ) -> Result<WatchResponse, fidl::Error> {
196 let _response = fidl::client::decode_transaction_body::<
197 WatchResponse,
198 fidl::encoding::DefaultFuchsiaResourceDialect,
199 0x3c7670983418477b,
200 >(_buf?)?;
201 Ok(_response)
202 }
203 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, WatchResponse>(
204 (),
205 0x3c7670983418477b,
206 fidl::encoding::DynamicFlags::empty(),
207 _decode,
208 )
209 }
210}
211
212pub struct ViewTreeWatcherEventStream {
213 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
214}
215
216impl std::marker::Unpin for ViewTreeWatcherEventStream {}
217
218impl futures::stream::FusedStream for ViewTreeWatcherEventStream {
219 fn is_terminated(&self) -> bool {
220 self.event_receiver.is_terminated()
221 }
222}
223
224impl futures::Stream for ViewTreeWatcherEventStream {
225 type Item = Result<ViewTreeWatcherEvent, fidl::Error>;
226
227 fn poll_next(
228 mut self: std::pin::Pin<&mut Self>,
229 cx: &mut std::task::Context<'_>,
230 ) -> std::task::Poll<Option<Self::Item>> {
231 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
232 &mut self.event_receiver,
233 cx
234 )?) {
235 Some(buf) => std::task::Poll::Ready(Some(ViewTreeWatcherEvent::decode(buf))),
236 None => std::task::Poll::Ready(None),
237 }
238 }
239}
240
241#[derive(Debug)]
242pub enum ViewTreeWatcherEvent {}
243
244impl ViewTreeWatcherEvent {
245 fn decode(
247 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
248 ) -> Result<ViewTreeWatcherEvent, fidl::Error> {
249 let (bytes, _handles) = buf.split_mut();
250 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
251 debug_assert_eq!(tx_header.tx_id, 0);
252 match tx_header.ordinal {
253 _ => Err(fidl::Error::UnknownOrdinal {
254 ordinal: tx_header.ordinal,
255 protocol_name:
256 <ViewTreeWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
257 }),
258 }
259 }
260}
261
262pub struct ViewTreeWatcherRequestStream {
264 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
265 is_terminated: bool,
266}
267
268impl std::marker::Unpin for ViewTreeWatcherRequestStream {}
269
270impl futures::stream::FusedStream for ViewTreeWatcherRequestStream {
271 fn is_terminated(&self) -> bool {
272 self.is_terminated
273 }
274}
275
276impl fidl::endpoints::RequestStream for ViewTreeWatcherRequestStream {
277 type Protocol = ViewTreeWatcherMarker;
278 type ControlHandle = ViewTreeWatcherControlHandle;
279
280 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
281 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
282 }
283
284 fn control_handle(&self) -> Self::ControlHandle {
285 ViewTreeWatcherControlHandle { inner: self.inner.clone() }
286 }
287
288 fn into_inner(
289 self,
290 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
291 {
292 (self.inner, self.is_terminated)
293 }
294
295 fn from_inner(
296 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
297 is_terminated: bool,
298 ) -> Self {
299 Self { inner, is_terminated }
300 }
301}
302
303impl futures::Stream for ViewTreeWatcherRequestStream {
304 type Item = Result<ViewTreeWatcherRequest, fidl::Error>;
305
306 fn poll_next(
307 mut self: std::pin::Pin<&mut Self>,
308 cx: &mut std::task::Context<'_>,
309 ) -> std::task::Poll<Option<Self::Item>> {
310 let this = &mut *self;
311 if this.inner.check_shutdown(cx) {
312 this.is_terminated = true;
313 return std::task::Poll::Ready(None);
314 }
315 if this.is_terminated {
316 panic!("polled ViewTreeWatcherRequestStream after completion");
317 }
318 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
319 |bytes, handles| {
320 match this.inner.channel().read_etc(cx, bytes, handles) {
321 std::task::Poll::Ready(Ok(())) => {}
322 std::task::Poll::Pending => return std::task::Poll::Pending,
323 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
324 this.is_terminated = true;
325 return std::task::Poll::Ready(None);
326 }
327 std::task::Poll::Ready(Err(e)) => {
328 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
329 e.into(),
330 ))))
331 }
332 }
333
334 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
336
337 std::task::Poll::Ready(Some(match header.ordinal {
338 0x3c7670983418477b => {
339 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
340 let mut req = fidl::new_empty!(
341 fidl::encoding::EmptyPayload,
342 fidl::encoding::DefaultFuchsiaResourceDialect
343 );
344 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
345 let control_handle =
346 ViewTreeWatcherControlHandle { inner: this.inner.clone() };
347 Ok(ViewTreeWatcherRequest::Watch {
348 responder: ViewTreeWatcherWatchResponder {
349 control_handle: std::mem::ManuallyDrop::new(control_handle),
350 tx_id: header.tx_id,
351 },
352 })
353 }
354 _ => Err(fidl::Error::UnknownOrdinal {
355 ordinal: header.ordinal,
356 protocol_name:
357 <ViewTreeWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
358 }),
359 }))
360 },
361 )
362 }
363}
364
365#[derive(Debug)]
399pub enum ViewTreeWatcherRequest {
400 Watch { responder: ViewTreeWatcherWatchResponder },
418}
419
420impl ViewTreeWatcherRequest {
421 #[allow(irrefutable_let_patterns)]
422 pub fn into_watch(self) -> Option<(ViewTreeWatcherWatchResponder)> {
423 if let ViewTreeWatcherRequest::Watch { responder } = self {
424 Some((responder))
425 } else {
426 None
427 }
428 }
429
430 pub fn method_name(&self) -> &'static str {
432 match *self {
433 ViewTreeWatcherRequest::Watch { .. } => "watch",
434 }
435 }
436}
437
438#[derive(Debug, Clone)]
439pub struct ViewTreeWatcherControlHandle {
440 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
441}
442
443impl fidl::endpoints::ControlHandle for ViewTreeWatcherControlHandle {
444 fn shutdown(&self) {
445 self.inner.shutdown()
446 }
447 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
448 self.inner.shutdown_with_epitaph(status)
449 }
450
451 fn is_closed(&self) -> bool {
452 self.inner.channel().is_closed()
453 }
454 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
455 self.inner.channel().on_closed()
456 }
457
458 #[cfg(target_os = "fuchsia")]
459 fn signal_peer(
460 &self,
461 clear_mask: zx::Signals,
462 set_mask: zx::Signals,
463 ) -> Result<(), zx_status::Status> {
464 use fidl::Peered;
465 self.inner.channel().signal_peer(clear_mask, set_mask)
466 }
467}
468
469impl ViewTreeWatcherControlHandle {}
470
471#[must_use = "FIDL methods require a response to be sent"]
472#[derive(Debug)]
473pub struct ViewTreeWatcherWatchResponder {
474 control_handle: std::mem::ManuallyDrop<ViewTreeWatcherControlHandle>,
475 tx_id: u32,
476}
477
478impl std::ops::Drop for ViewTreeWatcherWatchResponder {
482 fn drop(&mut self) {
483 self.control_handle.shutdown();
484 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
486 }
487}
488
489impl fidl::endpoints::Responder for ViewTreeWatcherWatchResponder {
490 type ControlHandle = ViewTreeWatcherControlHandle;
491
492 fn control_handle(&self) -> &ViewTreeWatcherControlHandle {
493 &self.control_handle
494 }
495
496 fn drop_without_shutdown(mut self) {
497 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
499 std::mem::forget(self);
501 }
502}
503
504impl ViewTreeWatcherWatchResponder {
505 pub fn send(self, mut payload: &WatchResponse) -> Result<(), fidl::Error> {
509 let _result = self.send_raw(payload);
510 if _result.is_err() {
511 self.control_handle.shutdown();
512 }
513 self.drop_without_shutdown();
514 _result
515 }
516
517 pub fn send_no_shutdown_on_err(self, mut payload: &WatchResponse) -> Result<(), fidl::Error> {
519 let _result = self.send_raw(payload);
520 self.drop_without_shutdown();
521 _result
522 }
523
524 fn send_raw(&self, mut payload: &WatchResponse) -> Result<(), fidl::Error> {
525 self.control_handle.inner.send::<WatchResponse>(
526 payload,
527 self.tx_id,
528 0x3c7670983418477b,
529 fidl::encoding::DynamicFlags::empty(),
530 )
531 }
532}
533
534mod internal {
535 use super::*;
536}