fidl_fuchsia_ui_pointerinjector/
fidl_fuchsia_ui_pointerinjector.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_pointerinjector_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct RegistryRegisterRequest {
16    pub config: Config,
17    pub injector: fidl::endpoints::ServerEnd<DeviceMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RegistryRegisterRequest {}
21
22/// A specification for an injector |Device|.
23///
24/// All fields required.
25#[derive(Debug, Default, PartialEq)]
26pub struct Config {
27    /// An identifier for the pointer device that issues pointer event streams.
28    pub device_id: Option<u32>,
29    /// A characterization of the pointer device.
30    pub device_type: Option<DeviceType>,
31    /// The scope and coordinate system of the injector |Device|.
32    ///
33    /// Note: To avoid circular injection scenarios, |context| must be a
34    ///       strict ancestor of |target|.
35    pub context: Option<Context>,
36    /// The region where dispatch is attempted for injected events.
37    ///
38    /// Note: To avoid circular injection scenarios, |target| must be a strict
39    ///       descendant of |context|.
40    pub target: Option<Target>,
41    /// The initial viewport for injected events. Subsequent modifications to
42    /// the viewport can also be sent synchronously with injected events.
43    pub viewport: Option<Viewport>,
44    /// A specification of the UI clients in |target| that may have injected
45    /// events dispatched to them.
46    ///
47    /// For example, if |dispatch_policy| is |EXCLUSIVE|, then only |target| may
48    /// have injected events dispatched to it, regardless of other factors, such
49    /// as surface occlusion by clients inside and outside of |target|.
50    pub dispatch_policy: Option<DispatchPolicy>,
51    /// Range of vertical scroll values issued by the device.
52    pub scroll_v_range: Option<fidl_fuchsia_input_report::Axis>,
53    /// Range of horizontal scroll values issued by the device.
54    pub scroll_h_range: Option<fidl_fuchsia_input_report::Axis>,
55    /// Mouse button identifiers issued by the device, in priority order.
56    ///
57    /// The priority order of mouse buttons is a policy choice enacted by the injector.
58    /// This priority order is conveyed verbatim to UI clients via
59    /// [`fuchsia.ui.pointer.MouseDeviceInfo.buttons`], so button priority is shared consistently
60    /// between multiple UI clients. For example, to swap the left-side (0x1) and right-side (0x2)
61    /// physical buttons from their traditional roles of primary and secondary mouse buttons, the
62    /// injector can specify [0x2, 0x1, ... ] in this [`buttons`] vector.
63    ///
64    /// Note that preserving the physical button ID is also a policy choice. If preserved, a
65    /// discerning UI client can distinguish between the ground truth (which physical button was
66    /// pressed) versus the desired interpretation (what priority does that physical button have, on
67    /// the current system).
68    pub buttons: Option<Vec<u8>>,
69    /// Range of X and Y motion by a mouse device.
70    pub relative_motion_range: Option<[fidl_fuchsia_input_report::Axis; 2]>,
71    #[doc(hidden)]
72    pub __source_breaking: fidl::marker::SourceBreaking,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Config {}
76
77/// The region from which injection is attempted for injected events. As the
78/// context, it serves two purposes:
79/// (1) Scoping. It confirms the |Device|'s authority to inject pointer events
80///     on the specified target. Specifically, the context must be a view-tree
81///     ancestor of the target.
82/// (2) Coordinate System. It provides the reference coordinate system to define
83///     the viewport's position and size, relative to the target.
84#[derive(Debug, PartialEq)]
85pub enum Context {
86    /// A Scenic view from which injection is attempted for injected events.
87    /// - This view must be connected to the scene graph for injection.
88    /// - Injected events are confined to this view and its sub-views.
89    View(fidl_fuchsia_ui_views::ViewRef),
90}
91
92impl Context {
93    #[inline]
94    pub fn ordinal(&self) -> u64 {
95        match *self {
96            Self::View(_) => 1,
97        }
98    }
99}
100
101impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Context {}
102
103/// The region in which dispatch is attempted for injected events.
104/// The particular dispatch policy is specified in |Config|.
105#[derive(Debug, PartialEq)]
106pub enum Target {
107    /// A Scenic view in which dispatch is attempted for injected events.
108    /// - This view must be connected to the scene graph for dispatch.
109    /// - Injected events are confined to this view and its sub-views.
110    View(fidl_fuchsia_ui_views::ViewRef),
111}
112
113impl Target {
114    #[inline]
115    pub fn ordinal(&self) -> u64 {
116        match *self {
117            Self::View(_) => 1,
118        }
119    }
120}
121
122impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Target {}
123
124#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
125pub struct DeviceMarker;
126
127impl fidl::endpoints::ProtocolMarker for DeviceMarker {
128    type Proxy = DeviceProxy;
129    type RequestStream = DeviceRequestStream;
130    #[cfg(target_os = "fuchsia")]
131    type SynchronousProxy = DeviceSynchronousProxy;
132
133    const DEBUG_NAME: &'static str = "(anonymous) Device";
134}
135
136pub trait DeviceProxyInterface: Send + Sync {
137    type InjectResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
138    fn r#inject(&self, events: &[Event]) -> Self::InjectResponseFut;
139}
140#[derive(Debug)]
141#[cfg(target_os = "fuchsia")]
142pub struct DeviceSynchronousProxy {
143    client: fidl::client::sync::Client,
144}
145
146#[cfg(target_os = "fuchsia")]
147impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
148    type Proxy = DeviceProxy;
149    type Protocol = DeviceMarker;
150
151    fn from_channel(inner: fidl::Channel) -> Self {
152        Self::new(inner)
153    }
154
155    fn into_channel(self) -> fidl::Channel {
156        self.client.into_channel()
157    }
158
159    fn as_channel(&self) -> &fidl::Channel {
160        self.client.as_channel()
161    }
162}
163
164#[cfg(target_os = "fuchsia")]
165impl DeviceSynchronousProxy {
166    pub fn new(channel: fidl::Channel) -> Self {
167        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
168        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
169    }
170
171    pub fn into_channel(self) -> fidl::Channel {
172        self.client.into_channel()
173    }
174
175    /// Waits until an event arrives and returns it. It is safe for other
176    /// threads to make concurrent requests while waiting for an event.
177    pub fn wait_for_event(
178        &self,
179        deadline: zx::MonotonicInstant,
180    ) -> Result<DeviceEvent, fidl::Error> {
181        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
182    }
183
184    /// Injects events into a target.
185    ///
186    /// Batching: The caller is expected to batch-inject all events that share the
187    /// same timestamp (e.g., multiple finger samples). There may be multiple such
188    /// batches per injection call.
189    ///
190    /// Flow control: The caller is allowed at most one in-flight |Inject| call
191    /// at at time: subsequent |Inject| calls must wait until the acknowledgment
192    /// returns. Non-compliance results in channel closure.
193    pub fn r#inject(
194        &self,
195        mut events: &[Event],
196        ___deadline: zx::MonotonicInstant,
197    ) -> Result<(), fidl::Error> {
198        let _response =
199            self.client.send_query::<DeviceInjectRequest, fidl::encoding::EmptyPayload>(
200                (events,),
201                0x123882bb65bff40,
202                fidl::encoding::DynamicFlags::empty(),
203                ___deadline,
204            )?;
205        Ok(_response)
206    }
207}
208
209#[cfg(target_os = "fuchsia")]
210impl From<DeviceSynchronousProxy> for zx::Handle {
211    fn from(value: DeviceSynchronousProxy) -> Self {
212        value.into_channel().into()
213    }
214}
215
216#[cfg(target_os = "fuchsia")]
217impl From<fidl::Channel> for DeviceSynchronousProxy {
218    fn from(value: fidl::Channel) -> Self {
219        Self::new(value)
220    }
221}
222
223#[derive(Debug, Clone)]
224pub struct DeviceProxy {
225    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
226}
227
228impl fidl::endpoints::Proxy for DeviceProxy {
229    type Protocol = DeviceMarker;
230
231    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
232        Self::new(inner)
233    }
234
235    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
236        self.client.into_channel().map_err(|client| Self { client })
237    }
238
239    fn as_channel(&self) -> &::fidl::AsyncChannel {
240        self.client.as_channel()
241    }
242}
243
244impl DeviceProxy {
245    /// Create a new Proxy for fuchsia.ui.pointerinjector/Device.
246    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
247        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
248        Self { client: fidl::client::Client::new(channel, protocol_name) }
249    }
250
251    /// Get a Stream of events from the remote end of the protocol.
252    ///
253    /// # Panics
254    ///
255    /// Panics if the event stream was already taken.
256    pub fn take_event_stream(&self) -> DeviceEventStream {
257        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
258    }
259
260    /// Injects events into a target.
261    ///
262    /// Batching: The caller is expected to batch-inject all events that share the
263    /// same timestamp (e.g., multiple finger samples). There may be multiple such
264    /// batches per injection call.
265    ///
266    /// Flow control: The caller is allowed at most one in-flight |Inject| call
267    /// at at time: subsequent |Inject| calls must wait until the acknowledgment
268    /// returns. Non-compliance results in channel closure.
269    pub fn r#inject(
270        &self,
271        mut events: &[Event],
272    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
273        DeviceProxyInterface::r#inject(self, events)
274    }
275}
276
277impl DeviceProxyInterface for DeviceProxy {
278    type InjectResponseFut =
279        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
280    fn r#inject(&self, mut events: &[Event]) -> Self::InjectResponseFut {
281        fn _decode(
282            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
283        ) -> Result<(), fidl::Error> {
284            let _response = fidl::client::decode_transaction_body::<
285                fidl::encoding::EmptyPayload,
286                fidl::encoding::DefaultFuchsiaResourceDialect,
287                0x123882bb65bff40,
288            >(_buf?)?;
289            Ok(_response)
290        }
291        self.client.send_query_and_decode::<DeviceInjectRequest, ()>(
292            (events,),
293            0x123882bb65bff40,
294            fidl::encoding::DynamicFlags::empty(),
295            _decode,
296        )
297    }
298}
299
300pub struct DeviceEventStream {
301    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
302}
303
304impl std::marker::Unpin for DeviceEventStream {}
305
306impl futures::stream::FusedStream for DeviceEventStream {
307    fn is_terminated(&self) -> bool {
308        self.event_receiver.is_terminated()
309    }
310}
311
312impl futures::Stream for DeviceEventStream {
313    type Item = Result<DeviceEvent, fidl::Error>;
314
315    fn poll_next(
316        mut self: std::pin::Pin<&mut Self>,
317        cx: &mut std::task::Context<'_>,
318    ) -> std::task::Poll<Option<Self::Item>> {
319        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
320            &mut self.event_receiver,
321            cx
322        )?) {
323            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
324            None => std::task::Poll::Ready(None),
325        }
326    }
327}
328
329#[derive(Debug)]
330pub enum DeviceEvent {}
331
332impl DeviceEvent {
333    /// Decodes a message buffer as a [`DeviceEvent`].
334    fn decode(
335        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
336    ) -> Result<DeviceEvent, fidl::Error> {
337        let (bytes, _handles) = buf.split_mut();
338        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
339        debug_assert_eq!(tx_header.tx_id, 0);
340        match tx_header.ordinal {
341            _ => Err(fidl::Error::UnknownOrdinal {
342                ordinal: tx_header.ordinal,
343                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
344            }),
345        }
346    }
347}
348
349/// A Stream of incoming requests for fuchsia.ui.pointerinjector/Device.
350pub struct DeviceRequestStream {
351    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
352    is_terminated: bool,
353}
354
355impl std::marker::Unpin for DeviceRequestStream {}
356
357impl futures::stream::FusedStream for DeviceRequestStream {
358    fn is_terminated(&self) -> bool {
359        self.is_terminated
360    }
361}
362
363impl fidl::endpoints::RequestStream for DeviceRequestStream {
364    type Protocol = DeviceMarker;
365    type ControlHandle = DeviceControlHandle;
366
367    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
368        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
369    }
370
371    fn control_handle(&self) -> Self::ControlHandle {
372        DeviceControlHandle { inner: self.inner.clone() }
373    }
374
375    fn into_inner(
376        self,
377    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
378    {
379        (self.inner, self.is_terminated)
380    }
381
382    fn from_inner(
383        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
384        is_terminated: bool,
385    ) -> Self {
386        Self { inner, is_terminated }
387    }
388}
389
390impl futures::Stream for DeviceRequestStream {
391    type Item = Result<DeviceRequest, fidl::Error>;
392
393    fn poll_next(
394        mut self: std::pin::Pin<&mut Self>,
395        cx: &mut std::task::Context<'_>,
396    ) -> std::task::Poll<Option<Self::Item>> {
397        let this = &mut *self;
398        if this.inner.check_shutdown(cx) {
399            this.is_terminated = true;
400            return std::task::Poll::Ready(None);
401        }
402        if this.is_terminated {
403            panic!("polled DeviceRequestStream after completion");
404        }
405        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
406            |bytes, handles| {
407                match this.inner.channel().read_etc(cx, bytes, handles) {
408                    std::task::Poll::Ready(Ok(())) => {}
409                    std::task::Poll::Pending => return std::task::Poll::Pending,
410                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
411                        this.is_terminated = true;
412                        return std::task::Poll::Ready(None);
413                    }
414                    std::task::Poll::Ready(Err(e)) => {
415                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
416                            e.into(),
417                        ))))
418                    }
419                }
420
421                // A message has been received from the channel
422                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
423
424                std::task::Poll::Ready(Some(match header.ordinal {
425                    0x123882bb65bff40 => {
426                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
427                        let mut req = fidl::new_empty!(
428                            DeviceInjectRequest,
429                            fidl::encoding::DefaultFuchsiaResourceDialect
430                        );
431                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceInjectRequest>(&header, _body_bytes, handles, &mut req)?;
432                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
433                        Ok(DeviceRequest::Inject {
434                            events: req.events,
435
436                            responder: DeviceInjectResponder {
437                                control_handle: std::mem::ManuallyDrop::new(control_handle),
438                                tx_id: header.tx_id,
439                            },
440                        })
441                    }
442                    _ => Err(fidl::Error::UnknownOrdinal {
443                        ordinal: header.ordinal,
444                        protocol_name:
445                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
446                    }),
447                }))
448            },
449        )
450    }
451}
452
453/// The channel for injecting pointer events into a target.
454/// The associated |Config| applies to injected pointer events.
455///
456/// A |Device| may *inject* pointer events into a target in the scene, but the
457/// *dispatch* of pointer events to UI clients within that target's view tree
458/// will depend on the dispatch policy and the scene topology.
459#[derive(Debug)]
460pub enum DeviceRequest {
461    /// Injects events into a target.
462    ///
463    /// Batching: The caller is expected to batch-inject all events that share the
464    /// same timestamp (e.g., multiple finger samples). There may be multiple such
465    /// batches per injection call.
466    ///
467    /// Flow control: The caller is allowed at most one in-flight |Inject| call
468    /// at at time: subsequent |Inject| calls must wait until the acknowledgment
469    /// returns. Non-compliance results in channel closure.
470    Inject { events: Vec<Event>, responder: DeviceInjectResponder },
471}
472
473impl DeviceRequest {
474    #[allow(irrefutable_let_patterns)]
475    pub fn into_inject(self) -> Option<(Vec<Event>, DeviceInjectResponder)> {
476        if let DeviceRequest::Inject { events, responder } = self {
477            Some((events, responder))
478        } else {
479            None
480        }
481    }
482
483    /// Name of the method defined in FIDL
484    pub fn method_name(&self) -> &'static str {
485        match *self {
486            DeviceRequest::Inject { .. } => "inject",
487        }
488    }
489}
490
491#[derive(Debug, Clone)]
492pub struct DeviceControlHandle {
493    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
494}
495
496impl fidl::endpoints::ControlHandle for DeviceControlHandle {
497    fn shutdown(&self) {
498        self.inner.shutdown()
499    }
500    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
501        self.inner.shutdown_with_epitaph(status)
502    }
503
504    fn is_closed(&self) -> bool {
505        self.inner.channel().is_closed()
506    }
507    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
508        self.inner.channel().on_closed()
509    }
510
511    #[cfg(target_os = "fuchsia")]
512    fn signal_peer(
513        &self,
514        clear_mask: zx::Signals,
515        set_mask: zx::Signals,
516    ) -> Result<(), zx_status::Status> {
517        use fidl::Peered;
518        self.inner.channel().signal_peer(clear_mask, set_mask)
519    }
520}
521
522impl DeviceControlHandle {}
523
524#[must_use = "FIDL methods require a response to be sent"]
525#[derive(Debug)]
526pub struct DeviceInjectResponder {
527    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
528    tx_id: u32,
529}
530
531/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
532/// if the responder is dropped without sending a response, so that the client
533/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
534impl std::ops::Drop for DeviceInjectResponder {
535    fn drop(&mut self) {
536        self.control_handle.shutdown();
537        // Safety: drops once, never accessed again
538        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
539    }
540}
541
542impl fidl::endpoints::Responder for DeviceInjectResponder {
543    type ControlHandle = DeviceControlHandle;
544
545    fn control_handle(&self) -> &DeviceControlHandle {
546        &self.control_handle
547    }
548
549    fn drop_without_shutdown(mut self) {
550        // Safety: drops once, never accessed again due to mem::forget
551        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
552        // Prevent Drop from running (which would shut down the channel)
553        std::mem::forget(self);
554    }
555}
556
557impl DeviceInjectResponder {
558    /// Sends a response to the FIDL transaction.
559    ///
560    /// Sets the channel to shutdown if an error occurs.
561    pub fn send(self) -> Result<(), fidl::Error> {
562        let _result = self.send_raw();
563        if _result.is_err() {
564            self.control_handle.shutdown();
565        }
566        self.drop_without_shutdown();
567        _result
568    }
569
570    /// Similar to "send" but does not shutdown the channel if an error occurs.
571    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
572        let _result = self.send_raw();
573        self.drop_without_shutdown();
574        _result
575    }
576
577    fn send_raw(&self) -> Result<(), fidl::Error> {
578        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
579            (),
580            self.tx_id,
581            0x123882bb65bff40,
582            fidl::encoding::DynamicFlags::empty(),
583        )
584    }
585}
586
587#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
588pub struct RegistryMarker;
589
590impl fidl::endpoints::ProtocolMarker for RegistryMarker {
591    type Proxy = RegistryProxy;
592    type RequestStream = RegistryRequestStream;
593    #[cfg(target_os = "fuchsia")]
594    type SynchronousProxy = RegistrySynchronousProxy;
595
596    const DEBUG_NAME: &'static str = "fuchsia.ui.pointerinjector.Registry";
597}
598impl fidl::endpoints::DiscoverableProtocolMarker for RegistryMarker {}
599
600pub trait RegistryProxyInterface: Send + Sync {
601    type RegisterResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
602    fn r#register(
603        &self,
604        config: Config,
605        injector: fidl::endpoints::ServerEnd<DeviceMarker>,
606    ) -> Self::RegisterResponseFut;
607}
608#[derive(Debug)]
609#[cfg(target_os = "fuchsia")]
610pub struct RegistrySynchronousProxy {
611    client: fidl::client::sync::Client,
612}
613
614#[cfg(target_os = "fuchsia")]
615impl fidl::endpoints::SynchronousProxy for RegistrySynchronousProxy {
616    type Proxy = RegistryProxy;
617    type Protocol = RegistryMarker;
618
619    fn from_channel(inner: fidl::Channel) -> Self {
620        Self::new(inner)
621    }
622
623    fn into_channel(self) -> fidl::Channel {
624        self.client.into_channel()
625    }
626
627    fn as_channel(&self) -> &fidl::Channel {
628        self.client.as_channel()
629    }
630}
631
632#[cfg(target_os = "fuchsia")]
633impl RegistrySynchronousProxy {
634    pub fn new(channel: fidl::Channel) -> Self {
635        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
636        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
637    }
638
639    pub fn into_channel(self) -> fidl::Channel {
640        self.client.into_channel()
641    }
642
643    /// Waits until an event arrives and returns it. It is safe for other
644    /// threads to make concurrent requests while waiting for an event.
645    pub fn wait_for_event(
646        &self,
647        deadline: zx::MonotonicInstant,
648    ) -> Result<RegistryEvent, fidl::Error> {
649        RegistryEvent::decode(self.client.wait_for_event(deadline)?)
650    }
651
652    /// Sets up a context for a |Device|, the target for the |Device|, and
653    /// directs the |Device| at the target via a viewport, positioned in the
654    /// context. These parameters are specified in a |Config|.
655    ///
656    /// If |config| is invalid (e.g., missing important data), the |Device|
657    /// request will be denied: the channel will be closed.
658    ///
659    /// The return event tells the caller that (1) the server has processed the
660    /// call, and (2) the |Device| is connected.
661    pub fn r#register(
662        &self,
663        mut config: Config,
664        mut injector: fidl::endpoints::ServerEnd<DeviceMarker>,
665        ___deadline: zx::MonotonicInstant,
666    ) -> Result<(), fidl::Error> {
667        let _response =
668            self.client.send_query::<RegistryRegisterRequest, fidl::encoding::EmptyPayload>(
669                (&mut config, injector),
670                0x9f8410fe7326a00,
671                fidl::encoding::DynamicFlags::empty(),
672                ___deadline,
673            )?;
674        Ok(_response)
675    }
676}
677
678#[cfg(target_os = "fuchsia")]
679impl From<RegistrySynchronousProxy> for zx::Handle {
680    fn from(value: RegistrySynchronousProxy) -> Self {
681        value.into_channel().into()
682    }
683}
684
685#[cfg(target_os = "fuchsia")]
686impl From<fidl::Channel> for RegistrySynchronousProxy {
687    fn from(value: fidl::Channel) -> Self {
688        Self::new(value)
689    }
690}
691
692#[derive(Debug, Clone)]
693pub struct RegistryProxy {
694    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
695}
696
697impl fidl::endpoints::Proxy for RegistryProxy {
698    type Protocol = RegistryMarker;
699
700    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
701        Self::new(inner)
702    }
703
704    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
705        self.client.into_channel().map_err(|client| Self { client })
706    }
707
708    fn as_channel(&self) -> &::fidl::AsyncChannel {
709        self.client.as_channel()
710    }
711}
712
713impl RegistryProxy {
714    /// Create a new Proxy for fuchsia.ui.pointerinjector/Registry.
715    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
716        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
717        Self { client: fidl::client::Client::new(channel, protocol_name) }
718    }
719
720    /// Get a Stream of events from the remote end of the protocol.
721    ///
722    /// # Panics
723    ///
724    /// Panics if the event stream was already taken.
725    pub fn take_event_stream(&self) -> RegistryEventStream {
726        RegistryEventStream { event_receiver: self.client.take_event_receiver() }
727    }
728
729    /// Sets up a context for a |Device|, the target for the |Device|, and
730    /// directs the |Device| at the target via a viewport, positioned in the
731    /// context. These parameters are specified in a |Config|.
732    ///
733    /// If |config| is invalid (e.g., missing important data), the |Device|
734    /// request will be denied: the channel will be closed.
735    ///
736    /// The return event tells the caller that (1) the server has processed the
737    /// call, and (2) the |Device| is connected.
738    pub fn r#register(
739        &self,
740        mut config: Config,
741        mut injector: fidl::endpoints::ServerEnd<DeviceMarker>,
742    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
743        RegistryProxyInterface::r#register(self, config, injector)
744    }
745}
746
747impl RegistryProxyInterface for RegistryProxy {
748    type RegisterResponseFut =
749        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
750    fn r#register(
751        &self,
752        mut config: Config,
753        mut injector: fidl::endpoints::ServerEnd<DeviceMarker>,
754    ) -> Self::RegisterResponseFut {
755        fn _decode(
756            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
757        ) -> Result<(), fidl::Error> {
758            let _response = fidl::client::decode_transaction_body::<
759                fidl::encoding::EmptyPayload,
760                fidl::encoding::DefaultFuchsiaResourceDialect,
761                0x9f8410fe7326a00,
762            >(_buf?)?;
763            Ok(_response)
764        }
765        self.client.send_query_and_decode::<RegistryRegisterRequest, ()>(
766            (&mut config, injector),
767            0x9f8410fe7326a00,
768            fidl::encoding::DynamicFlags::empty(),
769            _decode,
770        )
771    }
772}
773
774pub struct RegistryEventStream {
775    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
776}
777
778impl std::marker::Unpin for RegistryEventStream {}
779
780impl futures::stream::FusedStream for RegistryEventStream {
781    fn is_terminated(&self) -> bool {
782        self.event_receiver.is_terminated()
783    }
784}
785
786impl futures::Stream for RegistryEventStream {
787    type Item = Result<RegistryEvent, fidl::Error>;
788
789    fn poll_next(
790        mut self: std::pin::Pin<&mut Self>,
791        cx: &mut std::task::Context<'_>,
792    ) -> std::task::Poll<Option<Self::Item>> {
793        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
794            &mut self.event_receiver,
795            cx
796        )?) {
797            Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
798            None => std::task::Poll::Ready(None),
799        }
800    }
801}
802
803#[derive(Debug)]
804pub enum RegistryEvent {}
805
806impl RegistryEvent {
807    /// Decodes a message buffer as a [`RegistryEvent`].
808    fn decode(
809        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
810    ) -> Result<RegistryEvent, fidl::Error> {
811        let (bytes, _handles) = buf.split_mut();
812        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
813        debug_assert_eq!(tx_header.tx_id, 0);
814        match tx_header.ordinal {
815            _ => Err(fidl::Error::UnknownOrdinal {
816                ordinal: tx_header.ordinal,
817                protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
818            }),
819        }
820    }
821}
822
823/// A Stream of incoming requests for fuchsia.ui.pointerinjector/Registry.
824pub struct RegistryRequestStream {
825    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
826    is_terminated: bool,
827}
828
829impl std::marker::Unpin for RegistryRequestStream {}
830
831impl futures::stream::FusedStream for RegistryRequestStream {
832    fn is_terminated(&self) -> bool {
833        self.is_terminated
834    }
835}
836
837impl fidl::endpoints::RequestStream for RegistryRequestStream {
838    type Protocol = RegistryMarker;
839    type ControlHandle = RegistryControlHandle;
840
841    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
842        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
843    }
844
845    fn control_handle(&self) -> Self::ControlHandle {
846        RegistryControlHandle { inner: self.inner.clone() }
847    }
848
849    fn into_inner(
850        self,
851    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
852    {
853        (self.inner, self.is_terminated)
854    }
855
856    fn from_inner(
857        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
858        is_terminated: bool,
859    ) -> Self {
860        Self { inner, is_terminated }
861    }
862}
863
864impl futures::Stream for RegistryRequestStream {
865    type Item = Result<RegistryRequest, fidl::Error>;
866
867    fn poll_next(
868        mut self: std::pin::Pin<&mut Self>,
869        cx: &mut std::task::Context<'_>,
870    ) -> std::task::Poll<Option<Self::Item>> {
871        let this = &mut *self;
872        if this.inner.check_shutdown(cx) {
873            this.is_terminated = true;
874            return std::task::Poll::Ready(None);
875        }
876        if this.is_terminated {
877            panic!("polled RegistryRequestStream after completion");
878        }
879        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
880            |bytes, handles| {
881                match this.inner.channel().read_etc(cx, bytes, handles) {
882                    std::task::Poll::Ready(Ok(())) => {}
883                    std::task::Poll::Pending => return std::task::Poll::Pending,
884                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
885                        this.is_terminated = true;
886                        return std::task::Poll::Ready(None);
887                    }
888                    std::task::Poll::Ready(Err(e)) => {
889                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
890                            e.into(),
891                        ))))
892                    }
893                }
894
895                // A message has been received from the channel
896                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
897
898                std::task::Poll::Ready(Some(match header.ordinal {
899                    0x9f8410fe7326a00 => {
900                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
901                        let mut req = fidl::new_empty!(
902                            RegistryRegisterRequest,
903                            fidl::encoding::DefaultFuchsiaResourceDialect
904                        );
905                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
906                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
907                        Ok(RegistryRequest::Register {
908                            config: req.config,
909                            injector: req.injector,
910
911                            responder: RegistryRegisterResponder {
912                                control_handle: std::mem::ManuallyDrop::new(control_handle),
913                                tx_id: header.tx_id,
914                            },
915                        })
916                    }
917                    _ => Err(fidl::Error::UnknownOrdinal {
918                        ordinal: header.ordinal,
919                        protocol_name:
920                            <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
921                    }),
922                }))
923            },
924        )
925    }
926}
927
928/// A coordination mechanism to clearly define the *injecting* of pointer events
929/// into the scene (injection policy, injection context, etc), for *dispatching*
930/// pointer events to UI clients (referenced by |fuchsia.ui.views.ViewRef|).
931///
932/// NOTE WELL! ONLY COMPONENTS IN THE TRUSTED COMPUTING BASE SHOULD BE GRANTED
933///            ACCESS TO THIS PROTOCOL.
934/// (1) The injector device acts with the user's authority. UI clients cannot
935///     tell the difference between a real user and an injector device.
936/// (2) The context is self-specified when registering the injector device. An
937///     injector device that gains access to a sensitive context will operate in
938///     that scope.
939/// (3) The injected events may be arbitrary. An injector device can inject
940///     whatever it wants to the clients it can reach.
941///
942/// This protocol defines the context and target for an injector |Device|,
943/// places a viewport in spatial relation to the target, and connects the
944/// |Device| to the viewport. These parameters are set up in the |Config|. A
945/// |Device| may *inject* pointer events on the viewport, but the *dispatch* of
946/// pointer events to UI clients in the target will depend on the dispatch
947/// policy and the scene topology.
948///
949/// A |Device| operates within a context, and it serves two purposes:
950/// (1) Scoping. It confirms the |Device|'s authority to inject pointer events
951///     on the specified target.
952/// (2) Coordinate system. It provides the reference coordinate system to define
953///     the viewport's position and size, relative to the target.
954///
955/// Guarantees. A |Device| is directed at a specified target in the scene, and
956/// such a target is afforded some guarantees against snooping and interference
957/// from UI clients outside the target's view tree ("non-target clients").
958/// Non-target clients never have injected events dispatched to them: a |Device|
959/// preserves *confidentiality* for target clients.  Non-target clients never
960/// block injected events from reaching the target on injection, or from
961/// reaching target clients on dispatch: a |Device| preserves *integrity* and
962/// *availability* for target clients. However, the |Device| itself is subject
963/// to disruption by ancestor views of the target (see connectivity invariant).
964///
965/// Note. This protocol, and its policies, are *not* a sufficient guard against
966///       UI redress attacks! The confidentiality, integrity, and availability
967///       guarantees apply only with respect to non-target clients. Within a
968///       target, UI redress attacks can still happen, between target clients.
969///
970/// Connectivity invariant. A |Device| operates in a stable view tree that is
971/// connected to the root view. When either the target, or both context and
972/// target, are disconnected from the view tree by a UI client, the |Device|
973/// channel is closed. If an event stream was in flight, the server dispatches a
974/// final CANCEL event following channel closure; this CANCEL event is then
975/// propagated according to dispatch policy.
976#[derive(Debug)]
977pub enum RegistryRequest {
978    /// Sets up a context for a |Device|, the target for the |Device|, and
979    /// directs the |Device| at the target via a viewport, positioned in the
980    /// context. These parameters are specified in a |Config|.
981    ///
982    /// If |config| is invalid (e.g., missing important data), the |Device|
983    /// request will be denied: the channel will be closed.
984    ///
985    /// The return event tells the caller that (1) the server has processed the
986    /// call, and (2) the |Device| is connected.
987    Register {
988        config: Config,
989        injector: fidl::endpoints::ServerEnd<DeviceMarker>,
990        responder: RegistryRegisterResponder,
991    },
992}
993
994impl RegistryRequest {
995    #[allow(irrefutable_let_patterns)]
996    pub fn into_register(
997        self,
998    ) -> Option<(Config, fidl::endpoints::ServerEnd<DeviceMarker>, RegistryRegisterResponder)> {
999        if let RegistryRequest::Register { config, injector, responder } = self {
1000            Some((config, injector, responder))
1001        } else {
1002            None
1003        }
1004    }
1005
1006    /// Name of the method defined in FIDL
1007    pub fn method_name(&self) -> &'static str {
1008        match *self {
1009            RegistryRequest::Register { .. } => "register",
1010        }
1011    }
1012}
1013
1014#[derive(Debug, Clone)]
1015pub struct RegistryControlHandle {
1016    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1017}
1018
1019impl fidl::endpoints::ControlHandle for RegistryControlHandle {
1020    fn shutdown(&self) {
1021        self.inner.shutdown()
1022    }
1023    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1024        self.inner.shutdown_with_epitaph(status)
1025    }
1026
1027    fn is_closed(&self) -> bool {
1028        self.inner.channel().is_closed()
1029    }
1030    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1031        self.inner.channel().on_closed()
1032    }
1033
1034    #[cfg(target_os = "fuchsia")]
1035    fn signal_peer(
1036        &self,
1037        clear_mask: zx::Signals,
1038        set_mask: zx::Signals,
1039    ) -> Result<(), zx_status::Status> {
1040        use fidl::Peered;
1041        self.inner.channel().signal_peer(clear_mask, set_mask)
1042    }
1043}
1044
1045impl RegistryControlHandle {}
1046
1047#[must_use = "FIDL methods require a response to be sent"]
1048#[derive(Debug)]
1049pub struct RegistryRegisterResponder {
1050    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
1051    tx_id: u32,
1052}
1053
1054/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
1055/// if the responder is dropped without sending a response, so that the client
1056/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1057impl std::ops::Drop for RegistryRegisterResponder {
1058    fn drop(&mut self) {
1059        self.control_handle.shutdown();
1060        // Safety: drops once, never accessed again
1061        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1062    }
1063}
1064
1065impl fidl::endpoints::Responder for RegistryRegisterResponder {
1066    type ControlHandle = RegistryControlHandle;
1067
1068    fn control_handle(&self) -> &RegistryControlHandle {
1069        &self.control_handle
1070    }
1071
1072    fn drop_without_shutdown(mut self) {
1073        // Safety: drops once, never accessed again due to mem::forget
1074        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1075        // Prevent Drop from running (which would shut down the channel)
1076        std::mem::forget(self);
1077    }
1078}
1079
1080impl RegistryRegisterResponder {
1081    /// Sends a response to the FIDL transaction.
1082    ///
1083    /// Sets the channel to shutdown if an error occurs.
1084    pub fn send(self) -> Result<(), fidl::Error> {
1085        let _result = self.send_raw();
1086        if _result.is_err() {
1087            self.control_handle.shutdown();
1088        }
1089        self.drop_without_shutdown();
1090        _result
1091    }
1092
1093    /// Similar to "send" but does not shutdown the channel if an error occurs.
1094    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1095        let _result = self.send_raw();
1096        self.drop_without_shutdown();
1097        _result
1098    }
1099
1100    fn send_raw(&self) -> Result<(), fidl::Error> {
1101        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1102            (),
1103            self.tx_id,
1104            0x9f8410fe7326a00,
1105            fidl::encoding::DynamicFlags::empty(),
1106        )
1107    }
1108}
1109
1110mod internal {
1111    use super::*;
1112
1113    impl fidl::encoding::ResourceTypeMarker for RegistryRegisterRequest {
1114        type Borrowed<'a> = &'a mut Self;
1115        fn take_or_borrow<'a>(
1116            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1117        ) -> Self::Borrowed<'a> {
1118            value
1119        }
1120    }
1121
1122    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterRequest {
1123        type Owned = Self;
1124
1125        #[inline(always)]
1126        fn inline_align(_context: fidl::encoding::Context) -> usize {
1127            8
1128        }
1129
1130        #[inline(always)]
1131        fn inline_size(_context: fidl::encoding::Context) -> usize {
1132            24
1133        }
1134    }
1135
1136    unsafe impl
1137        fidl::encoding::Encode<
1138            RegistryRegisterRequest,
1139            fidl::encoding::DefaultFuchsiaResourceDialect,
1140        > for &mut RegistryRegisterRequest
1141    {
1142        #[inline]
1143        unsafe fn encode(
1144            self,
1145            encoder: &mut fidl::encoding::Encoder<
1146                '_,
1147                fidl::encoding::DefaultFuchsiaResourceDialect,
1148            >,
1149            offset: usize,
1150            _depth: fidl::encoding::Depth,
1151        ) -> fidl::Result<()> {
1152            encoder.debug_check_bounds::<RegistryRegisterRequest>(offset);
1153            // Delegate to tuple encoding.
1154            fidl::encoding::Encode::<RegistryRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1155                (
1156                    <Config as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.config),
1157                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.injector),
1158                ),
1159                encoder, offset, _depth
1160            )
1161        }
1162    }
1163    unsafe impl<
1164            T0: fidl::encoding::Encode<Config, fidl::encoding::DefaultFuchsiaResourceDialect>,
1165            T1: fidl::encoding::Encode<
1166                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1167                fidl::encoding::DefaultFuchsiaResourceDialect,
1168            >,
1169        >
1170        fidl::encoding::Encode<
1171            RegistryRegisterRequest,
1172            fidl::encoding::DefaultFuchsiaResourceDialect,
1173        > for (T0, T1)
1174    {
1175        #[inline]
1176        unsafe fn encode(
1177            self,
1178            encoder: &mut fidl::encoding::Encoder<
1179                '_,
1180                fidl::encoding::DefaultFuchsiaResourceDialect,
1181            >,
1182            offset: usize,
1183            depth: fidl::encoding::Depth,
1184        ) -> fidl::Result<()> {
1185            encoder.debug_check_bounds::<RegistryRegisterRequest>(offset);
1186            // Zero out padding regions. There's no need to apply masks
1187            // because the unmasked parts will be overwritten by fields.
1188            unsafe {
1189                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1190                (ptr as *mut u64).write_unaligned(0);
1191            }
1192            // Write the fields.
1193            self.0.encode(encoder, offset + 0, depth)?;
1194            self.1.encode(encoder, offset + 16, depth)?;
1195            Ok(())
1196        }
1197    }
1198
1199    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1200        for RegistryRegisterRequest
1201    {
1202        #[inline(always)]
1203        fn new_empty() -> Self {
1204            Self {
1205                config: fidl::new_empty!(Config, fidl::encoding::DefaultFuchsiaResourceDialect),
1206                injector: fidl::new_empty!(
1207                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1208                    fidl::encoding::DefaultFuchsiaResourceDialect
1209                ),
1210            }
1211        }
1212
1213        #[inline]
1214        unsafe fn decode(
1215            &mut self,
1216            decoder: &mut fidl::encoding::Decoder<
1217                '_,
1218                fidl::encoding::DefaultFuchsiaResourceDialect,
1219            >,
1220            offset: usize,
1221            _depth: fidl::encoding::Depth,
1222        ) -> fidl::Result<()> {
1223            decoder.debug_check_bounds::<Self>(offset);
1224            // Verify that padding bytes are zero.
1225            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1226            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1227            let mask = 0xffffffff00000000u64;
1228            let maskedval = padval & mask;
1229            if maskedval != 0 {
1230                return Err(fidl::Error::NonZeroPadding {
1231                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1232                });
1233            }
1234            fidl::decode!(
1235                Config,
1236                fidl::encoding::DefaultFuchsiaResourceDialect,
1237                &mut self.config,
1238                decoder,
1239                offset + 0,
1240                _depth
1241            )?;
1242            fidl::decode!(
1243                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1244                fidl::encoding::DefaultFuchsiaResourceDialect,
1245                &mut self.injector,
1246                decoder,
1247                offset + 16,
1248                _depth
1249            )?;
1250            Ok(())
1251        }
1252    }
1253
1254    impl Config {
1255        #[inline(always)]
1256        fn max_ordinal_present(&self) -> u64 {
1257            if let Some(_) = self.relative_motion_range {
1258                return 10;
1259            }
1260            if let Some(_) = self.buttons {
1261                return 9;
1262            }
1263            if let Some(_) = self.scroll_h_range {
1264                return 8;
1265            }
1266            if let Some(_) = self.scroll_v_range {
1267                return 7;
1268            }
1269            if let Some(_) = self.dispatch_policy {
1270                return 6;
1271            }
1272            if let Some(_) = self.viewport {
1273                return 5;
1274            }
1275            if let Some(_) = self.target {
1276                return 4;
1277            }
1278            if let Some(_) = self.context {
1279                return 3;
1280            }
1281            if let Some(_) = self.device_type {
1282                return 2;
1283            }
1284            if let Some(_) = self.device_id {
1285                return 1;
1286            }
1287            0
1288        }
1289    }
1290
1291    impl fidl::encoding::ResourceTypeMarker for Config {
1292        type Borrowed<'a> = &'a mut Self;
1293        fn take_or_borrow<'a>(
1294            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1295        ) -> Self::Borrowed<'a> {
1296            value
1297        }
1298    }
1299
1300    unsafe impl fidl::encoding::TypeMarker for Config {
1301        type Owned = Self;
1302
1303        #[inline(always)]
1304        fn inline_align(_context: fidl::encoding::Context) -> usize {
1305            8
1306        }
1307
1308        #[inline(always)]
1309        fn inline_size(_context: fidl::encoding::Context) -> usize {
1310            16
1311        }
1312    }
1313
1314    unsafe impl fidl::encoding::Encode<Config, fidl::encoding::DefaultFuchsiaResourceDialect>
1315        for &mut Config
1316    {
1317        unsafe fn encode(
1318            self,
1319            encoder: &mut fidl::encoding::Encoder<
1320                '_,
1321                fidl::encoding::DefaultFuchsiaResourceDialect,
1322            >,
1323            offset: usize,
1324            mut depth: fidl::encoding::Depth,
1325        ) -> fidl::Result<()> {
1326            encoder.debug_check_bounds::<Config>(offset);
1327            // Vector header
1328            let max_ordinal: u64 = self.max_ordinal_present();
1329            encoder.write_num(max_ordinal, offset);
1330            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1331            // Calling encoder.out_of_line_offset(0) is not allowed.
1332            if max_ordinal == 0 {
1333                return Ok(());
1334            }
1335            depth.increment()?;
1336            let envelope_size = 8;
1337            let bytes_len = max_ordinal as usize * envelope_size;
1338            #[allow(unused_variables)]
1339            let offset = encoder.out_of_line_offset(bytes_len);
1340            let mut _prev_end_offset: usize = 0;
1341            if 1 > max_ordinal {
1342                return Ok(());
1343            }
1344
1345            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1346            // are envelope_size bytes.
1347            let cur_offset: usize = (1 - 1) * envelope_size;
1348
1349            // Zero reserved fields.
1350            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1351
1352            // Safety:
1353            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1354            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1355            //   envelope_size bytes, there is always sufficient room.
1356            fidl::encoding::encode_in_envelope_optional::<
1357                u32,
1358                fidl::encoding::DefaultFuchsiaResourceDialect,
1359            >(
1360                self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1361                encoder,
1362                offset + cur_offset,
1363                depth,
1364            )?;
1365
1366            _prev_end_offset = cur_offset + envelope_size;
1367            if 2 > max_ordinal {
1368                return Ok(());
1369            }
1370
1371            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1372            // are envelope_size bytes.
1373            let cur_offset: usize = (2 - 1) * envelope_size;
1374
1375            // Zero reserved fields.
1376            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1377
1378            // Safety:
1379            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1380            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1381            //   envelope_size bytes, there is always sufficient room.
1382            fidl::encoding::encode_in_envelope_optional::<
1383                DeviceType,
1384                fidl::encoding::DefaultFuchsiaResourceDialect,
1385            >(
1386                self.device_type
1387                    .as_ref()
1388                    .map(<DeviceType as fidl::encoding::ValueTypeMarker>::borrow),
1389                encoder,
1390                offset + cur_offset,
1391                depth,
1392            )?;
1393
1394            _prev_end_offset = cur_offset + envelope_size;
1395            if 3 > max_ordinal {
1396                return Ok(());
1397            }
1398
1399            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1400            // are envelope_size bytes.
1401            let cur_offset: usize = (3 - 1) * envelope_size;
1402
1403            // Zero reserved fields.
1404            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1405
1406            // Safety:
1407            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1408            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1409            //   envelope_size bytes, there is always sufficient room.
1410            fidl::encoding::encode_in_envelope_optional::<
1411                Context,
1412                fidl::encoding::DefaultFuchsiaResourceDialect,
1413            >(
1414                self.context
1415                    .as_mut()
1416                    .map(<Context as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1417                encoder,
1418                offset + cur_offset,
1419                depth,
1420            )?;
1421
1422            _prev_end_offset = cur_offset + envelope_size;
1423            if 4 > max_ordinal {
1424                return Ok(());
1425            }
1426
1427            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1428            // are envelope_size bytes.
1429            let cur_offset: usize = (4 - 1) * envelope_size;
1430
1431            // Zero reserved fields.
1432            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1433
1434            // Safety:
1435            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1436            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1437            //   envelope_size bytes, there is always sufficient room.
1438            fidl::encoding::encode_in_envelope_optional::<
1439                Target,
1440                fidl::encoding::DefaultFuchsiaResourceDialect,
1441            >(
1442                self.target
1443                    .as_mut()
1444                    .map(<Target as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1445                encoder,
1446                offset + cur_offset,
1447                depth,
1448            )?;
1449
1450            _prev_end_offset = cur_offset + envelope_size;
1451            if 5 > max_ordinal {
1452                return Ok(());
1453            }
1454
1455            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1456            // are envelope_size bytes.
1457            let cur_offset: usize = (5 - 1) * envelope_size;
1458
1459            // Zero reserved fields.
1460            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1461
1462            // Safety:
1463            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1464            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1465            //   envelope_size bytes, there is always sufficient room.
1466            fidl::encoding::encode_in_envelope_optional::<
1467                Viewport,
1468                fidl::encoding::DefaultFuchsiaResourceDialect,
1469            >(
1470                self.viewport.as_ref().map(<Viewport as fidl::encoding::ValueTypeMarker>::borrow),
1471                encoder,
1472                offset + cur_offset,
1473                depth,
1474            )?;
1475
1476            _prev_end_offset = cur_offset + envelope_size;
1477            if 6 > max_ordinal {
1478                return Ok(());
1479            }
1480
1481            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1482            // are envelope_size bytes.
1483            let cur_offset: usize = (6 - 1) * envelope_size;
1484
1485            // Zero reserved fields.
1486            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1487
1488            // Safety:
1489            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1490            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1491            //   envelope_size bytes, there is always sufficient room.
1492            fidl::encoding::encode_in_envelope_optional::<
1493                DispatchPolicy,
1494                fidl::encoding::DefaultFuchsiaResourceDialect,
1495            >(
1496                self.dispatch_policy
1497                    .as_ref()
1498                    .map(<DispatchPolicy as fidl::encoding::ValueTypeMarker>::borrow),
1499                encoder,
1500                offset + cur_offset,
1501                depth,
1502            )?;
1503
1504            _prev_end_offset = cur_offset + envelope_size;
1505            if 7 > max_ordinal {
1506                return Ok(());
1507            }
1508
1509            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1510            // are envelope_size bytes.
1511            let cur_offset: usize = (7 - 1) * envelope_size;
1512
1513            // Zero reserved fields.
1514            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1515
1516            // Safety:
1517            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1518            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1519            //   envelope_size bytes, there is always sufficient room.
1520            fidl::encoding::encode_in_envelope_optional::<
1521                fidl_fuchsia_input_report::Axis,
1522                fidl::encoding::DefaultFuchsiaResourceDialect,
1523            >(
1524                self.scroll_v_range.as_ref().map(
1525                    <fidl_fuchsia_input_report::Axis as fidl::encoding::ValueTypeMarker>::borrow,
1526                ),
1527                encoder,
1528                offset + cur_offset,
1529                depth,
1530            )?;
1531
1532            _prev_end_offset = cur_offset + envelope_size;
1533            if 8 > max_ordinal {
1534                return Ok(());
1535            }
1536
1537            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1538            // are envelope_size bytes.
1539            let cur_offset: usize = (8 - 1) * envelope_size;
1540
1541            // Zero reserved fields.
1542            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1543
1544            // Safety:
1545            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1546            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1547            //   envelope_size bytes, there is always sufficient room.
1548            fidl::encoding::encode_in_envelope_optional::<
1549                fidl_fuchsia_input_report::Axis,
1550                fidl::encoding::DefaultFuchsiaResourceDialect,
1551            >(
1552                self.scroll_h_range.as_ref().map(
1553                    <fidl_fuchsia_input_report::Axis as fidl::encoding::ValueTypeMarker>::borrow,
1554                ),
1555                encoder,
1556                offset + cur_offset,
1557                depth,
1558            )?;
1559
1560            _prev_end_offset = cur_offset + envelope_size;
1561            if 9 > max_ordinal {
1562                return Ok(());
1563            }
1564
1565            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1566            // are envelope_size bytes.
1567            let cur_offset: usize = (9 - 1) * envelope_size;
1568
1569            // Zero reserved fields.
1570            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1571
1572            // Safety:
1573            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1574            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1575            //   envelope_size bytes, there is always sufficient room.
1576            fidl::encoding::encode_in_envelope_optional::<
1577                fidl::encoding::Vector<u8, 32>,
1578                fidl::encoding::DefaultFuchsiaResourceDialect,
1579            >(
1580                self.buttons.as_ref().map(
1581                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow,
1582                ),
1583                encoder,
1584                offset + cur_offset,
1585                depth,
1586            )?;
1587
1588            _prev_end_offset = cur_offset + envelope_size;
1589            if 10 > max_ordinal {
1590                return Ok(());
1591            }
1592
1593            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1594            // are envelope_size bytes.
1595            let cur_offset: usize = (10 - 1) * envelope_size;
1596
1597            // Zero reserved fields.
1598            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1599
1600            // Safety:
1601            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1602            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1603            //   envelope_size bytes, there is always sufficient room.
1604            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<fidl_fuchsia_input_report::Axis, 2>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1605            self.relative_motion_range.as_ref().map(<fidl::encoding::Array<fidl_fuchsia_input_report::Axis, 2> as fidl::encoding::ValueTypeMarker>::borrow),
1606            encoder, offset + cur_offset, depth
1607        )?;
1608
1609            _prev_end_offset = cur_offset + envelope_size;
1610
1611            Ok(())
1612        }
1613    }
1614
1615    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Config {
1616        #[inline(always)]
1617        fn new_empty() -> Self {
1618            Self::default()
1619        }
1620
1621        unsafe fn decode(
1622            &mut self,
1623            decoder: &mut fidl::encoding::Decoder<
1624                '_,
1625                fidl::encoding::DefaultFuchsiaResourceDialect,
1626            >,
1627            offset: usize,
1628            mut depth: fidl::encoding::Depth,
1629        ) -> fidl::Result<()> {
1630            decoder.debug_check_bounds::<Self>(offset);
1631            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1632                None => return Err(fidl::Error::NotNullable),
1633                Some(len) => len,
1634            };
1635            // Calling decoder.out_of_line_offset(0) is not allowed.
1636            if len == 0 {
1637                return Ok(());
1638            };
1639            depth.increment()?;
1640            let envelope_size = 8;
1641            let bytes_len = len * envelope_size;
1642            let offset = decoder.out_of_line_offset(bytes_len)?;
1643            // Decode the envelope for each type.
1644            let mut _next_ordinal_to_read = 0;
1645            let mut next_offset = offset;
1646            let end_offset = offset + bytes_len;
1647            _next_ordinal_to_read += 1;
1648            if next_offset >= end_offset {
1649                return Ok(());
1650            }
1651
1652            // Decode unknown envelopes for gaps in ordinals.
1653            while _next_ordinal_to_read < 1 {
1654                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1655                _next_ordinal_to_read += 1;
1656                next_offset += envelope_size;
1657            }
1658
1659            let next_out_of_line = decoder.next_out_of_line();
1660            let handles_before = decoder.remaining_handles();
1661            if let Some((inlined, num_bytes, num_handles)) =
1662                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1663            {
1664                let member_inline_size =
1665                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1666                if inlined != (member_inline_size <= 4) {
1667                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1668                }
1669                let inner_offset;
1670                let mut inner_depth = depth.clone();
1671                if inlined {
1672                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1673                    inner_offset = next_offset;
1674                } else {
1675                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1676                    inner_depth.increment()?;
1677                }
1678                let val_ref = self.device_id.get_or_insert_with(|| {
1679                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1680                });
1681                fidl::decode!(
1682                    u32,
1683                    fidl::encoding::DefaultFuchsiaResourceDialect,
1684                    val_ref,
1685                    decoder,
1686                    inner_offset,
1687                    inner_depth
1688                )?;
1689                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1690                {
1691                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1692                }
1693                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1694                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1695                }
1696            }
1697
1698            next_offset += envelope_size;
1699            _next_ordinal_to_read += 1;
1700            if next_offset >= end_offset {
1701                return Ok(());
1702            }
1703
1704            // Decode unknown envelopes for gaps in ordinals.
1705            while _next_ordinal_to_read < 2 {
1706                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1707                _next_ordinal_to_read += 1;
1708                next_offset += envelope_size;
1709            }
1710
1711            let next_out_of_line = decoder.next_out_of_line();
1712            let handles_before = decoder.remaining_handles();
1713            if let Some((inlined, num_bytes, num_handles)) =
1714                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1715            {
1716                let member_inline_size =
1717                    <DeviceType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1718                if inlined != (member_inline_size <= 4) {
1719                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1720                }
1721                let inner_offset;
1722                let mut inner_depth = depth.clone();
1723                if inlined {
1724                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1725                    inner_offset = next_offset;
1726                } else {
1727                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1728                    inner_depth.increment()?;
1729                }
1730                let val_ref = self.device_type.get_or_insert_with(|| {
1731                    fidl::new_empty!(DeviceType, fidl::encoding::DefaultFuchsiaResourceDialect)
1732                });
1733                fidl::decode!(
1734                    DeviceType,
1735                    fidl::encoding::DefaultFuchsiaResourceDialect,
1736                    val_ref,
1737                    decoder,
1738                    inner_offset,
1739                    inner_depth
1740                )?;
1741                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1742                {
1743                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1744                }
1745                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1746                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1747                }
1748            }
1749
1750            next_offset += envelope_size;
1751            _next_ordinal_to_read += 1;
1752            if next_offset >= end_offset {
1753                return Ok(());
1754            }
1755
1756            // Decode unknown envelopes for gaps in ordinals.
1757            while _next_ordinal_to_read < 3 {
1758                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1759                _next_ordinal_to_read += 1;
1760                next_offset += envelope_size;
1761            }
1762
1763            let next_out_of_line = decoder.next_out_of_line();
1764            let handles_before = decoder.remaining_handles();
1765            if let Some((inlined, num_bytes, num_handles)) =
1766                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1767            {
1768                let member_inline_size =
1769                    <Context as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1770                if inlined != (member_inline_size <= 4) {
1771                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1772                }
1773                let inner_offset;
1774                let mut inner_depth = depth.clone();
1775                if inlined {
1776                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1777                    inner_offset = next_offset;
1778                } else {
1779                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1780                    inner_depth.increment()?;
1781                }
1782                let val_ref = self.context.get_or_insert_with(|| {
1783                    fidl::new_empty!(Context, fidl::encoding::DefaultFuchsiaResourceDialect)
1784                });
1785                fidl::decode!(
1786                    Context,
1787                    fidl::encoding::DefaultFuchsiaResourceDialect,
1788                    val_ref,
1789                    decoder,
1790                    inner_offset,
1791                    inner_depth
1792                )?;
1793                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1794                {
1795                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1796                }
1797                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1798                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1799                }
1800            }
1801
1802            next_offset += envelope_size;
1803            _next_ordinal_to_read += 1;
1804            if next_offset >= end_offset {
1805                return Ok(());
1806            }
1807
1808            // Decode unknown envelopes for gaps in ordinals.
1809            while _next_ordinal_to_read < 4 {
1810                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1811                _next_ordinal_to_read += 1;
1812                next_offset += envelope_size;
1813            }
1814
1815            let next_out_of_line = decoder.next_out_of_line();
1816            let handles_before = decoder.remaining_handles();
1817            if let Some((inlined, num_bytes, num_handles)) =
1818                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1819            {
1820                let member_inline_size =
1821                    <Target as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1822                if inlined != (member_inline_size <= 4) {
1823                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1824                }
1825                let inner_offset;
1826                let mut inner_depth = depth.clone();
1827                if inlined {
1828                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1829                    inner_offset = next_offset;
1830                } else {
1831                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1832                    inner_depth.increment()?;
1833                }
1834                let val_ref = self.target.get_or_insert_with(|| {
1835                    fidl::new_empty!(Target, fidl::encoding::DefaultFuchsiaResourceDialect)
1836                });
1837                fidl::decode!(
1838                    Target,
1839                    fidl::encoding::DefaultFuchsiaResourceDialect,
1840                    val_ref,
1841                    decoder,
1842                    inner_offset,
1843                    inner_depth
1844                )?;
1845                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1846                {
1847                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1848                }
1849                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1850                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1851                }
1852            }
1853
1854            next_offset += envelope_size;
1855            _next_ordinal_to_read += 1;
1856            if next_offset >= end_offset {
1857                return Ok(());
1858            }
1859
1860            // Decode unknown envelopes for gaps in ordinals.
1861            while _next_ordinal_to_read < 5 {
1862                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1863                _next_ordinal_to_read += 1;
1864                next_offset += envelope_size;
1865            }
1866
1867            let next_out_of_line = decoder.next_out_of_line();
1868            let handles_before = decoder.remaining_handles();
1869            if let Some((inlined, num_bytes, num_handles)) =
1870                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1871            {
1872                let member_inline_size =
1873                    <Viewport as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1874                if inlined != (member_inline_size <= 4) {
1875                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1876                }
1877                let inner_offset;
1878                let mut inner_depth = depth.clone();
1879                if inlined {
1880                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1881                    inner_offset = next_offset;
1882                } else {
1883                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1884                    inner_depth.increment()?;
1885                }
1886                let val_ref = self.viewport.get_or_insert_with(|| {
1887                    fidl::new_empty!(Viewport, fidl::encoding::DefaultFuchsiaResourceDialect)
1888                });
1889                fidl::decode!(
1890                    Viewport,
1891                    fidl::encoding::DefaultFuchsiaResourceDialect,
1892                    val_ref,
1893                    decoder,
1894                    inner_offset,
1895                    inner_depth
1896                )?;
1897                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1898                {
1899                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1900                }
1901                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1902                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1903                }
1904            }
1905
1906            next_offset += envelope_size;
1907            _next_ordinal_to_read += 1;
1908            if next_offset >= end_offset {
1909                return Ok(());
1910            }
1911
1912            // Decode unknown envelopes for gaps in ordinals.
1913            while _next_ordinal_to_read < 6 {
1914                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1915                _next_ordinal_to_read += 1;
1916                next_offset += envelope_size;
1917            }
1918
1919            let next_out_of_line = decoder.next_out_of_line();
1920            let handles_before = decoder.remaining_handles();
1921            if let Some((inlined, num_bytes, num_handles)) =
1922                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1923            {
1924                let member_inline_size =
1925                    <DispatchPolicy as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1926                if inlined != (member_inline_size <= 4) {
1927                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1928                }
1929                let inner_offset;
1930                let mut inner_depth = depth.clone();
1931                if inlined {
1932                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1933                    inner_offset = next_offset;
1934                } else {
1935                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1936                    inner_depth.increment()?;
1937                }
1938                let val_ref = self.dispatch_policy.get_or_insert_with(|| {
1939                    fidl::new_empty!(DispatchPolicy, fidl::encoding::DefaultFuchsiaResourceDialect)
1940                });
1941                fidl::decode!(
1942                    DispatchPolicy,
1943                    fidl::encoding::DefaultFuchsiaResourceDialect,
1944                    val_ref,
1945                    decoder,
1946                    inner_offset,
1947                    inner_depth
1948                )?;
1949                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1950                {
1951                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1952                }
1953                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1954                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1955                }
1956            }
1957
1958            next_offset += envelope_size;
1959            _next_ordinal_to_read += 1;
1960            if next_offset >= end_offset {
1961                return Ok(());
1962            }
1963
1964            // Decode unknown envelopes for gaps in ordinals.
1965            while _next_ordinal_to_read < 7 {
1966                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1967                _next_ordinal_to_read += 1;
1968                next_offset += envelope_size;
1969            }
1970
1971            let next_out_of_line = decoder.next_out_of_line();
1972            let handles_before = decoder.remaining_handles();
1973            if let Some((inlined, num_bytes, num_handles)) =
1974                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1975            {
1976                let member_inline_size =
1977                    <fidl_fuchsia_input_report::Axis as fidl::encoding::TypeMarker>::inline_size(
1978                        decoder.context,
1979                    );
1980                if inlined != (member_inline_size <= 4) {
1981                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1982                }
1983                let inner_offset;
1984                let mut inner_depth = depth.clone();
1985                if inlined {
1986                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1987                    inner_offset = next_offset;
1988                } else {
1989                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1990                    inner_depth.increment()?;
1991                }
1992                let val_ref = self.scroll_v_range.get_or_insert_with(|| {
1993                    fidl::new_empty!(
1994                        fidl_fuchsia_input_report::Axis,
1995                        fidl::encoding::DefaultFuchsiaResourceDialect
1996                    )
1997                });
1998                fidl::decode!(
1999                    fidl_fuchsia_input_report::Axis,
2000                    fidl::encoding::DefaultFuchsiaResourceDialect,
2001                    val_ref,
2002                    decoder,
2003                    inner_offset,
2004                    inner_depth
2005                )?;
2006                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2007                {
2008                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2009                }
2010                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2011                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2012                }
2013            }
2014
2015            next_offset += envelope_size;
2016            _next_ordinal_to_read += 1;
2017            if next_offset >= end_offset {
2018                return Ok(());
2019            }
2020
2021            // Decode unknown envelopes for gaps in ordinals.
2022            while _next_ordinal_to_read < 8 {
2023                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2024                _next_ordinal_to_read += 1;
2025                next_offset += envelope_size;
2026            }
2027
2028            let next_out_of_line = decoder.next_out_of_line();
2029            let handles_before = decoder.remaining_handles();
2030            if let Some((inlined, num_bytes, num_handles)) =
2031                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2032            {
2033                let member_inline_size =
2034                    <fidl_fuchsia_input_report::Axis as fidl::encoding::TypeMarker>::inline_size(
2035                        decoder.context,
2036                    );
2037                if inlined != (member_inline_size <= 4) {
2038                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2039                }
2040                let inner_offset;
2041                let mut inner_depth = depth.clone();
2042                if inlined {
2043                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2044                    inner_offset = next_offset;
2045                } else {
2046                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2047                    inner_depth.increment()?;
2048                }
2049                let val_ref = self.scroll_h_range.get_or_insert_with(|| {
2050                    fidl::new_empty!(
2051                        fidl_fuchsia_input_report::Axis,
2052                        fidl::encoding::DefaultFuchsiaResourceDialect
2053                    )
2054                });
2055                fidl::decode!(
2056                    fidl_fuchsia_input_report::Axis,
2057                    fidl::encoding::DefaultFuchsiaResourceDialect,
2058                    val_ref,
2059                    decoder,
2060                    inner_offset,
2061                    inner_depth
2062                )?;
2063                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2064                {
2065                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2066                }
2067                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2068                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2069                }
2070            }
2071
2072            next_offset += envelope_size;
2073            _next_ordinal_to_read += 1;
2074            if next_offset >= end_offset {
2075                return Ok(());
2076            }
2077
2078            // Decode unknown envelopes for gaps in ordinals.
2079            while _next_ordinal_to_read < 9 {
2080                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2081                _next_ordinal_to_read += 1;
2082                next_offset += envelope_size;
2083            }
2084
2085            let next_out_of_line = decoder.next_out_of_line();
2086            let handles_before = decoder.remaining_handles();
2087            if let Some((inlined, num_bytes, num_handles)) =
2088                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2089            {
2090                let member_inline_size =
2091                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::TypeMarker>::inline_size(
2092                        decoder.context,
2093                    );
2094                if inlined != (member_inline_size <= 4) {
2095                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2096                }
2097                let inner_offset;
2098                let mut inner_depth = depth.clone();
2099                if inlined {
2100                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2101                    inner_offset = next_offset;
2102                } else {
2103                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2104                    inner_depth.increment()?;
2105                }
2106                let val_ref =
2107                self.buttons.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
2108                fidl::decode!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2109                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2110                {
2111                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2112                }
2113                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2114                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2115                }
2116            }
2117
2118            next_offset += envelope_size;
2119            _next_ordinal_to_read += 1;
2120            if next_offset >= end_offset {
2121                return Ok(());
2122            }
2123
2124            // Decode unknown envelopes for gaps in ordinals.
2125            while _next_ordinal_to_read < 10 {
2126                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2127                _next_ordinal_to_read += 1;
2128                next_offset += envelope_size;
2129            }
2130
2131            let next_out_of_line = decoder.next_out_of_line();
2132            let handles_before = decoder.remaining_handles();
2133            if let Some((inlined, num_bytes, num_handles)) =
2134                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2135            {
2136                let member_inline_size = <fidl::encoding::Array<fidl_fuchsia_input_report::Axis, 2> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2137                if inlined != (member_inline_size <= 4) {
2138                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2139                }
2140                let inner_offset;
2141                let mut inner_depth = depth.clone();
2142                if inlined {
2143                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2144                    inner_offset = next_offset;
2145                } else {
2146                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2147                    inner_depth.increment()?;
2148                }
2149                let val_ref =
2150                self.relative_motion_range.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<fidl_fuchsia_input_report::Axis, 2>, fidl::encoding::DefaultFuchsiaResourceDialect));
2151                fidl::decode!(fidl::encoding::Array<fidl_fuchsia_input_report::Axis, 2>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2152                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2153                {
2154                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2155                }
2156                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2157                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2158                }
2159            }
2160
2161            next_offset += envelope_size;
2162
2163            // Decode the remaining unknown envelopes.
2164            while next_offset < end_offset {
2165                _next_ordinal_to_read += 1;
2166                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2167                next_offset += envelope_size;
2168            }
2169
2170            Ok(())
2171        }
2172    }
2173
2174    impl fidl::encoding::ResourceTypeMarker for Context {
2175        type Borrowed<'a> = &'a mut Self;
2176        fn take_or_borrow<'a>(
2177            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2178        ) -> Self::Borrowed<'a> {
2179            value
2180        }
2181    }
2182
2183    unsafe impl fidl::encoding::TypeMarker for Context {
2184        type Owned = Self;
2185
2186        #[inline(always)]
2187        fn inline_align(_context: fidl::encoding::Context) -> usize {
2188            8
2189        }
2190
2191        #[inline(always)]
2192        fn inline_size(_context: fidl::encoding::Context) -> usize {
2193            16
2194        }
2195    }
2196
2197    unsafe impl fidl::encoding::Encode<Context, fidl::encoding::DefaultFuchsiaResourceDialect>
2198        for &mut Context
2199    {
2200        #[inline]
2201        unsafe fn encode(
2202            self,
2203            encoder: &mut fidl::encoding::Encoder<
2204                '_,
2205                fidl::encoding::DefaultFuchsiaResourceDialect,
2206            >,
2207            offset: usize,
2208            _depth: fidl::encoding::Depth,
2209        ) -> fidl::Result<()> {
2210            encoder.debug_check_bounds::<Context>(offset);
2211            encoder.write_num::<u64>(self.ordinal(), offset);
2212            match self {
2213            Context::View(ref mut val) => {
2214                fidl::encoding::encode_in_envelope::<fidl_fuchsia_ui_views::ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>(
2215                    <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2216                    encoder, offset + 8, _depth
2217                )
2218            }
2219        }
2220        }
2221    }
2222
2223    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Context {
2224        #[inline(always)]
2225        fn new_empty() -> Self {
2226            Self::View(fidl::new_empty!(
2227                fidl_fuchsia_ui_views::ViewRef,
2228                fidl::encoding::DefaultFuchsiaResourceDialect
2229            ))
2230        }
2231
2232        #[inline]
2233        unsafe fn decode(
2234            &mut self,
2235            decoder: &mut fidl::encoding::Decoder<
2236                '_,
2237                fidl::encoding::DefaultFuchsiaResourceDialect,
2238            >,
2239            offset: usize,
2240            mut depth: fidl::encoding::Depth,
2241        ) -> fidl::Result<()> {
2242            decoder.debug_check_bounds::<Self>(offset);
2243            #[allow(unused_variables)]
2244            let next_out_of_line = decoder.next_out_of_line();
2245            let handles_before = decoder.remaining_handles();
2246            let (ordinal, inlined, num_bytes, num_handles) =
2247                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2248
2249            let member_inline_size = match ordinal {
2250                1 => <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::TypeMarker>::inline_size(
2251                    decoder.context,
2252                ),
2253                _ => return Err(fidl::Error::UnknownUnionTag),
2254            };
2255
2256            if inlined != (member_inline_size <= 4) {
2257                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2258            }
2259            let _inner_offset;
2260            if inlined {
2261                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2262                _inner_offset = offset + 8;
2263            } else {
2264                depth.increment()?;
2265                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2266            }
2267            match ordinal {
2268                1 => {
2269                    #[allow(irrefutable_let_patterns)]
2270                    if let Context::View(_) = self {
2271                        // Do nothing, read the value into the object
2272                    } else {
2273                        // Initialize `self` to the right variant
2274                        *self = Context::View(fidl::new_empty!(
2275                            fidl_fuchsia_ui_views::ViewRef,
2276                            fidl::encoding::DefaultFuchsiaResourceDialect
2277                        ));
2278                    }
2279                    #[allow(irrefutable_let_patterns)]
2280                    if let Context::View(ref mut val) = self {
2281                        fidl::decode!(
2282                            fidl_fuchsia_ui_views::ViewRef,
2283                            fidl::encoding::DefaultFuchsiaResourceDialect,
2284                            val,
2285                            decoder,
2286                            _inner_offset,
2287                            depth
2288                        )?;
2289                    } else {
2290                        unreachable!()
2291                    }
2292                }
2293                ordinal => panic!("unexpected ordinal {:?}", ordinal),
2294            }
2295            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2296                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2297            }
2298            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2299                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2300            }
2301            Ok(())
2302        }
2303    }
2304
2305    impl fidl::encoding::ResourceTypeMarker for Target {
2306        type Borrowed<'a> = &'a mut Self;
2307        fn take_or_borrow<'a>(
2308            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2309        ) -> Self::Borrowed<'a> {
2310            value
2311        }
2312    }
2313
2314    unsafe impl fidl::encoding::TypeMarker for Target {
2315        type Owned = Self;
2316
2317        #[inline(always)]
2318        fn inline_align(_context: fidl::encoding::Context) -> usize {
2319            8
2320        }
2321
2322        #[inline(always)]
2323        fn inline_size(_context: fidl::encoding::Context) -> usize {
2324            16
2325        }
2326    }
2327
2328    unsafe impl fidl::encoding::Encode<Target, fidl::encoding::DefaultFuchsiaResourceDialect>
2329        for &mut Target
2330    {
2331        #[inline]
2332        unsafe fn encode(
2333            self,
2334            encoder: &mut fidl::encoding::Encoder<
2335                '_,
2336                fidl::encoding::DefaultFuchsiaResourceDialect,
2337            >,
2338            offset: usize,
2339            _depth: fidl::encoding::Depth,
2340        ) -> fidl::Result<()> {
2341            encoder.debug_check_bounds::<Target>(offset);
2342            encoder.write_num::<u64>(self.ordinal(), offset);
2343            match self {
2344            Target::View(ref mut val) => {
2345                fidl::encoding::encode_in_envelope::<fidl_fuchsia_ui_views::ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>(
2346                    <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2347                    encoder, offset + 8, _depth
2348                )
2349            }
2350        }
2351        }
2352    }
2353
2354    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Target {
2355        #[inline(always)]
2356        fn new_empty() -> Self {
2357            Self::View(fidl::new_empty!(
2358                fidl_fuchsia_ui_views::ViewRef,
2359                fidl::encoding::DefaultFuchsiaResourceDialect
2360            ))
2361        }
2362
2363        #[inline]
2364        unsafe fn decode(
2365            &mut self,
2366            decoder: &mut fidl::encoding::Decoder<
2367                '_,
2368                fidl::encoding::DefaultFuchsiaResourceDialect,
2369            >,
2370            offset: usize,
2371            mut depth: fidl::encoding::Depth,
2372        ) -> fidl::Result<()> {
2373            decoder.debug_check_bounds::<Self>(offset);
2374            #[allow(unused_variables)]
2375            let next_out_of_line = decoder.next_out_of_line();
2376            let handles_before = decoder.remaining_handles();
2377            let (ordinal, inlined, num_bytes, num_handles) =
2378                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2379
2380            let member_inline_size = match ordinal {
2381                1 => <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::TypeMarker>::inline_size(
2382                    decoder.context,
2383                ),
2384                _ => return Err(fidl::Error::UnknownUnionTag),
2385            };
2386
2387            if inlined != (member_inline_size <= 4) {
2388                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2389            }
2390            let _inner_offset;
2391            if inlined {
2392                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2393                _inner_offset = offset + 8;
2394            } else {
2395                depth.increment()?;
2396                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2397            }
2398            match ordinal {
2399                1 => {
2400                    #[allow(irrefutable_let_patterns)]
2401                    if let Target::View(_) = self {
2402                        // Do nothing, read the value into the object
2403                    } else {
2404                        // Initialize `self` to the right variant
2405                        *self = Target::View(fidl::new_empty!(
2406                            fidl_fuchsia_ui_views::ViewRef,
2407                            fidl::encoding::DefaultFuchsiaResourceDialect
2408                        ));
2409                    }
2410                    #[allow(irrefutable_let_patterns)]
2411                    if let Target::View(ref mut val) = self {
2412                        fidl::decode!(
2413                            fidl_fuchsia_ui_views::ViewRef,
2414                            fidl::encoding::DefaultFuchsiaResourceDialect,
2415                            val,
2416                            decoder,
2417                            _inner_offset,
2418                            depth
2419                        )?;
2420                    } else {
2421                        unreachable!()
2422                    }
2423                }
2424                ordinal => panic!("unexpected ordinal {:?}", ordinal),
2425            }
2426            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2427                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2428            }
2429            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2430                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2431            }
2432            Ok(())
2433        }
2434    }
2435}