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::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#[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    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
506        self.inner.shutdown_with_epitaph(status)
507    }
508
509    fn is_closed(&self) -> bool {
510        self.inner.channel().is_closed()
511    }
512    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
513        self.inner.channel().on_closed()
514    }
515
516    #[cfg(target_os = "fuchsia")]
517    fn signal_peer(
518        &self,
519        clear_mask: zx::Signals,
520        set_mask: zx::Signals,
521    ) -> Result<(), zx_status::Status> {
522        use fidl::Peered;
523        self.inner.channel().signal_peer(clear_mask, set_mask)
524    }
525}
526
527impl RegistryControlHandle {}
528
529#[must_use = "FIDL methods require a response to be sent"]
530#[derive(Debug)]
531pub struct RegistryRegisterScopedViewTreeWatcherResponder {
532    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
533    tx_id: u32,
534}
535
536/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
537/// if the responder is dropped without sending a response, so that the client
538/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
539impl std::ops::Drop for RegistryRegisterScopedViewTreeWatcherResponder {
540    fn drop(&mut self) {
541        self.control_handle.shutdown();
542        // Safety: drops once, never accessed again
543        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
544    }
545}
546
547impl fidl::endpoints::Responder for RegistryRegisterScopedViewTreeWatcherResponder {
548    type ControlHandle = RegistryControlHandle;
549
550    fn control_handle(&self) -> &RegistryControlHandle {
551        &self.control_handle
552    }
553
554    fn drop_without_shutdown(mut self) {
555        // Safety: drops once, never accessed again due to mem::forget
556        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
557        // Prevent Drop from running (which would shut down the channel)
558        std::mem::forget(self);
559    }
560}
561
562impl RegistryRegisterScopedViewTreeWatcherResponder {
563    /// Sends a response to the FIDL transaction.
564    ///
565    /// Sets the channel to shutdown if an error occurs.
566    pub fn send(self) -> Result<(), fidl::Error> {
567        let _result = self.send_raw();
568        if _result.is_err() {
569            self.control_handle.shutdown();
570        }
571        self.drop_without_shutdown();
572        _result
573    }
574
575    /// Similar to "send" but does not shutdown the channel if an error occurs.
576    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
577        let _result = self.send_raw();
578        self.drop_without_shutdown();
579        _result
580    }
581
582    fn send_raw(&self) -> Result<(), fidl::Error> {
583        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
584            (),
585            self.tx_id,
586            0x7fcb9e2fd95ffc3d,
587            fidl::encoding::DynamicFlags::empty(),
588        )
589    }
590}
591
592mod internal {
593    use super::*;
594
595    impl fidl::encoding::ResourceTypeMarker for RegistryRegisterScopedViewTreeWatcherRequest {
596        type Borrowed<'a> = &'a mut Self;
597        fn take_or_borrow<'a>(
598            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
599        ) -> Self::Borrowed<'a> {
600            value
601        }
602    }
603
604    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterScopedViewTreeWatcherRequest {
605        type Owned = Self;
606
607        #[inline(always)]
608        fn inline_align(_context: fidl::encoding::Context) -> usize {
609            8
610        }
611
612        #[inline(always)]
613        fn inline_size(_context: fidl::encoding::Context) -> usize {
614            16
615        }
616    }
617
618    unsafe impl
619        fidl::encoding::Encode<
620            RegistryRegisterScopedViewTreeWatcherRequest,
621            fidl::encoding::DefaultFuchsiaResourceDialect,
622        > for &mut RegistryRegisterScopedViewTreeWatcherRequest
623    {
624        #[inline]
625        unsafe fn encode(
626            self,
627            encoder: &mut fidl::encoding::Encoder<
628                '_,
629                fidl::encoding::DefaultFuchsiaResourceDialect,
630            >,
631            offset: usize,
632            _depth: fidl::encoding::Depth,
633        ) -> fidl::Result<()> {
634            encoder.debug_check_bounds::<RegistryRegisterScopedViewTreeWatcherRequest>(offset);
635            // Delegate to tuple encoding.
636            fidl::encoding::Encode::<
637                RegistryRegisterScopedViewTreeWatcherRequest,
638                fidl::encoding::DefaultFuchsiaResourceDialect,
639            >::encode(
640                (
641                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.context_view),
642                    <fidl::encoding::Endpoint<
643                        fidl::endpoints::ServerEnd<
644                            fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
645                        >,
646                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
647                        &mut self.watcher
648                    ),
649                ),
650                encoder,
651                offset,
652                _depth,
653            )
654        }
655    }
656    unsafe impl<
657            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
658            T1: fidl::encoding::Encode<
659                fidl::encoding::Endpoint<
660                    fidl::endpoints::ServerEnd<
661                        fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
662                    >,
663                >,
664                fidl::encoding::DefaultFuchsiaResourceDialect,
665            >,
666        >
667        fidl::encoding::Encode<
668            RegistryRegisterScopedViewTreeWatcherRequest,
669            fidl::encoding::DefaultFuchsiaResourceDialect,
670        > for (T0, T1)
671    {
672        #[inline]
673        unsafe fn encode(
674            self,
675            encoder: &mut fidl::encoding::Encoder<
676                '_,
677                fidl::encoding::DefaultFuchsiaResourceDialect,
678            >,
679            offset: usize,
680            depth: fidl::encoding::Depth,
681        ) -> fidl::Result<()> {
682            encoder.debug_check_bounds::<RegistryRegisterScopedViewTreeWatcherRequest>(offset);
683            // Zero out padding regions. There's no need to apply masks
684            // because the unmasked parts will be overwritten by fields.
685            unsafe {
686                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
687                (ptr as *mut u64).write_unaligned(0);
688            }
689            // Write the fields.
690            self.0.encode(encoder, offset + 0, depth)?;
691            self.1.encode(encoder, offset + 8, depth)?;
692            Ok(())
693        }
694    }
695
696    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
697        for RegistryRegisterScopedViewTreeWatcherRequest
698    {
699        #[inline(always)]
700        fn new_empty() -> Self {
701            Self {
702                context_view: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
703                watcher: fidl::new_empty!(
704                    fidl::encoding::Endpoint<
705                        fidl::endpoints::ServerEnd<
706                            fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
707                        >,
708                    >,
709                    fidl::encoding::DefaultFuchsiaResourceDialect
710                ),
711            }
712        }
713
714        #[inline]
715        unsafe fn decode(
716            &mut self,
717            decoder: &mut fidl::encoding::Decoder<
718                '_,
719                fidl::encoding::DefaultFuchsiaResourceDialect,
720            >,
721            offset: usize,
722            _depth: fidl::encoding::Depth,
723        ) -> fidl::Result<()> {
724            decoder.debug_check_bounds::<Self>(offset);
725            // Verify that padding bytes are zero.
726            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
727            let padval = unsafe { (ptr as *const u64).read_unaligned() };
728            let mask = 0xffffffff00000000u64;
729            let maskedval = padval & mask;
730            if maskedval != 0 {
731                return Err(fidl::Error::NonZeroPadding {
732                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
733                });
734            }
735            fidl::decode!(
736                u64,
737                fidl::encoding::DefaultFuchsiaResourceDialect,
738                &mut self.context_view,
739                decoder,
740                offset + 0,
741                _depth
742            )?;
743            fidl::decode!(
744                fidl::encoding::Endpoint<
745                    fidl::endpoints::ServerEnd<
746                        fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
747                    >,
748                >,
749                fidl::encoding::DefaultFuchsiaResourceDialect,
750                &mut self.watcher,
751                decoder,
752                offset + 8,
753                _depth
754            )?;
755            Ok(())
756        }
757    }
758}