fidl_fuchsia_ui_observation_scope/
fidl_fuchsia_ui_observation_scope.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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    /// Waits until an event arrives and returns it. It is safe for other
86    /// threads to make concurrent requests while waiting for an event.
87    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    /// Sets up a geometry `ViewTreeWatcher` channel which reports the view tree
95    /// geometry for a specific view, identified by `context_view`. The data
96    /// received describes the `context_view` and its descendant views.
97    ///
98    /// This method may be called multiple times to obtain multiple geometry
99    /// `ViewTreeWatcher`s. Typical usage is to obtain just one geometry
100    /// `ViewTreeWatcher`.
101    ///
102    /// Client can freely disconnect this `Registry` endpoint after this method
103    /// returns and the `ViewTreeWatcher` endpoint will remain active.
104    ///
105    /// Flow control. The caller is allowed at most one in-flight call at a
106    /// time. Subsequent calls must wait until the acknowledgment returns.
107    /// Non-compliance results in channel closure.
108    ///
109    /// Client synchronization. The method response signifies that the server
110    /// has processed the channel endpoint. A client can synchronize its next
111    /// actions based on this guarantee (for example, trigger a change in view
112    /// geometry without the change "getting lost").
113    ///
114    /// View lifecycle. The view represented by `context_view` must first be
115    /// created. Otherwise, `geometry` channel's server endpoint is closed.
116    ///
117    /// + request `context_view` a view's identity, which serves as the root of
118    ///   a view tree
119    /// + request `geometry` a channel to observe `context_view`'s view tree
120    /// - response acknowledgement that `geometry` is connected to the server
121    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::NullableHandle {
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#[cfg(target_os = "fuchsia")]
157impl fidl::endpoints::FromClient for RegistrySynchronousProxy {
158    type Protocol = RegistryMarker;
159
160    fn from_client(value: fidl::endpoints::ClientEnd<RegistryMarker>) -> Self {
161        Self::new(value.into_channel())
162    }
163}
164
165#[derive(Debug, Clone)]
166pub struct RegistryProxy {
167    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
168}
169
170impl fidl::endpoints::Proxy for RegistryProxy {
171    type Protocol = RegistryMarker;
172
173    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
174        Self::new(inner)
175    }
176
177    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
178        self.client.into_channel().map_err(|client| Self { client })
179    }
180
181    fn as_channel(&self) -> &::fidl::AsyncChannel {
182        self.client.as_channel()
183    }
184}
185
186impl RegistryProxy {
187    /// Create a new Proxy for fuchsia.ui.observation.scope/Registry.
188    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
189        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
190        Self { client: fidl::client::Client::new(channel, protocol_name) }
191    }
192
193    /// Get a Stream of events from the remote end of the protocol.
194    ///
195    /// # Panics
196    ///
197    /// Panics if the event stream was already taken.
198    pub fn take_event_stream(&self) -> RegistryEventStream {
199        RegistryEventStream { event_receiver: self.client.take_event_receiver() }
200    }
201
202    /// Sets up a geometry `ViewTreeWatcher` channel which reports the view tree
203    /// geometry for a specific view, identified by `context_view`. The data
204    /// received describes the `context_view` and its descendant views.
205    ///
206    /// This method may be called multiple times to obtain multiple geometry
207    /// `ViewTreeWatcher`s. Typical usage is to obtain just one geometry
208    /// `ViewTreeWatcher`.
209    ///
210    /// Client can freely disconnect this `Registry` endpoint after this method
211    /// returns and the `ViewTreeWatcher` endpoint will remain active.
212    ///
213    /// Flow control. The caller is allowed at most one in-flight call at a
214    /// time. Subsequent calls must wait until the acknowledgment returns.
215    /// Non-compliance results in channel closure.
216    ///
217    /// Client synchronization. The method response signifies that the server
218    /// has processed the channel endpoint. A client can synchronize its next
219    /// actions based on this guarantee (for example, trigger a change in view
220    /// geometry without the change "getting lost").
221    ///
222    /// View lifecycle. The view represented by `context_view` must first be
223    /// created. Otherwise, `geometry` channel's server endpoint is closed.
224    ///
225    /// + request `context_view` a view's identity, which serves as the root of
226    ///   a view tree
227    /// + request `geometry` a channel to observe `context_view`'s view tree
228    /// - response acknowledgement that `geometry` is connected to the server
229    pub fn r#register_scoped_view_tree_watcher(
230        &self,
231        mut context_view: u64,
232        mut watcher: fidl::endpoints::ServerEnd<
233            fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
234        >,
235    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
236        RegistryProxyInterface::r#register_scoped_view_tree_watcher(self, context_view, watcher)
237    }
238}
239
240impl RegistryProxyInterface for RegistryProxy {
241    type RegisterScopedViewTreeWatcherResponseFut =
242        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
243    fn r#register_scoped_view_tree_watcher(
244        &self,
245        mut context_view: u64,
246        mut watcher: fidl::endpoints::ServerEnd<
247            fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
248        >,
249    ) -> Self::RegisterScopedViewTreeWatcherResponseFut {
250        fn _decode(
251            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
252        ) -> Result<(), fidl::Error> {
253            let _response = fidl::client::decode_transaction_body::<
254                fidl::encoding::EmptyPayload,
255                fidl::encoding::DefaultFuchsiaResourceDialect,
256                0x7fcb9e2fd95ffc3d,
257            >(_buf?)?;
258            Ok(_response)
259        }
260        self.client.send_query_and_decode::<RegistryRegisterScopedViewTreeWatcherRequest, ()>(
261            (context_view, watcher),
262            0x7fcb9e2fd95ffc3d,
263            fidl::encoding::DynamicFlags::empty(),
264            _decode,
265        )
266    }
267}
268
269pub struct RegistryEventStream {
270    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
271}
272
273impl std::marker::Unpin for RegistryEventStream {}
274
275impl futures::stream::FusedStream for RegistryEventStream {
276    fn is_terminated(&self) -> bool {
277        self.event_receiver.is_terminated()
278    }
279}
280
281impl futures::Stream for RegistryEventStream {
282    type Item = Result<RegistryEvent, fidl::Error>;
283
284    fn poll_next(
285        mut self: std::pin::Pin<&mut Self>,
286        cx: &mut std::task::Context<'_>,
287    ) -> std::task::Poll<Option<Self::Item>> {
288        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
289            &mut self.event_receiver,
290            cx
291        )?) {
292            Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
293            None => std::task::Poll::Ready(None),
294        }
295    }
296}
297
298#[derive(Debug)]
299pub enum RegistryEvent {}
300
301impl RegistryEvent {
302    /// Decodes a message buffer as a [`RegistryEvent`].
303    fn decode(
304        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
305    ) -> Result<RegistryEvent, fidl::Error> {
306        let (bytes, _handles) = buf.split_mut();
307        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
308        debug_assert_eq!(tx_header.tx_id, 0);
309        match tx_header.ordinal {
310            _ => Err(fidl::Error::UnknownOrdinal {
311                ordinal: tx_header.ordinal,
312                protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
313            }),
314        }
315    }
316}
317
318/// A Stream of incoming requests for fuchsia.ui.observation.scope/Registry.
319pub struct RegistryRequestStream {
320    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
321    is_terminated: bool,
322}
323
324impl std::marker::Unpin for RegistryRequestStream {}
325
326impl futures::stream::FusedStream for RegistryRequestStream {
327    fn is_terminated(&self) -> bool {
328        self.is_terminated
329    }
330}
331
332impl fidl::endpoints::RequestStream for RegistryRequestStream {
333    type Protocol = RegistryMarker;
334    type ControlHandle = RegistryControlHandle;
335
336    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
337        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
338    }
339
340    fn control_handle(&self) -> Self::ControlHandle {
341        RegistryControlHandle { inner: self.inner.clone() }
342    }
343
344    fn into_inner(
345        self,
346    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
347    {
348        (self.inner, self.is_terminated)
349    }
350
351    fn from_inner(
352        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
353        is_terminated: bool,
354    ) -> Self {
355        Self { inner, is_terminated }
356    }
357}
358
359impl futures::Stream for RegistryRequestStream {
360    type Item = Result<RegistryRequest, fidl::Error>;
361
362    fn poll_next(
363        mut self: std::pin::Pin<&mut Self>,
364        cx: &mut std::task::Context<'_>,
365    ) -> std::task::Poll<Option<Self::Item>> {
366        let this = &mut *self;
367        if this.inner.check_shutdown(cx) {
368            this.is_terminated = true;
369            return std::task::Poll::Ready(None);
370        }
371        if this.is_terminated {
372            panic!("polled RegistryRequestStream after completion");
373        }
374        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
375            |bytes, handles| {
376                match this.inner.channel().read_etc(cx, bytes, handles) {
377                    std::task::Poll::Ready(Ok(())) => {}
378                    std::task::Poll::Pending => return std::task::Poll::Pending,
379                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
380                        this.is_terminated = true;
381                        return std::task::Poll::Ready(None);
382                    }
383                    std::task::Poll::Ready(Err(e)) => {
384                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
385                            e.into(),
386                        ))));
387                    }
388                }
389
390                // A message has been received from the channel
391                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
392
393                std::task::Poll::Ready(Some(match header.ordinal {
394                    0x7fcb9e2fd95ffc3d => {
395                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
396                        let mut req = fidl::new_empty!(
397                            RegistryRegisterScopedViewTreeWatcherRequest,
398                            fidl::encoding::DefaultFuchsiaResourceDialect
399                        );
400                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterScopedViewTreeWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
401                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
402                        Ok(RegistryRequest::RegisterScopedViewTreeWatcher {
403                            context_view: req.context_view,
404                            watcher: req.watcher,
405
406                            responder: RegistryRegisterScopedViewTreeWatcherResponder {
407                                control_handle: std::mem::ManuallyDrop::new(control_handle),
408                                tx_id: header.tx_id,
409                            },
410                        })
411                    }
412                    _ => Err(fidl::Error::UnknownOrdinal {
413                        ordinal: header.ordinal,
414                        protocol_name:
415                            <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
416                    }),
417                }))
418            },
419        )
420    }
421}
422
423/// *** ONLY FOR USE IN PLATFORM COMPONENTS ***
424/// This is a sensitive protocol. It provides unlimited visibility into any
425/// view tree, if handed the tree root's view ref KOID. Hand it out ONLY to
426/// platform components, such as Accessibility Manager or UI Test Manager.
427///
428/// Regular UI clients uses should obtain observation protocols through a
429/// graphics factory function (see |fuchsia.ui.composition.ViewBoundProtocols|),
430/// which securely ties observation protocols to a specific view client.
431#[derive(Debug)]
432pub enum RegistryRequest {
433    /// Sets up a geometry `ViewTreeWatcher` channel which reports the view tree
434    /// geometry for a specific view, identified by `context_view`. The data
435    /// received describes the `context_view` and its descendant views.
436    ///
437    /// This method may be called multiple times to obtain multiple geometry
438    /// `ViewTreeWatcher`s. Typical usage is to obtain just one geometry
439    /// `ViewTreeWatcher`.
440    ///
441    /// Client can freely disconnect this `Registry` endpoint after this method
442    /// returns and the `ViewTreeWatcher` endpoint will remain active.
443    ///
444    /// Flow control. The caller is allowed at most one in-flight call at a
445    /// time. Subsequent calls must wait until the acknowledgment returns.
446    /// Non-compliance results in channel closure.
447    ///
448    /// Client synchronization. The method response signifies that the server
449    /// has processed the channel endpoint. A client can synchronize its next
450    /// actions based on this guarantee (for example, trigger a change in view
451    /// geometry without the change "getting lost").
452    ///
453    /// View lifecycle. The view represented by `context_view` must first be
454    /// created. Otherwise, `geometry` channel's server endpoint is closed.
455    ///
456    /// + request `context_view` a view's identity, which serves as the root of
457    ///   a view tree
458    /// + request `geometry` a channel to observe `context_view`'s view tree
459    /// - response acknowledgement that `geometry` is connected to the server
460    RegisterScopedViewTreeWatcher {
461        context_view: u64,
462        watcher:
463            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker>,
464        responder: RegistryRegisterScopedViewTreeWatcherResponder,
465    },
466}
467
468impl RegistryRequest {
469    #[allow(irrefutable_let_patterns)]
470    pub fn into_register_scoped_view_tree_watcher(
471        self,
472    ) -> Option<(
473        u64,
474        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker>,
475        RegistryRegisterScopedViewTreeWatcherResponder,
476    )> {
477        if let RegistryRequest::RegisterScopedViewTreeWatcher { context_view, watcher, responder } =
478            self
479        {
480            Some((context_view, watcher, responder))
481        } else {
482            None
483        }
484    }
485
486    /// Name of the method defined in FIDL
487    pub fn method_name(&self) -> &'static str {
488        match *self {
489            RegistryRequest::RegisterScopedViewTreeWatcher { .. } => {
490                "register_scoped_view_tree_watcher"
491            }
492        }
493    }
494}
495
496#[derive(Debug, Clone)]
497pub struct RegistryControlHandle {
498    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
499}
500
501impl fidl::endpoints::ControlHandle for RegistryControlHandle {
502    fn shutdown(&self) {
503        self.inner.shutdown()
504    }
505
506    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
507        self.inner.shutdown_with_epitaph(status)
508    }
509
510    fn is_closed(&self) -> bool {
511        self.inner.channel().is_closed()
512    }
513    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
514        self.inner.channel().on_closed()
515    }
516
517    #[cfg(target_os = "fuchsia")]
518    fn signal_peer(
519        &self,
520        clear_mask: zx::Signals,
521        set_mask: zx::Signals,
522    ) -> Result<(), zx_status::Status> {
523        use fidl::Peered;
524        self.inner.channel().signal_peer(clear_mask, set_mask)
525    }
526}
527
528impl RegistryControlHandle {}
529
530#[must_use = "FIDL methods require a response to be sent"]
531#[derive(Debug)]
532pub struct RegistryRegisterScopedViewTreeWatcherResponder {
533    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
534    tx_id: u32,
535}
536
537/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
538/// if the responder is dropped without sending a response, so that the client
539/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
540impl std::ops::Drop for RegistryRegisterScopedViewTreeWatcherResponder {
541    fn drop(&mut self) {
542        self.control_handle.shutdown();
543        // Safety: drops once, never accessed again
544        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
545    }
546}
547
548impl fidl::endpoints::Responder for RegistryRegisterScopedViewTreeWatcherResponder {
549    type ControlHandle = RegistryControlHandle;
550
551    fn control_handle(&self) -> &RegistryControlHandle {
552        &self.control_handle
553    }
554
555    fn drop_without_shutdown(mut self) {
556        // Safety: drops once, never accessed again due to mem::forget
557        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
558        // Prevent Drop from running (which would shut down the channel)
559        std::mem::forget(self);
560    }
561}
562
563impl RegistryRegisterScopedViewTreeWatcherResponder {
564    /// Sends a response to the FIDL transaction.
565    ///
566    /// Sets the channel to shutdown if an error occurs.
567    pub fn send(self) -> Result<(), fidl::Error> {
568        let _result = self.send_raw();
569        if _result.is_err() {
570            self.control_handle.shutdown();
571        }
572        self.drop_without_shutdown();
573        _result
574    }
575
576    /// Similar to "send" but does not shutdown the channel if an error occurs.
577    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
578        let _result = self.send_raw();
579        self.drop_without_shutdown();
580        _result
581    }
582
583    fn send_raw(&self) -> Result<(), fidl::Error> {
584        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
585            (),
586            self.tx_id,
587            0x7fcb9e2fd95ffc3d,
588            fidl::encoding::DynamicFlags::empty(),
589        )
590    }
591}
592
593mod internal {
594    use super::*;
595
596    impl fidl::encoding::ResourceTypeMarker for RegistryRegisterScopedViewTreeWatcherRequest {
597        type Borrowed<'a> = &'a mut Self;
598        fn take_or_borrow<'a>(
599            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
600        ) -> Self::Borrowed<'a> {
601            value
602        }
603    }
604
605    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterScopedViewTreeWatcherRequest {
606        type Owned = Self;
607
608        #[inline(always)]
609        fn inline_align(_context: fidl::encoding::Context) -> usize {
610            8
611        }
612
613        #[inline(always)]
614        fn inline_size(_context: fidl::encoding::Context) -> usize {
615            16
616        }
617    }
618
619    unsafe impl
620        fidl::encoding::Encode<
621            RegistryRegisterScopedViewTreeWatcherRequest,
622            fidl::encoding::DefaultFuchsiaResourceDialect,
623        > for &mut RegistryRegisterScopedViewTreeWatcherRequest
624    {
625        #[inline]
626        unsafe fn encode(
627            self,
628            encoder: &mut fidl::encoding::Encoder<
629                '_,
630                fidl::encoding::DefaultFuchsiaResourceDialect,
631            >,
632            offset: usize,
633            _depth: fidl::encoding::Depth,
634        ) -> fidl::Result<()> {
635            encoder.debug_check_bounds::<RegistryRegisterScopedViewTreeWatcherRequest>(offset);
636            // Delegate to tuple encoding.
637            fidl::encoding::Encode::<
638                RegistryRegisterScopedViewTreeWatcherRequest,
639                fidl::encoding::DefaultFuchsiaResourceDialect,
640            >::encode(
641                (
642                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.context_view),
643                    <fidl::encoding::Endpoint<
644                        fidl::endpoints::ServerEnd<
645                            fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
646                        >,
647                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
648                        &mut self.watcher
649                    ),
650                ),
651                encoder,
652                offset,
653                _depth,
654            )
655        }
656    }
657    unsafe impl<
658        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
659        T1: fidl::encoding::Encode<
660                fidl::encoding::Endpoint<
661                    fidl::endpoints::ServerEnd<
662                        fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
663                    >,
664                >,
665                fidl::encoding::DefaultFuchsiaResourceDialect,
666            >,
667    >
668        fidl::encoding::Encode<
669            RegistryRegisterScopedViewTreeWatcherRequest,
670            fidl::encoding::DefaultFuchsiaResourceDialect,
671        > for (T0, T1)
672    {
673        #[inline]
674        unsafe fn encode(
675            self,
676            encoder: &mut fidl::encoding::Encoder<
677                '_,
678                fidl::encoding::DefaultFuchsiaResourceDialect,
679            >,
680            offset: usize,
681            depth: fidl::encoding::Depth,
682        ) -> fidl::Result<()> {
683            encoder.debug_check_bounds::<RegistryRegisterScopedViewTreeWatcherRequest>(offset);
684            // Zero out padding regions. There's no need to apply masks
685            // because the unmasked parts will be overwritten by fields.
686            unsafe {
687                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
688                (ptr as *mut u64).write_unaligned(0);
689            }
690            // Write the fields.
691            self.0.encode(encoder, offset + 0, depth)?;
692            self.1.encode(encoder, offset + 8, depth)?;
693            Ok(())
694        }
695    }
696
697    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
698        for RegistryRegisterScopedViewTreeWatcherRequest
699    {
700        #[inline(always)]
701        fn new_empty() -> Self {
702            Self {
703                context_view: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
704                watcher: fidl::new_empty!(
705                    fidl::encoding::Endpoint<
706                        fidl::endpoints::ServerEnd<
707                            fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
708                        >,
709                    >,
710                    fidl::encoding::DefaultFuchsiaResourceDialect
711                ),
712            }
713        }
714
715        #[inline]
716        unsafe fn decode(
717            &mut self,
718            decoder: &mut fidl::encoding::Decoder<
719                '_,
720                fidl::encoding::DefaultFuchsiaResourceDialect,
721            >,
722            offset: usize,
723            _depth: fidl::encoding::Depth,
724        ) -> fidl::Result<()> {
725            decoder.debug_check_bounds::<Self>(offset);
726            // Verify that padding bytes are zero.
727            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
728            let padval = unsafe { (ptr as *const u64).read_unaligned() };
729            let mask = 0xffffffff00000000u64;
730            let maskedval = padval & mask;
731            if maskedval != 0 {
732                return Err(fidl::Error::NonZeroPadding {
733                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
734                });
735            }
736            fidl::decode!(
737                u64,
738                fidl::encoding::DefaultFuchsiaResourceDialect,
739                &mut self.context_view,
740                decoder,
741                offset + 0,
742                _depth
743            )?;
744            fidl::decode!(
745                fidl::encoding::Endpoint<
746                    fidl::endpoints::ServerEnd<
747                        fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
748                    >,
749                >,
750                fidl::encoding::DefaultFuchsiaResourceDialect,
751                &mut self.watcher,
752                decoder,
753                offset + 8,
754                _depth
755            )?;
756            Ok(())
757        }
758    }
759}