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