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