Skip to main content

fidl_fuchsia_ui_pointer_common/
fidl_fuchsia_ui_pointer_common.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::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11/// A floating-point 3x3 matrix.
12/// - The values are placed in column-major order.
13pub type Mat3 = [f32; 9];
14
15/// A floating-point two-dimensional point.
16/// - The values are placed in (x, y) order.
17pub type Point2 = [f32; 2];
18
19/// The relative motion performed by a mouse device.
20/// - The valid range is defined in [`MouseDeviceInfo.RelativeMotionRange`].
21/// - The values are placed in (x, y) order.
22pub type RelativeMotion = [f32; 2];
23
24pub type RelativeMotionRange = [fidl_fuchsia_input_common::Axis; 2];
25
26pub const MOUSE_MAX_EVENT: u32 = 128;
27
28/// The default maximum number of unacknowledged events allowed in flight for
29/// [`MouseSourceV2`].
30///
31/// Reflects approximately 0.625 seconds (625ms) of buffered events for a typical
32/// 240Hz sensor sampling rate.
33///
34/// The server (Scenic) will throttle event delivery when unacknowledged events
35/// in flight reach this limit. Clients should send acknowledgments periodically
36/// (e.g. before reaching the limit, such as within 20 remaining credits) to
37/// avoid being throttled.
38pub const MOUSE_SOURCE_V2_MAX_UNACKNOWLEDGED_EVENTS: u32 = 150;
39
40pub const TOUCH_MAX_EVENT: u32 = 128;
41
42/// The default maximum number of unacknowledged events allowed in flight for
43/// [`TouchSourceV2`].
44///
45/// Reflects approximately 0.625 seconds (625ms) of buffered events for a typical
46/// 240Hz touch sensor sampling rate.
47///
48/// The server (Scenic) will throttle event delivery when unacknowledged events
49/// in flight reach this limit. Clients should send acknowledgments periodically
50/// (e.g. before reaching the limit, such as within 20 remaining credits) to
51/// avoid being throttled.
52pub const TOUCH_SOURCE_V2_MAX_UNACKNOWLEDGED_EVENTS: u32 = 150;
53
54/// The possible states of a pointer event. These phases of events in a stream
55/// follow a state machine that starts with the `ADD` phase, followed by zero or
56/// more `CHANGE` phases, and finally terminates with `REMOVE` or `CANCEL`
57/// phase.
58/// ```
59/// ADD ---> CHANGE* -+-> REMOVE
60///                   |
61///                   +-> CANCEL
62/// ```
63///
64/// A finite sequence of pointer events that follows this state machine,
65/// starting from the initial state, is called an **interaction**. A closed (or
66/// past) interaction is one where it has reached the terminal state; an open
67/// (or current) interaction is one where it has not.
68///
69/// For a given device pointer, a stream of events is observed as a succession
70/// of zero or more closed interactions (the past history of user engagement),
71/// followed by at most one open interaction (the current user engagement).
72///
73/// When we need to group pointer events by their interaction, an event carries
74/// an **interaction id** that is unique in that pointer stream. This common
75/// reference makes it possible to operate on a closed interaction, as well as
76/// an open interaction.
77///
78/// For example, touch events are typically observed as a succession of
79/// interactions, as fingers engage and disengage with the display.
80#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
81#[repr(u32)]
82pub enum EventPhase {
83    /// The device has started tracking the pointer.
84    Add = 1,
85    /// The device has reported an update to the pointer state.
86    Change = 2,
87    /// The device has stopped tracking the pointer.
88    Remove = 3,
89    /// The pointer is no longer available.
90    Cancel = 4,
91}
92
93impl EventPhase {
94    #[inline]
95    pub fn from_primitive(prim: u32) -> Option<Self> {
96        match prim {
97            1 => Some(Self::Add),
98            2 => Some(Self::Change),
99            3 => Some(Self::Remove),
100            4 => Some(Self::Cancel),
101            _ => None,
102        }
103    }
104
105    #[inline]
106    pub const fn into_primitive(self) -> u32 {
107        self as u32
108    }
109}
110
111/// A description of mouse event stream's relationship to this view.
112#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
113#[repr(u32)]
114pub enum MouseViewStatus {
115    /// The stream is directed towards this view.
116    Entered = 1,
117    /// The stream is directed away from this view.
118    Exited = 2,
119}
120
121impl MouseViewStatus {
122    #[inline]
123    pub fn from_primitive(prim: u32) -> Option<Self> {
124        match prim {
125            1 => Some(Self::Entered),
126            2 => Some(Self::Exited),
127            _ => None,
128        }
129    }
130
131    #[inline]
132    pub const fn into_primitive(self) -> u32 {
133        self as u32
134    }
135}
136
137/// A description of the interaction's relationship to this client.
138#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
139#[repr(u32)]
140pub enum TouchInteractionStatus {
141    /// The client has been denied ownership of the interaction.
142    Denied = 1,
143    /// The client has been granted ownership of the interaction.
144    Granted = 2,
145}
146
147impl TouchInteractionStatus {
148    #[inline]
149    pub fn from_primitive(prim: u32) -> Option<Self> {
150        match prim {
151            1 => Some(Self::Denied),
152            2 => Some(Self::Granted),
153            _ => None,
154        }
155    }
156
157    #[inline]
158    pub const fn into_primitive(self) -> u32 {
159        self as u32
160    }
161}
162
163/// The possible interaction dispositions that a client can respond with to a
164/// given |TouchPointerSample|. Used as part of a gesture disambiguation scheme.
165///
166/// The responses are based on the idea of an ownership claim on a interaction.
167/// Clients may assert a claim of ownership on an open interaction, but only one
168/// client's claim is granted by the server; other clients' claims are denied.
169#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
170#[repr(u32)]
171pub enum TouchResponseType {
172    /// The client has no further interest in this interaction; it declines
173    /// ownership of the interaction. The client will stop receiving events for
174    /// this interaction.
175    No = 1,
176    /// The client is interested in this interaction, but needs to see more
177    /// events to decide; the client has not yet claimed ownership of this
178    /// interaction.
179    Maybe = 2,
180    /// The client is interested in this interaction, but needs to see more
181    /// events to decide; the client has not yet claimed ownership of the
182    /// interaction. During ownership resolution, it exerts its priority over
183    /// lower-priority "maybe" claims, but always loses to a "yes" claim.
184    MaybePrioritize = 3,
185    /// The client is interested in this interaction, but needs to see more
186    /// events to decide; the client has not yet claimed ownership of the
187    /// interaction. Moreover, it suppresses lower-priority claims that try to
188    /// resolve interaction ownership.
189    MaybeSuppress = 4,
190    /// The client is interested in this interaction, but needs to see more
191    /// events to decide; the client has not yet claimed ownership of the
192    /// interaction. Moreover, it suppresses lower-priority claims that try to
193    /// resolve interaction ownership. During ownership resolution, it exerts
194    /// its priority over lower-priority "maybe" claims, but always loses to a
195    /// "yes" claim.
196    MaybePrioritizeSuppress = 5,
197    /// The client is interested in this interaction, but needs to see a
198    /// subsequent interaction to decide; the client has not yet claimed
199    /// ownership of this interaction. It prevents ownership resolution when the
200    /// interaction closes.
201    Hold = 6,
202    /// The client is interested in this interaction, but needs to see a
203    /// subsequent interaction to decide; the client has not yet claimed
204    /// ownership of this interaction. It prevents ownership resolution when the
205    /// interaction closes. Moreover, it suppresses lower-priority claims that
206    /// try to resolve interaction ownership.
207    HoldSuppress = 7,
208    /// The client wishes exclusive access to the remaining events in this
209    /// interaction; it claims ownership of this interaction (but that claim may
210    /// be granted or denied). During ownership resolution, it yields its
211    /// priority to lower-priority "yes" claims.
212    Yes = 8,
213    /// The client wishes exclusive access to the remaining events in this
214    /// interaction; it claims ownership of this interaction (but that claim may
215    /// be granted or denied). During ownership resolution, it exerts its
216    /// priority over lower-priority "yes" claims.
217    YesPrioritize = 9,
218}
219
220impl TouchResponseType {
221    #[inline]
222    pub fn from_primitive(prim: u32) -> Option<Self> {
223        match prim {
224            1 => Some(Self::No),
225            2 => Some(Self::Maybe),
226            3 => Some(Self::MaybePrioritize),
227            4 => Some(Self::MaybeSuppress),
228            5 => Some(Self::MaybePrioritizeSuppress),
229            6 => Some(Self::Hold),
230            7 => Some(Self::HoldSuppress),
231            8 => Some(Self::Yes),
232            9 => Some(Self::YesPrioritize),
233            _ => None,
234        }
235    }
236
237    #[inline]
238    pub const fn into_primitive(self) -> u32 {
239        self as u32
240    }
241}
242
243/// The status of a mouse event stream, sent from server to client.
244///
245/// Invariant: a client's mouse events are bracketed by
246/// [`MouseViewStatus.ENTERED`] and [`MouseViewStatus.EXITED`].
247#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
248pub struct MouseEventStreamInfo {
249    /// An identifier for the mouse device that issues a mouse event stream.
250    pub device_id: u32,
251    /// The mouse event stream's enter/exit status, sent from server to client.
252    pub status: MouseViewStatus,
253}
254
255impl fidl::Persistable for MouseEventStreamInfo {}
256
257#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
258#[repr(C)]
259pub struct MouseSourceV2AcknowledgeEventsRequest {
260    pub last_acknowledged_event_stamp: u64,
261}
262
263impl fidl::Persistable for MouseSourceV2AcknowledgeEventsRequest {}
264
265/// An axis-aligned rectangle. It is defined by its minimal and maximal extents
266/// in a coordinate system.
267#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
268pub struct Rectangle {
269    /// The minimal extent of this rectangle, inclusive.
270    /// - Its coordinates are pairwise less than the maximal extent's
271    ///   coordinates.
272    pub min: [f32; 2],
273    /// The maximal extent of this rectangle, inclusive.
274    /// - Its coordinates are pairwise greater than the minimal extent's
275    ///   coordinates.
276    pub max: [f32; 2],
277}
278
279impl fidl::Persistable for Rectangle {}
280
281/// A unique identifier for a "interaction" of touch events in an event stream.
282/// Touch events are observed as a succession of interactions, as fingers engage
283/// and disengage with the display.
284///
285/// A finite sequence of pointer events that follows the `EventPhase` state
286/// machine, starting from the initial state ADD, is called an **interaction**.
287/// A closed (or past) interaction is one where it has reached the terminal
288/// state (REMOVE or CANCEL); an open (or current) interaction is one where it
289/// has not.
290///
291/// For a given device pointer, a stream of events is observed as a succession
292/// of zero or more closed interactions (the past history of user engagement),
293/// followed by at most one open interaction (the current user engagement).
294///
295/// Because we need to group pointer events by their interaction, touch event
296/// carries an **interaction id** that is unique in that pointer stream. This
297/// common reference makes it possible to operate on a closed interaction, as
298/// well as an open interaction.
299///
300/// Also see `EventPhase` for a discussion on event streams by mice.
301#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
302#[repr(C)]
303pub struct TouchInteractionId {
304    /// An identifier for the pointer device that issues touch event streams.
305    /// A device may own multiple pointers, each with its own |pointer_id|.
306    pub device_id: u32,
307    /// An identifier of the pointer that issued this event. It is unique only
308    /// to a specific |device_id|. Each (device_id, pointer_id) pair issues at
309    /// most one open interaction at a time.
310    pub pointer_id: u32,
311    /// An identifier of the interaction. It is unique only to a specific
312    /// (device_id, pointer_id) pair.
313    pub interaction_id: u32,
314}
315
316impl fidl::Persistable for TouchInteractionId {}
317
318/// The result of gesture disambiguation for a interaction of touch events, sent
319/// from server to client.
320#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
321pub struct TouchInteractionResult {
322    /// The interaction that this pointer sample belongs to.
323    pub interaction: TouchInteractionId,
324    /// The interaction's disposition, sent from server to client.
325    pub status: TouchInteractionStatus,
326}
327
328impl fidl::Persistable for TouchInteractionResult {}
329
330#[derive(Clone, Debug, PartialEq)]
331pub struct TouchSourceUpdateResponseRequest {
332    pub interaction: TouchInteractionId,
333    pub response: TouchResponse,
334}
335
336impl fidl::Persistable for TouchSourceUpdateResponseRequest {}
337
338#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
339#[repr(C)]
340pub struct TouchSourceV2AcknowledgeEventsRequest {
341    pub last_acknowledged_event_stamp: u64,
342}
343
344impl fidl::Persistable for TouchSourceV2AcknowledgeEventsRequest {}
345
346#[derive(Clone, Debug, PartialEq)]
347pub struct TouchSourceWatchRequest {
348    pub responses: Vec<TouchResponse>,
349}
350
351impl fidl::Persistable for TouchSourceWatchRequest {}
352
353/// The parameters of the associated view and viewport, sufficient to correctly
354/// interpret the position and scale of pointer events dispatched to this view.
355///
356/// Ordering. These parameters arrive over the same channel as pointer events,
357/// to provide synchronous context for interpreting the position of pointer
358/// events in the view's local coordinate system.
359///
360/// Inter-protocol redundancy. Some of these parameters may also be sent over an
361/// independent channel dedicated to view control; the client is responsible for
362/// correct use of asynchronously received parameters.
363///
364/// TODO(https://fxbug.dev/42162292): Rename viewport, it is used in Flatland.
365#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
366pub struct ViewParameters {
367    /// The view's area of content, placed in the coordinate system of the view.
368    ///
369    /// The rectangle is defined by the parent view's setup of clipping on this
370    /// view.
371    pub view: Rectangle,
372    /// The viewport's area of interaction, placed in an independent coordinate
373    /// system.
374    ///
375    /// A pointer event's position is defined in the coordinate system of this
376    /// viewport.
377    ///
378    /// A change in viewport extents means the region for pointer interaction
379    /// has itself moved, or changed in size, or both.
380    pub viewport: Rectangle,
381    /// The transform matrix that relates a point's position in the viewport's
382    /// coordinate system to its position in the view's coordinate system.
383    pub viewport_to_view_transform: [f32; 9],
384}
385
386impl fidl::Persistable for ViewParameters {}
387
388/// Information about a device that issues a mouse event stream.
389#[derive(Clone, Debug, Default, PartialEq)]
390pub struct MouseDeviceInfo {
391    /// An identifier for the mouse device that issues a mouse event stream.
392    /// Required.
393    pub id: Option<u32>,
394    /// Range of vertical scroll values issued by the device.
395    pub scroll_v_range: Option<fidl_fuchsia_input_common::Axis>,
396    /// Range of horizontal scroll values issued by the device.
397    pub scroll_h_range: Option<fidl_fuchsia_input_common::Axis>,
398    /// Button identifiers issued by the device, in priority order.
399    pub buttons: Option<Vec<u8>>,
400    /// Range of relative movement values issued by the device.
401    pub relative_motion_range: Option<[fidl_fuchsia_input_common::Axis; 2]>,
402    #[doc(hidden)]
403    pub __source_breaking: fidl::marker::SourceBreaking,
404}
405
406impl fidl::Persistable for MouseDeviceInfo {}
407
408/// A description of each sampled data point in a mouse event stream.
409///
410/// `MousePointerSample` may bundle multiple state changes into one event.
411/// For example, if user scrolls mouse wheel and presses the left buttton
412/// down at the same time, client may receive scroll and button state changes
413/// together in 1 event, or receive button change and scroll change in
414/// separate events.
415#[derive(Clone, Debug, Default, PartialEq)]
416pub struct MousePointerSample {
417    /// An identifier for the mouse device that issues a mouse event stream.
418    /// Required.
419    pub device_id: Option<u32>,
420    /// The position of this event, in the viewport's coordinate system.
421    /// Required.
422    pub position_in_viewport: Option<[f32; 2]>,
423    /// Relative vertical scrolling displacement by detent.
424    pub scroll_v: Option<i64>,
425    /// Relative horizontal scrolling displacement by detent.
426    pub scroll_h: Option<i64>,
427    /// Identifiers of currently pressed buttons.
428    pub pressed_buttons: Option<Vec<u8>>,
429    /// The relative movement performed, independent of the viewport's
430    /// coordinate system.
431    pub relative_motion: Option<[f32; 2]>,
432    /// Recommended vertical scrolling displacement by physical pixel, it is
433    /// computed with accelerator, detent / mm to pixel ratio, etc.
434    pub scroll_v_physical_pixel: Option<f64>,
435    /// Recommended horizontal scrolling displacement by physical pixel, it
436    /// is computed with accelerator, detent / mm to pixel ratio, etc.
437    pub scroll_h_physical_pixel: Option<f64>,
438    /// Indicated if the scroll event is from a precision scroll device (HI_RES
439    /// mouse or touchpad). Clients may want to play interpolation animations
440    /// on non precision scroll device for smooth scrolling.
441    pub is_precision_scroll: Option<bool>,
442    #[doc(hidden)]
443    pub __source_breaking: fidl::marker::SourceBreaking,
444}
445
446impl fidl::Persistable for MousePointerSample {}
447
448/// Information about a device that issues touch event streams.
449#[derive(Clone, Debug, Default, PartialEq)]
450pub struct TouchDeviceInfo {
451    /// An identifier for the touch device that issues touch event streams.
452    /// A device may own multiple pointers, each with its own pointer id and its
453    /// own touch event stream.
454    /// Required.
455    pub id: Option<u32>,
456    #[doc(hidden)]
457    pub __source_breaking: fidl::marker::SourceBreaking,
458}
459
460impl fidl::Persistable for TouchDeviceInfo {}
461
462/// A description of each sampled data point in a touch event stream.
463/// All fields are required.
464#[derive(Clone, Debug, Default, PartialEq)]
465pub struct TouchPointerSample {
466    /// The interaction that this pointer sample belongs to.
467    pub interaction: Option<TouchInteractionId>,
468    /// The state of this event in the interaction's state machine.
469    pub phase: Option<EventPhase>,
470    /// The position of this event, in the viewport's coordinate system.
471    pub position_in_viewport: Option<[f32; 2]>,
472    #[doc(hidden)]
473    pub __source_breaking: fidl::marker::SourceBreaking,
474}
475
476impl fidl::Persistable for TouchPointerSample {}
477
478/// A feedback event per |Event|, sent from client to server.
479///
480/// Only |TouchPointerSample| requires a |TouchResponseType|; for other events,
481/// the server expects an empty |TouchResponse| table.
482#[derive(Clone, Debug, Default, PartialEq)]
483pub struct TouchResponse {
484    /// The interaction disposition that a client responds with for a given
485    /// |TouchPointerSample|.
486    pub response_type: Option<TouchResponseType>,
487    /// An identifier to correlate this response's send/receive occurrence across
488    /// component boundaries or abstraction layers.
489    pub trace_flow_id: Option<u64>,
490    #[doc(hidden)]
491    pub __source_breaking: fidl::marker::SourceBreaking,
492}
493
494impl fidl::Persistable for TouchResponse {}
495
496pub mod mouse_source_ordinals {
497    pub const WATCH: u64 = 0x5b1f6e917ac1abb4;
498}
499
500pub mod mouse_source_v2_ordinals {
501    pub const ON_MOUSE_EVENTS: u64 = 0x61f8d843a513238d;
502    pub const ACKNOWLEDGE_EVENTS: u64 = 0x1be628961fdf2cf1;
503}
504
505pub mod touch_source_ordinals {
506    pub const WATCH: u64 = 0x38453127dd0fc7d;
507    pub const UPDATE_RESPONSE: u64 = 0x6c746a313b39898a;
508}
509
510pub mod touch_source_v2_ordinals {
511    pub const ON_TOUCH_EVENTS: u64 = 0x28aa3c07e625b3f7;
512    pub const ACKNOWLEDGE_EVENTS: u64 = 0x262966714efb0712;
513}
514
515mod internal {
516    use super::*;
517    unsafe impl fidl::encoding::TypeMarker for EventPhase {
518        type Owned = Self;
519
520        #[inline(always)]
521        fn inline_align(_context: fidl::encoding::Context) -> usize {
522            std::mem::align_of::<u32>()
523        }
524
525        #[inline(always)]
526        fn inline_size(_context: fidl::encoding::Context) -> usize {
527            std::mem::size_of::<u32>()
528        }
529
530        #[inline(always)]
531        fn encode_is_copy() -> bool {
532            true
533        }
534
535        #[inline(always)]
536        fn decode_is_copy() -> bool {
537            false
538        }
539    }
540
541    impl fidl::encoding::ValueTypeMarker for EventPhase {
542        type Borrowed<'a> = Self;
543        #[inline(always)]
544        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
545            *value
546        }
547    }
548
549    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for EventPhase {
550        #[inline]
551        unsafe fn encode(
552            self,
553            encoder: &mut fidl::encoding::Encoder<'_, D>,
554            offset: usize,
555            _depth: fidl::encoding::Depth,
556        ) -> fidl::Result<()> {
557            encoder.debug_check_bounds::<Self>(offset);
558            encoder.write_num(self.into_primitive(), offset);
559            Ok(())
560        }
561    }
562
563    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EventPhase {
564        #[inline(always)]
565        fn new_empty() -> Self {
566            Self::Add
567        }
568
569        #[inline]
570        unsafe fn decode(
571            &mut self,
572            decoder: &mut fidl::encoding::Decoder<'_, D>,
573            offset: usize,
574            _depth: fidl::encoding::Depth,
575        ) -> fidl::Result<()> {
576            decoder.debug_check_bounds::<Self>(offset);
577            let prim = decoder.read_num::<u32>(offset);
578
579            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
580            Ok(())
581        }
582    }
583    unsafe impl fidl::encoding::TypeMarker for MouseViewStatus {
584        type Owned = Self;
585
586        #[inline(always)]
587        fn inline_align(_context: fidl::encoding::Context) -> usize {
588            std::mem::align_of::<u32>()
589        }
590
591        #[inline(always)]
592        fn inline_size(_context: fidl::encoding::Context) -> usize {
593            std::mem::size_of::<u32>()
594        }
595
596        #[inline(always)]
597        fn encode_is_copy() -> bool {
598            true
599        }
600
601        #[inline(always)]
602        fn decode_is_copy() -> bool {
603            false
604        }
605    }
606
607    impl fidl::encoding::ValueTypeMarker for MouseViewStatus {
608        type Borrowed<'a> = Self;
609        #[inline(always)]
610        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
611            *value
612        }
613    }
614
615    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
616        for MouseViewStatus
617    {
618        #[inline]
619        unsafe fn encode(
620            self,
621            encoder: &mut fidl::encoding::Encoder<'_, D>,
622            offset: usize,
623            _depth: fidl::encoding::Depth,
624        ) -> fidl::Result<()> {
625            encoder.debug_check_bounds::<Self>(offset);
626            encoder.write_num(self.into_primitive(), offset);
627            Ok(())
628        }
629    }
630
631    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MouseViewStatus {
632        #[inline(always)]
633        fn new_empty() -> Self {
634            Self::Entered
635        }
636
637        #[inline]
638        unsafe fn decode(
639            &mut self,
640            decoder: &mut fidl::encoding::Decoder<'_, D>,
641            offset: usize,
642            _depth: fidl::encoding::Depth,
643        ) -> fidl::Result<()> {
644            decoder.debug_check_bounds::<Self>(offset);
645            let prim = decoder.read_num::<u32>(offset);
646
647            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
648            Ok(())
649        }
650    }
651    unsafe impl fidl::encoding::TypeMarker for TouchInteractionStatus {
652        type Owned = Self;
653
654        #[inline(always)]
655        fn inline_align(_context: fidl::encoding::Context) -> usize {
656            std::mem::align_of::<u32>()
657        }
658
659        #[inline(always)]
660        fn inline_size(_context: fidl::encoding::Context) -> usize {
661            std::mem::size_of::<u32>()
662        }
663
664        #[inline(always)]
665        fn encode_is_copy() -> bool {
666            true
667        }
668
669        #[inline(always)]
670        fn decode_is_copy() -> bool {
671            false
672        }
673    }
674
675    impl fidl::encoding::ValueTypeMarker for TouchInteractionStatus {
676        type Borrowed<'a> = Self;
677        #[inline(always)]
678        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
679            *value
680        }
681    }
682
683    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
684        for TouchInteractionStatus
685    {
686        #[inline]
687        unsafe fn encode(
688            self,
689            encoder: &mut fidl::encoding::Encoder<'_, D>,
690            offset: usize,
691            _depth: fidl::encoding::Depth,
692        ) -> fidl::Result<()> {
693            encoder.debug_check_bounds::<Self>(offset);
694            encoder.write_num(self.into_primitive(), offset);
695            Ok(())
696        }
697    }
698
699    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
700        for TouchInteractionStatus
701    {
702        #[inline(always)]
703        fn new_empty() -> Self {
704            Self::Denied
705        }
706
707        #[inline]
708        unsafe fn decode(
709            &mut self,
710            decoder: &mut fidl::encoding::Decoder<'_, D>,
711            offset: usize,
712            _depth: fidl::encoding::Depth,
713        ) -> fidl::Result<()> {
714            decoder.debug_check_bounds::<Self>(offset);
715            let prim = decoder.read_num::<u32>(offset);
716
717            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
718            Ok(())
719        }
720    }
721    unsafe impl fidl::encoding::TypeMarker for TouchResponseType {
722        type Owned = Self;
723
724        #[inline(always)]
725        fn inline_align(_context: fidl::encoding::Context) -> usize {
726            std::mem::align_of::<u32>()
727        }
728
729        #[inline(always)]
730        fn inline_size(_context: fidl::encoding::Context) -> usize {
731            std::mem::size_of::<u32>()
732        }
733
734        #[inline(always)]
735        fn encode_is_copy() -> bool {
736            true
737        }
738
739        #[inline(always)]
740        fn decode_is_copy() -> bool {
741            false
742        }
743    }
744
745    impl fidl::encoding::ValueTypeMarker for TouchResponseType {
746        type Borrowed<'a> = Self;
747        #[inline(always)]
748        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
749            *value
750        }
751    }
752
753    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
754        for TouchResponseType
755    {
756        #[inline]
757        unsafe fn encode(
758            self,
759            encoder: &mut fidl::encoding::Encoder<'_, D>,
760            offset: usize,
761            _depth: fidl::encoding::Depth,
762        ) -> fidl::Result<()> {
763            encoder.debug_check_bounds::<Self>(offset);
764            encoder.write_num(self.into_primitive(), offset);
765            Ok(())
766        }
767    }
768
769    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TouchResponseType {
770        #[inline(always)]
771        fn new_empty() -> Self {
772            Self::No
773        }
774
775        #[inline]
776        unsafe fn decode(
777            &mut self,
778            decoder: &mut fidl::encoding::Decoder<'_, D>,
779            offset: usize,
780            _depth: fidl::encoding::Depth,
781        ) -> fidl::Result<()> {
782            decoder.debug_check_bounds::<Self>(offset);
783            let prim = decoder.read_num::<u32>(offset);
784
785            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
786            Ok(())
787        }
788    }
789
790    impl fidl::encoding::ValueTypeMarker for MouseEventStreamInfo {
791        type Borrowed<'a> = &'a Self;
792        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
793            value
794        }
795    }
796
797    unsafe impl fidl::encoding::TypeMarker for MouseEventStreamInfo {
798        type Owned = Self;
799
800        #[inline(always)]
801        fn inline_align(_context: fidl::encoding::Context) -> usize {
802            4
803        }
804
805        #[inline(always)]
806        fn inline_size(_context: fidl::encoding::Context) -> usize {
807            8
808        }
809    }
810
811    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<MouseEventStreamInfo, D>
812        for &MouseEventStreamInfo
813    {
814        #[inline]
815        unsafe fn encode(
816            self,
817            encoder: &mut fidl::encoding::Encoder<'_, D>,
818            offset: usize,
819            _depth: fidl::encoding::Depth,
820        ) -> fidl::Result<()> {
821            encoder.debug_check_bounds::<MouseEventStreamInfo>(offset);
822            // Delegate to tuple encoding.
823            fidl::encoding::Encode::<MouseEventStreamInfo, D>::encode(
824                (
825                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.device_id),
826                    <MouseViewStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
827                ),
828                encoder,
829                offset,
830                _depth,
831            )
832        }
833    }
834    unsafe impl<
835        D: fidl::encoding::ResourceDialect,
836        T0: fidl::encoding::Encode<u32, D>,
837        T1: fidl::encoding::Encode<MouseViewStatus, D>,
838    > fidl::encoding::Encode<MouseEventStreamInfo, D> for (T0, T1)
839    {
840        #[inline]
841        unsafe fn encode(
842            self,
843            encoder: &mut fidl::encoding::Encoder<'_, D>,
844            offset: usize,
845            depth: fidl::encoding::Depth,
846        ) -> fidl::Result<()> {
847            encoder.debug_check_bounds::<MouseEventStreamInfo>(offset);
848            // Zero out padding regions. There's no need to apply masks
849            // because the unmasked parts will be overwritten by fields.
850            // Write the fields.
851            self.0.encode(encoder, offset + 0, depth)?;
852            self.1.encode(encoder, offset + 4, depth)?;
853            Ok(())
854        }
855    }
856
857    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MouseEventStreamInfo {
858        #[inline(always)]
859        fn new_empty() -> Self {
860            Self {
861                device_id: fidl::new_empty!(u32, D),
862                status: fidl::new_empty!(MouseViewStatus, D),
863            }
864        }
865
866        #[inline]
867        unsafe fn decode(
868            &mut self,
869            decoder: &mut fidl::encoding::Decoder<'_, D>,
870            offset: usize,
871            _depth: fidl::encoding::Depth,
872        ) -> fidl::Result<()> {
873            decoder.debug_check_bounds::<Self>(offset);
874            // Verify that padding bytes are zero.
875            fidl::decode!(u32, D, &mut self.device_id, decoder, offset + 0, _depth)?;
876            fidl::decode!(MouseViewStatus, D, &mut self.status, decoder, offset + 4, _depth)?;
877            Ok(())
878        }
879    }
880
881    impl fidl::encoding::ValueTypeMarker for MouseSourceV2AcknowledgeEventsRequest {
882        type Borrowed<'a> = &'a Self;
883        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
884            value
885        }
886    }
887
888    unsafe impl fidl::encoding::TypeMarker for MouseSourceV2AcknowledgeEventsRequest {
889        type Owned = Self;
890
891        #[inline(always)]
892        fn inline_align(_context: fidl::encoding::Context) -> usize {
893            8
894        }
895
896        #[inline(always)]
897        fn inline_size(_context: fidl::encoding::Context) -> usize {
898            8
899        }
900        #[inline(always)]
901        fn encode_is_copy() -> bool {
902            true
903        }
904
905        #[inline(always)]
906        fn decode_is_copy() -> bool {
907            true
908        }
909    }
910
911    unsafe impl<D: fidl::encoding::ResourceDialect>
912        fidl::encoding::Encode<MouseSourceV2AcknowledgeEventsRequest, D>
913        for &MouseSourceV2AcknowledgeEventsRequest
914    {
915        #[inline]
916        unsafe fn encode(
917            self,
918            encoder: &mut fidl::encoding::Encoder<'_, D>,
919            offset: usize,
920            _depth: fidl::encoding::Depth,
921        ) -> fidl::Result<()> {
922            encoder.debug_check_bounds::<MouseSourceV2AcknowledgeEventsRequest>(offset);
923            unsafe {
924                // Copy the object into the buffer.
925                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
926                (buf_ptr as *mut MouseSourceV2AcknowledgeEventsRequest)
927                    .write_unaligned((self as *const MouseSourceV2AcknowledgeEventsRequest).read());
928                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
929                // done second because the memcpy will write garbage to these bytes.
930            }
931            Ok(())
932        }
933    }
934    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
935        fidl::encoding::Encode<MouseSourceV2AcknowledgeEventsRequest, D> for (T0,)
936    {
937        #[inline]
938        unsafe fn encode(
939            self,
940            encoder: &mut fidl::encoding::Encoder<'_, D>,
941            offset: usize,
942            depth: fidl::encoding::Depth,
943        ) -> fidl::Result<()> {
944            encoder.debug_check_bounds::<MouseSourceV2AcknowledgeEventsRequest>(offset);
945            // Zero out padding regions. There's no need to apply masks
946            // because the unmasked parts will be overwritten by fields.
947            // Write the fields.
948            self.0.encode(encoder, offset + 0, depth)?;
949            Ok(())
950        }
951    }
952
953    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
954        for MouseSourceV2AcknowledgeEventsRequest
955    {
956        #[inline(always)]
957        fn new_empty() -> Self {
958            Self { last_acknowledged_event_stamp: fidl::new_empty!(u64, D) }
959        }
960
961        #[inline]
962        unsafe fn decode(
963            &mut self,
964            decoder: &mut fidl::encoding::Decoder<'_, D>,
965            offset: usize,
966            _depth: fidl::encoding::Depth,
967        ) -> fidl::Result<()> {
968            decoder.debug_check_bounds::<Self>(offset);
969            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
970            // Verify that padding bytes are zero.
971            // Copy from the buffer into the object.
972            unsafe {
973                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
974            }
975            Ok(())
976        }
977    }
978
979    impl fidl::encoding::ValueTypeMarker for Rectangle {
980        type Borrowed<'a> = &'a Self;
981        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
982            value
983        }
984    }
985
986    unsafe impl fidl::encoding::TypeMarker for Rectangle {
987        type Owned = Self;
988
989        #[inline(always)]
990        fn inline_align(_context: fidl::encoding::Context) -> usize {
991            4
992        }
993
994        #[inline(always)]
995        fn inline_size(_context: fidl::encoding::Context) -> usize {
996            16
997        }
998    }
999
1000    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Rectangle, D>
1001        for &Rectangle
1002    {
1003        #[inline]
1004        unsafe fn encode(
1005            self,
1006            encoder: &mut fidl::encoding::Encoder<'_, D>,
1007            offset: usize,
1008            _depth: fidl::encoding::Depth,
1009        ) -> fidl::Result<()> {
1010            encoder.debug_check_bounds::<Rectangle>(offset);
1011            // Delegate to tuple encoding.
1012            fidl::encoding::Encode::<Rectangle, D>::encode(
1013                (
1014                    <fidl::encoding::Array<f32, 2> as fidl::encoding::ValueTypeMarker>::borrow(
1015                        &self.min,
1016                    ),
1017                    <fidl::encoding::Array<f32, 2> as fidl::encoding::ValueTypeMarker>::borrow(
1018                        &self.max,
1019                    ),
1020                ),
1021                encoder,
1022                offset,
1023                _depth,
1024            )
1025        }
1026    }
1027    unsafe impl<
1028        D: fidl::encoding::ResourceDialect,
1029        T0: fidl::encoding::Encode<fidl::encoding::Array<f32, 2>, D>,
1030        T1: fidl::encoding::Encode<fidl::encoding::Array<f32, 2>, D>,
1031    > fidl::encoding::Encode<Rectangle, D> for (T0, T1)
1032    {
1033        #[inline]
1034        unsafe fn encode(
1035            self,
1036            encoder: &mut fidl::encoding::Encoder<'_, D>,
1037            offset: usize,
1038            depth: fidl::encoding::Depth,
1039        ) -> fidl::Result<()> {
1040            encoder.debug_check_bounds::<Rectangle>(offset);
1041            // Zero out padding regions. There's no need to apply masks
1042            // because the unmasked parts will be overwritten by fields.
1043            // Write the fields.
1044            self.0.encode(encoder, offset + 0, depth)?;
1045            self.1.encode(encoder, offset + 8, depth)?;
1046            Ok(())
1047        }
1048    }
1049
1050    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Rectangle {
1051        #[inline(always)]
1052        fn new_empty() -> Self {
1053            Self {
1054                min: fidl::new_empty!(fidl::encoding::Array<f32, 2>, D),
1055                max: fidl::new_empty!(fidl::encoding::Array<f32, 2>, D),
1056            }
1057        }
1058
1059        #[inline]
1060        unsafe fn decode(
1061            &mut self,
1062            decoder: &mut fidl::encoding::Decoder<'_, D>,
1063            offset: usize,
1064            _depth: fidl::encoding::Depth,
1065        ) -> fidl::Result<()> {
1066            decoder.debug_check_bounds::<Self>(offset);
1067            // Verify that padding bytes are zero.
1068            fidl::decode!(fidl::encoding::Array<f32, 2>, D, &mut self.min, decoder, offset + 0, _depth)?;
1069            fidl::decode!(fidl::encoding::Array<f32, 2>, D, &mut self.max, decoder, offset + 8, _depth)?;
1070            Ok(())
1071        }
1072    }
1073
1074    impl fidl::encoding::ValueTypeMarker for TouchInteractionId {
1075        type Borrowed<'a> = &'a Self;
1076        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1077            value
1078        }
1079    }
1080
1081    unsafe impl fidl::encoding::TypeMarker for TouchInteractionId {
1082        type Owned = Self;
1083
1084        #[inline(always)]
1085        fn inline_align(_context: fidl::encoding::Context) -> usize {
1086            4
1087        }
1088
1089        #[inline(always)]
1090        fn inline_size(_context: fidl::encoding::Context) -> usize {
1091            12
1092        }
1093        #[inline(always)]
1094        fn encode_is_copy() -> bool {
1095            true
1096        }
1097
1098        #[inline(always)]
1099        fn decode_is_copy() -> bool {
1100            true
1101        }
1102    }
1103
1104    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TouchInteractionId, D>
1105        for &TouchInteractionId
1106    {
1107        #[inline]
1108        unsafe fn encode(
1109            self,
1110            encoder: &mut fidl::encoding::Encoder<'_, D>,
1111            offset: usize,
1112            _depth: fidl::encoding::Depth,
1113        ) -> fidl::Result<()> {
1114            encoder.debug_check_bounds::<TouchInteractionId>(offset);
1115            unsafe {
1116                // Copy the object into the buffer.
1117                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1118                (buf_ptr as *mut TouchInteractionId)
1119                    .write_unaligned((self as *const TouchInteractionId).read());
1120                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1121                // done second because the memcpy will write garbage to these bytes.
1122            }
1123            Ok(())
1124        }
1125    }
1126    unsafe impl<
1127        D: fidl::encoding::ResourceDialect,
1128        T0: fidl::encoding::Encode<u32, D>,
1129        T1: fidl::encoding::Encode<u32, D>,
1130        T2: fidl::encoding::Encode<u32, D>,
1131    > fidl::encoding::Encode<TouchInteractionId, D> for (T0, T1, T2)
1132    {
1133        #[inline]
1134        unsafe fn encode(
1135            self,
1136            encoder: &mut fidl::encoding::Encoder<'_, D>,
1137            offset: usize,
1138            depth: fidl::encoding::Depth,
1139        ) -> fidl::Result<()> {
1140            encoder.debug_check_bounds::<TouchInteractionId>(offset);
1141            // Zero out padding regions. There's no need to apply masks
1142            // because the unmasked parts will be overwritten by fields.
1143            // Write the fields.
1144            self.0.encode(encoder, offset + 0, depth)?;
1145            self.1.encode(encoder, offset + 4, depth)?;
1146            self.2.encode(encoder, offset + 8, depth)?;
1147            Ok(())
1148        }
1149    }
1150
1151    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TouchInteractionId {
1152        #[inline(always)]
1153        fn new_empty() -> Self {
1154            Self {
1155                device_id: fidl::new_empty!(u32, D),
1156                pointer_id: fidl::new_empty!(u32, D),
1157                interaction_id: fidl::new_empty!(u32, D),
1158            }
1159        }
1160
1161        #[inline]
1162        unsafe fn decode(
1163            &mut self,
1164            decoder: &mut fidl::encoding::Decoder<'_, D>,
1165            offset: usize,
1166            _depth: fidl::encoding::Depth,
1167        ) -> fidl::Result<()> {
1168            decoder.debug_check_bounds::<Self>(offset);
1169            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1170            // Verify that padding bytes are zero.
1171            // Copy from the buffer into the object.
1172            unsafe {
1173                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 12);
1174            }
1175            Ok(())
1176        }
1177    }
1178
1179    impl fidl::encoding::ValueTypeMarker for TouchInteractionResult {
1180        type Borrowed<'a> = &'a Self;
1181        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1182            value
1183        }
1184    }
1185
1186    unsafe impl fidl::encoding::TypeMarker for TouchInteractionResult {
1187        type Owned = Self;
1188
1189        #[inline(always)]
1190        fn inline_align(_context: fidl::encoding::Context) -> usize {
1191            4
1192        }
1193
1194        #[inline(always)]
1195        fn inline_size(_context: fidl::encoding::Context) -> usize {
1196            16
1197        }
1198    }
1199
1200    unsafe impl<D: fidl::encoding::ResourceDialect>
1201        fidl::encoding::Encode<TouchInteractionResult, D> for &TouchInteractionResult
1202    {
1203        #[inline]
1204        unsafe fn encode(
1205            self,
1206            encoder: &mut fidl::encoding::Encoder<'_, D>,
1207            offset: usize,
1208            _depth: fidl::encoding::Depth,
1209        ) -> fidl::Result<()> {
1210            encoder.debug_check_bounds::<TouchInteractionResult>(offset);
1211            // Delegate to tuple encoding.
1212            fidl::encoding::Encode::<TouchInteractionResult, D>::encode(
1213                (
1214                    <TouchInteractionId as fidl::encoding::ValueTypeMarker>::borrow(
1215                        &self.interaction,
1216                    ),
1217                    <TouchInteractionStatus as fidl::encoding::ValueTypeMarker>::borrow(
1218                        &self.status,
1219                    ),
1220                ),
1221                encoder,
1222                offset,
1223                _depth,
1224            )
1225        }
1226    }
1227    unsafe impl<
1228        D: fidl::encoding::ResourceDialect,
1229        T0: fidl::encoding::Encode<TouchInteractionId, D>,
1230        T1: fidl::encoding::Encode<TouchInteractionStatus, D>,
1231    > fidl::encoding::Encode<TouchInteractionResult, D> for (T0, T1)
1232    {
1233        #[inline]
1234        unsafe fn encode(
1235            self,
1236            encoder: &mut fidl::encoding::Encoder<'_, D>,
1237            offset: usize,
1238            depth: fidl::encoding::Depth,
1239        ) -> fidl::Result<()> {
1240            encoder.debug_check_bounds::<TouchInteractionResult>(offset);
1241            // Zero out padding regions. There's no need to apply masks
1242            // because the unmasked parts will be overwritten by fields.
1243            // Write the fields.
1244            self.0.encode(encoder, offset + 0, depth)?;
1245            self.1.encode(encoder, offset + 12, depth)?;
1246            Ok(())
1247        }
1248    }
1249
1250    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1251        for TouchInteractionResult
1252    {
1253        #[inline(always)]
1254        fn new_empty() -> Self {
1255            Self {
1256                interaction: fidl::new_empty!(TouchInteractionId, D),
1257                status: fidl::new_empty!(TouchInteractionStatus, D),
1258            }
1259        }
1260
1261        #[inline]
1262        unsafe fn decode(
1263            &mut self,
1264            decoder: &mut fidl::encoding::Decoder<'_, D>,
1265            offset: usize,
1266            _depth: fidl::encoding::Depth,
1267        ) -> fidl::Result<()> {
1268            decoder.debug_check_bounds::<Self>(offset);
1269            // Verify that padding bytes are zero.
1270            fidl::decode!(
1271                TouchInteractionId,
1272                D,
1273                &mut self.interaction,
1274                decoder,
1275                offset + 0,
1276                _depth
1277            )?;
1278            fidl::decode!(
1279                TouchInteractionStatus,
1280                D,
1281                &mut self.status,
1282                decoder,
1283                offset + 12,
1284                _depth
1285            )?;
1286            Ok(())
1287        }
1288    }
1289
1290    impl fidl::encoding::ValueTypeMarker for TouchSourceUpdateResponseRequest {
1291        type Borrowed<'a> = &'a Self;
1292        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1293            value
1294        }
1295    }
1296
1297    unsafe impl fidl::encoding::TypeMarker for TouchSourceUpdateResponseRequest {
1298        type Owned = Self;
1299
1300        #[inline(always)]
1301        fn inline_align(_context: fidl::encoding::Context) -> usize {
1302            8
1303        }
1304
1305        #[inline(always)]
1306        fn inline_size(_context: fidl::encoding::Context) -> usize {
1307            32
1308        }
1309    }
1310
1311    unsafe impl<D: fidl::encoding::ResourceDialect>
1312        fidl::encoding::Encode<TouchSourceUpdateResponseRequest, D>
1313        for &TouchSourceUpdateResponseRequest
1314    {
1315        #[inline]
1316        unsafe fn encode(
1317            self,
1318            encoder: &mut fidl::encoding::Encoder<'_, D>,
1319            offset: usize,
1320            _depth: fidl::encoding::Depth,
1321        ) -> fidl::Result<()> {
1322            encoder.debug_check_bounds::<TouchSourceUpdateResponseRequest>(offset);
1323            // Delegate to tuple encoding.
1324            fidl::encoding::Encode::<TouchSourceUpdateResponseRequest, D>::encode(
1325                (
1326                    <TouchInteractionId as fidl::encoding::ValueTypeMarker>::borrow(
1327                        &self.interaction,
1328                    ),
1329                    <TouchResponse as fidl::encoding::ValueTypeMarker>::borrow(&self.response),
1330                ),
1331                encoder,
1332                offset,
1333                _depth,
1334            )
1335        }
1336    }
1337    unsafe impl<
1338        D: fidl::encoding::ResourceDialect,
1339        T0: fidl::encoding::Encode<TouchInteractionId, D>,
1340        T1: fidl::encoding::Encode<TouchResponse, D>,
1341    > fidl::encoding::Encode<TouchSourceUpdateResponseRequest, D> for (T0, T1)
1342    {
1343        #[inline]
1344        unsafe fn encode(
1345            self,
1346            encoder: &mut fidl::encoding::Encoder<'_, D>,
1347            offset: usize,
1348            depth: fidl::encoding::Depth,
1349        ) -> fidl::Result<()> {
1350            encoder.debug_check_bounds::<TouchSourceUpdateResponseRequest>(offset);
1351            // Zero out padding regions. There's no need to apply masks
1352            // because the unmasked parts will be overwritten by fields.
1353            unsafe {
1354                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
1355                (ptr as *mut u64).write_unaligned(0);
1356            }
1357            // Write the fields.
1358            self.0.encode(encoder, offset + 0, depth)?;
1359            self.1.encode(encoder, offset + 16, depth)?;
1360            Ok(())
1361        }
1362    }
1363
1364    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1365        for TouchSourceUpdateResponseRequest
1366    {
1367        #[inline(always)]
1368        fn new_empty() -> Self {
1369            Self {
1370                interaction: fidl::new_empty!(TouchInteractionId, D),
1371                response: fidl::new_empty!(TouchResponse, D),
1372            }
1373        }
1374
1375        #[inline]
1376        unsafe fn decode(
1377            &mut self,
1378            decoder: &mut fidl::encoding::Decoder<'_, D>,
1379            offset: usize,
1380            _depth: fidl::encoding::Depth,
1381        ) -> fidl::Result<()> {
1382            decoder.debug_check_bounds::<Self>(offset);
1383            // Verify that padding bytes are zero.
1384            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
1385            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1386            let mask = 0xffffffff00000000u64;
1387            let maskedval = padval & mask;
1388            if maskedval != 0 {
1389                return Err(fidl::Error::NonZeroPadding {
1390                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
1391                });
1392            }
1393            fidl::decode!(
1394                TouchInteractionId,
1395                D,
1396                &mut self.interaction,
1397                decoder,
1398                offset + 0,
1399                _depth
1400            )?;
1401            fidl::decode!(TouchResponse, D, &mut self.response, decoder, offset + 16, _depth)?;
1402            Ok(())
1403        }
1404    }
1405
1406    impl fidl::encoding::ValueTypeMarker for TouchSourceV2AcknowledgeEventsRequest {
1407        type Borrowed<'a> = &'a Self;
1408        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1409            value
1410        }
1411    }
1412
1413    unsafe impl fidl::encoding::TypeMarker for TouchSourceV2AcknowledgeEventsRequest {
1414        type Owned = Self;
1415
1416        #[inline(always)]
1417        fn inline_align(_context: fidl::encoding::Context) -> usize {
1418            8
1419        }
1420
1421        #[inline(always)]
1422        fn inline_size(_context: fidl::encoding::Context) -> usize {
1423            8
1424        }
1425        #[inline(always)]
1426        fn encode_is_copy() -> bool {
1427            true
1428        }
1429
1430        #[inline(always)]
1431        fn decode_is_copy() -> bool {
1432            true
1433        }
1434    }
1435
1436    unsafe impl<D: fidl::encoding::ResourceDialect>
1437        fidl::encoding::Encode<TouchSourceV2AcknowledgeEventsRequest, D>
1438        for &TouchSourceV2AcknowledgeEventsRequest
1439    {
1440        #[inline]
1441        unsafe fn encode(
1442            self,
1443            encoder: &mut fidl::encoding::Encoder<'_, D>,
1444            offset: usize,
1445            _depth: fidl::encoding::Depth,
1446        ) -> fidl::Result<()> {
1447            encoder.debug_check_bounds::<TouchSourceV2AcknowledgeEventsRequest>(offset);
1448            unsafe {
1449                // Copy the object into the buffer.
1450                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1451                (buf_ptr as *mut TouchSourceV2AcknowledgeEventsRequest)
1452                    .write_unaligned((self as *const TouchSourceV2AcknowledgeEventsRequest).read());
1453                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1454                // done second because the memcpy will write garbage to these bytes.
1455            }
1456            Ok(())
1457        }
1458    }
1459    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
1460        fidl::encoding::Encode<TouchSourceV2AcknowledgeEventsRequest, D> for (T0,)
1461    {
1462        #[inline]
1463        unsafe fn encode(
1464            self,
1465            encoder: &mut fidl::encoding::Encoder<'_, D>,
1466            offset: usize,
1467            depth: fidl::encoding::Depth,
1468        ) -> fidl::Result<()> {
1469            encoder.debug_check_bounds::<TouchSourceV2AcknowledgeEventsRequest>(offset);
1470            // Zero out padding regions. There's no need to apply masks
1471            // because the unmasked parts will be overwritten by fields.
1472            // Write the fields.
1473            self.0.encode(encoder, offset + 0, depth)?;
1474            Ok(())
1475        }
1476    }
1477
1478    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1479        for TouchSourceV2AcknowledgeEventsRequest
1480    {
1481        #[inline(always)]
1482        fn new_empty() -> Self {
1483            Self { last_acknowledged_event_stamp: fidl::new_empty!(u64, D) }
1484        }
1485
1486        #[inline]
1487        unsafe fn decode(
1488            &mut self,
1489            decoder: &mut fidl::encoding::Decoder<'_, D>,
1490            offset: usize,
1491            _depth: fidl::encoding::Depth,
1492        ) -> fidl::Result<()> {
1493            decoder.debug_check_bounds::<Self>(offset);
1494            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1495            // Verify that padding bytes are zero.
1496            // Copy from the buffer into the object.
1497            unsafe {
1498                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1499            }
1500            Ok(())
1501        }
1502    }
1503
1504    impl fidl::encoding::ValueTypeMarker for TouchSourceWatchRequest {
1505        type Borrowed<'a> = &'a Self;
1506        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1507            value
1508        }
1509    }
1510
1511    unsafe impl fidl::encoding::TypeMarker for TouchSourceWatchRequest {
1512        type Owned = Self;
1513
1514        #[inline(always)]
1515        fn inline_align(_context: fidl::encoding::Context) -> usize {
1516            8
1517        }
1518
1519        #[inline(always)]
1520        fn inline_size(_context: fidl::encoding::Context) -> usize {
1521            16
1522        }
1523    }
1524
1525    unsafe impl<D: fidl::encoding::ResourceDialect>
1526        fidl::encoding::Encode<TouchSourceWatchRequest, D> for &TouchSourceWatchRequest
1527    {
1528        #[inline]
1529        unsafe fn encode(
1530            self,
1531            encoder: &mut fidl::encoding::Encoder<'_, D>,
1532            offset: usize,
1533            _depth: fidl::encoding::Depth,
1534        ) -> fidl::Result<()> {
1535            encoder.debug_check_bounds::<TouchSourceWatchRequest>(offset);
1536            // Delegate to tuple encoding.
1537            fidl::encoding::Encode::<TouchSourceWatchRequest, D>::encode(
1538                (
1539                    <fidl::encoding::Vector<TouchResponse, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.responses),
1540                ),
1541                encoder, offset, _depth
1542            )
1543        }
1544    }
1545    unsafe impl<
1546        D: fidl::encoding::ResourceDialect,
1547        T0: fidl::encoding::Encode<fidl::encoding::Vector<TouchResponse, 128>, D>,
1548    > fidl::encoding::Encode<TouchSourceWatchRequest, D> for (T0,)
1549    {
1550        #[inline]
1551        unsafe fn encode(
1552            self,
1553            encoder: &mut fidl::encoding::Encoder<'_, D>,
1554            offset: usize,
1555            depth: fidl::encoding::Depth,
1556        ) -> fidl::Result<()> {
1557            encoder.debug_check_bounds::<TouchSourceWatchRequest>(offset);
1558            // Zero out padding regions. There's no need to apply masks
1559            // because the unmasked parts will be overwritten by fields.
1560            // Write the fields.
1561            self.0.encode(encoder, offset + 0, depth)?;
1562            Ok(())
1563        }
1564    }
1565
1566    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1567        for TouchSourceWatchRequest
1568    {
1569        #[inline(always)]
1570        fn new_empty() -> Self {
1571            Self { responses: fidl::new_empty!(fidl::encoding::Vector<TouchResponse, 128>, D) }
1572        }
1573
1574        #[inline]
1575        unsafe fn decode(
1576            &mut self,
1577            decoder: &mut fidl::encoding::Decoder<'_, D>,
1578            offset: usize,
1579            _depth: fidl::encoding::Depth,
1580        ) -> fidl::Result<()> {
1581            decoder.debug_check_bounds::<Self>(offset);
1582            // Verify that padding bytes are zero.
1583            fidl::decode!(fidl::encoding::Vector<TouchResponse, 128>, D, &mut self.responses, decoder, offset + 0, _depth)?;
1584            Ok(())
1585        }
1586    }
1587
1588    impl fidl::encoding::ValueTypeMarker for ViewParameters {
1589        type Borrowed<'a> = &'a Self;
1590        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1591            value
1592        }
1593    }
1594
1595    unsafe impl fidl::encoding::TypeMarker for ViewParameters {
1596        type Owned = Self;
1597
1598        #[inline(always)]
1599        fn inline_align(_context: fidl::encoding::Context) -> usize {
1600            4
1601        }
1602
1603        #[inline(always)]
1604        fn inline_size(_context: fidl::encoding::Context) -> usize {
1605            68
1606        }
1607    }
1608
1609    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ViewParameters, D>
1610        for &ViewParameters
1611    {
1612        #[inline]
1613        unsafe fn encode(
1614            self,
1615            encoder: &mut fidl::encoding::Encoder<'_, D>,
1616            offset: usize,
1617            _depth: fidl::encoding::Depth,
1618        ) -> fidl::Result<()> {
1619            encoder.debug_check_bounds::<ViewParameters>(offset);
1620            // Delegate to tuple encoding.
1621            fidl::encoding::Encode::<ViewParameters, D>::encode(
1622                (
1623                    <Rectangle as fidl::encoding::ValueTypeMarker>::borrow(&self.view),
1624                    <Rectangle as fidl::encoding::ValueTypeMarker>::borrow(&self.viewport),
1625                    <fidl::encoding::Array<f32, 9> as fidl::encoding::ValueTypeMarker>::borrow(
1626                        &self.viewport_to_view_transform,
1627                    ),
1628                ),
1629                encoder,
1630                offset,
1631                _depth,
1632            )
1633        }
1634    }
1635    unsafe impl<
1636        D: fidl::encoding::ResourceDialect,
1637        T0: fidl::encoding::Encode<Rectangle, D>,
1638        T1: fidl::encoding::Encode<Rectangle, D>,
1639        T2: fidl::encoding::Encode<fidl::encoding::Array<f32, 9>, D>,
1640    > fidl::encoding::Encode<ViewParameters, D> for (T0, T1, T2)
1641    {
1642        #[inline]
1643        unsafe fn encode(
1644            self,
1645            encoder: &mut fidl::encoding::Encoder<'_, D>,
1646            offset: usize,
1647            depth: fidl::encoding::Depth,
1648        ) -> fidl::Result<()> {
1649            encoder.debug_check_bounds::<ViewParameters>(offset);
1650            // Zero out padding regions. There's no need to apply masks
1651            // because the unmasked parts will be overwritten by fields.
1652            // Write the fields.
1653            self.0.encode(encoder, offset + 0, depth)?;
1654            self.1.encode(encoder, offset + 16, depth)?;
1655            self.2.encode(encoder, offset + 32, depth)?;
1656            Ok(())
1657        }
1658    }
1659
1660    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ViewParameters {
1661        #[inline(always)]
1662        fn new_empty() -> Self {
1663            Self {
1664                view: fidl::new_empty!(Rectangle, D),
1665                viewport: fidl::new_empty!(Rectangle, D),
1666                viewport_to_view_transform: fidl::new_empty!(fidl::encoding::Array<f32, 9>, D),
1667            }
1668        }
1669
1670        #[inline]
1671        unsafe fn decode(
1672            &mut self,
1673            decoder: &mut fidl::encoding::Decoder<'_, D>,
1674            offset: usize,
1675            _depth: fidl::encoding::Depth,
1676        ) -> fidl::Result<()> {
1677            decoder.debug_check_bounds::<Self>(offset);
1678            // Verify that padding bytes are zero.
1679            fidl::decode!(Rectangle, D, &mut self.view, decoder, offset + 0, _depth)?;
1680            fidl::decode!(Rectangle, D, &mut self.viewport, decoder, offset + 16, _depth)?;
1681            fidl::decode!(fidl::encoding::Array<f32, 9>, D, &mut self.viewport_to_view_transform, decoder, offset + 32, _depth)?;
1682            Ok(())
1683        }
1684    }
1685
1686    impl MouseDeviceInfo {
1687        #[inline(always)]
1688        fn max_ordinal_present(&self) -> u64 {
1689            if let Some(_) = self.relative_motion_range {
1690                return 5;
1691            }
1692            if let Some(_) = self.buttons {
1693                return 4;
1694            }
1695            if let Some(_) = self.scroll_h_range {
1696                return 3;
1697            }
1698            if let Some(_) = self.scroll_v_range {
1699                return 2;
1700            }
1701            if let Some(_) = self.id {
1702                return 1;
1703            }
1704            0
1705        }
1706    }
1707
1708    impl fidl::encoding::ValueTypeMarker for MouseDeviceInfo {
1709        type Borrowed<'a> = &'a Self;
1710        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1711            value
1712        }
1713    }
1714
1715    unsafe impl fidl::encoding::TypeMarker for MouseDeviceInfo {
1716        type Owned = Self;
1717
1718        #[inline(always)]
1719        fn inline_align(_context: fidl::encoding::Context) -> usize {
1720            8
1721        }
1722
1723        #[inline(always)]
1724        fn inline_size(_context: fidl::encoding::Context) -> usize {
1725            16
1726        }
1727    }
1728
1729    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<MouseDeviceInfo, D>
1730        for &MouseDeviceInfo
1731    {
1732        unsafe fn encode(
1733            self,
1734            encoder: &mut fidl::encoding::Encoder<'_, D>,
1735            offset: usize,
1736            mut depth: fidl::encoding::Depth,
1737        ) -> fidl::Result<()> {
1738            encoder.debug_check_bounds::<MouseDeviceInfo>(offset);
1739            // Vector header
1740            let max_ordinal: u64 = self.max_ordinal_present();
1741            encoder.write_num(max_ordinal, offset);
1742            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1743            // Calling encoder.out_of_line_offset(0) is not allowed.
1744            if max_ordinal == 0 {
1745                return Ok(());
1746            }
1747            depth.increment()?;
1748            let envelope_size = 8;
1749            let bytes_len = max_ordinal as usize * envelope_size;
1750            #[allow(unused_variables)]
1751            let offset = encoder.out_of_line_offset(bytes_len);
1752            let mut _prev_end_offset: usize = 0;
1753            if 1 > max_ordinal {
1754                return Ok(());
1755            }
1756
1757            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1758            // are envelope_size bytes.
1759            let cur_offset: usize = (1 - 1) * envelope_size;
1760
1761            // Zero reserved fields.
1762            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1763
1764            // Safety:
1765            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1766            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1767            //   envelope_size bytes, there is always sufficient room.
1768            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1769                self.id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1770                encoder,
1771                offset + cur_offset,
1772                depth,
1773            )?;
1774
1775            _prev_end_offset = cur_offset + envelope_size;
1776            if 2 > max_ordinal {
1777                return Ok(());
1778            }
1779
1780            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1781            // are envelope_size bytes.
1782            let cur_offset: usize = (2 - 1) * envelope_size;
1783
1784            // Zero reserved fields.
1785            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1786
1787            // Safety:
1788            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1789            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1790            //   envelope_size bytes, there is always sufficient room.
1791            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_input_common::Axis, D>(
1792                self.scroll_v_range.as_ref().map(
1793                    <fidl_fuchsia_input_common::Axis as fidl::encoding::ValueTypeMarker>::borrow,
1794                ),
1795                encoder,
1796                offset + cur_offset,
1797                depth,
1798            )?;
1799
1800            _prev_end_offset = cur_offset + envelope_size;
1801            if 3 > max_ordinal {
1802                return Ok(());
1803            }
1804
1805            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1806            // are envelope_size bytes.
1807            let cur_offset: usize = (3 - 1) * envelope_size;
1808
1809            // Zero reserved fields.
1810            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1811
1812            // Safety:
1813            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1814            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1815            //   envelope_size bytes, there is always sufficient room.
1816            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_input_common::Axis, D>(
1817                self.scroll_h_range.as_ref().map(
1818                    <fidl_fuchsia_input_common::Axis as fidl::encoding::ValueTypeMarker>::borrow,
1819                ),
1820                encoder,
1821                offset + cur_offset,
1822                depth,
1823            )?;
1824
1825            _prev_end_offset = cur_offset + envelope_size;
1826            if 4 > max_ordinal {
1827                return Ok(());
1828            }
1829
1830            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1831            // are envelope_size bytes.
1832            let cur_offset: usize = (4 - 1) * envelope_size;
1833
1834            // Zero reserved fields.
1835            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1836
1837            // Safety:
1838            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1839            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1840            //   envelope_size bytes, there is always sufficient room.
1841            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 32>, D>(
1842                self.buttons.as_ref().map(
1843                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow,
1844                ),
1845                encoder,
1846                offset + cur_offset,
1847                depth,
1848            )?;
1849
1850            _prev_end_offset = cur_offset + envelope_size;
1851            if 5 > max_ordinal {
1852                return Ok(());
1853            }
1854
1855            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1856            // are envelope_size bytes.
1857            let cur_offset: usize = (5 - 1) * envelope_size;
1858
1859            // Zero reserved fields.
1860            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1861
1862            // Safety:
1863            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1864            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1865            //   envelope_size bytes, there is always sufficient room.
1866            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<fidl_fuchsia_input_common::Axis, 2>, D>(
1867            self.relative_motion_range.as_ref().map(<fidl::encoding::Array<fidl_fuchsia_input_common::Axis, 2> as fidl::encoding::ValueTypeMarker>::borrow),
1868            encoder, offset + cur_offset, depth
1869        )?;
1870
1871            _prev_end_offset = cur_offset + envelope_size;
1872
1873            Ok(())
1874        }
1875    }
1876
1877    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MouseDeviceInfo {
1878        #[inline(always)]
1879        fn new_empty() -> Self {
1880            Self::default()
1881        }
1882
1883        unsafe fn decode(
1884            &mut self,
1885            decoder: &mut fidl::encoding::Decoder<'_, D>,
1886            offset: usize,
1887            mut depth: fidl::encoding::Depth,
1888        ) -> fidl::Result<()> {
1889            decoder.debug_check_bounds::<Self>(offset);
1890            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1891                None => return Err(fidl::Error::NotNullable),
1892                Some(len) => len,
1893            };
1894            // Calling decoder.out_of_line_offset(0) is not allowed.
1895            if len == 0 {
1896                return Ok(());
1897            };
1898            depth.increment()?;
1899            let envelope_size = 8;
1900            let bytes_len = len * envelope_size;
1901            let offset = decoder.out_of_line_offset(bytes_len)?;
1902            // Decode the envelope for each type.
1903            let mut _next_ordinal_to_read = 0;
1904            let mut next_offset = offset;
1905            let end_offset = offset + bytes_len;
1906            _next_ordinal_to_read += 1;
1907            if next_offset >= end_offset {
1908                return Ok(());
1909            }
1910
1911            // Decode unknown envelopes for gaps in ordinals.
1912            while _next_ordinal_to_read < 1 {
1913                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1914                _next_ordinal_to_read += 1;
1915                next_offset += envelope_size;
1916            }
1917
1918            let next_out_of_line = decoder.next_out_of_line();
1919            let handles_before = decoder.remaining_handles();
1920            if let Some((inlined, num_bytes, num_handles)) =
1921                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1922            {
1923                let member_inline_size =
1924                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1925                if inlined != (member_inline_size <= 4) {
1926                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1927                }
1928                let inner_offset;
1929                let mut inner_depth = depth.clone();
1930                if inlined {
1931                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1932                    inner_offset = next_offset;
1933                } else {
1934                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1935                    inner_depth.increment()?;
1936                }
1937                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u32, D));
1938                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1939                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1940                {
1941                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1942                }
1943                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1944                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1945                }
1946            }
1947
1948            next_offset += envelope_size;
1949            _next_ordinal_to_read += 1;
1950            if next_offset >= end_offset {
1951                return Ok(());
1952            }
1953
1954            // Decode unknown envelopes for gaps in ordinals.
1955            while _next_ordinal_to_read < 2 {
1956                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1957                _next_ordinal_to_read += 1;
1958                next_offset += envelope_size;
1959            }
1960
1961            let next_out_of_line = decoder.next_out_of_line();
1962            let handles_before = decoder.remaining_handles();
1963            if let Some((inlined, num_bytes, num_handles)) =
1964                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1965            {
1966                let member_inline_size =
1967                    <fidl_fuchsia_input_common::Axis as fidl::encoding::TypeMarker>::inline_size(
1968                        decoder.context,
1969                    );
1970                if inlined != (member_inline_size <= 4) {
1971                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1972                }
1973                let inner_offset;
1974                let mut inner_depth = depth.clone();
1975                if inlined {
1976                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1977                    inner_offset = next_offset;
1978                } else {
1979                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1980                    inner_depth.increment()?;
1981                }
1982                let val_ref = self
1983                    .scroll_v_range
1984                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_input_common::Axis, D));
1985                fidl::decode!(
1986                    fidl_fuchsia_input_common::Axis,
1987                    D,
1988                    val_ref,
1989                    decoder,
1990                    inner_offset,
1991                    inner_depth
1992                )?;
1993                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1994                {
1995                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1996                }
1997                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1998                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1999                }
2000            }
2001
2002            next_offset += envelope_size;
2003            _next_ordinal_to_read += 1;
2004            if next_offset >= end_offset {
2005                return Ok(());
2006            }
2007
2008            // Decode unknown envelopes for gaps in ordinals.
2009            while _next_ordinal_to_read < 3 {
2010                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2011                _next_ordinal_to_read += 1;
2012                next_offset += envelope_size;
2013            }
2014
2015            let next_out_of_line = decoder.next_out_of_line();
2016            let handles_before = decoder.remaining_handles();
2017            if let Some((inlined, num_bytes, num_handles)) =
2018                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2019            {
2020                let member_inline_size =
2021                    <fidl_fuchsia_input_common::Axis as fidl::encoding::TypeMarker>::inline_size(
2022                        decoder.context,
2023                    );
2024                if inlined != (member_inline_size <= 4) {
2025                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2026                }
2027                let inner_offset;
2028                let mut inner_depth = depth.clone();
2029                if inlined {
2030                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2031                    inner_offset = next_offset;
2032                } else {
2033                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2034                    inner_depth.increment()?;
2035                }
2036                let val_ref = self
2037                    .scroll_h_range
2038                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_input_common::Axis, D));
2039                fidl::decode!(
2040                    fidl_fuchsia_input_common::Axis,
2041                    D,
2042                    val_ref,
2043                    decoder,
2044                    inner_offset,
2045                    inner_depth
2046                )?;
2047                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2048                {
2049                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2050                }
2051                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2052                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2053                }
2054            }
2055
2056            next_offset += envelope_size;
2057            _next_ordinal_to_read += 1;
2058            if next_offset >= end_offset {
2059                return Ok(());
2060            }
2061
2062            // Decode unknown envelopes for gaps in ordinals.
2063            while _next_ordinal_to_read < 4 {
2064                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2065                _next_ordinal_to_read += 1;
2066                next_offset += envelope_size;
2067            }
2068
2069            let next_out_of_line = decoder.next_out_of_line();
2070            let handles_before = decoder.remaining_handles();
2071            if let Some((inlined, num_bytes, num_handles)) =
2072                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2073            {
2074                let member_inline_size =
2075                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::TypeMarker>::inline_size(
2076                        decoder.context,
2077                    );
2078                if inlined != (member_inline_size <= 4) {
2079                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2080                }
2081                let inner_offset;
2082                let mut inner_depth = depth.clone();
2083                if inlined {
2084                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2085                    inner_offset = next_offset;
2086                } else {
2087                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2088                    inner_depth.increment()?;
2089                }
2090                let val_ref = self
2091                    .buttons
2092                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 32>, D));
2093                fidl::decode!(fidl::encoding::Vector<u8, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
2094                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2095                {
2096                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2097                }
2098                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2099                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2100                }
2101            }
2102
2103            next_offset += envelope_size;
2104            _next_ordinal_to_read += 1;
2105            if next_offset >= end_offset {
2106                return Ok(());
2107            }
2108
2109            // Decode unknown envelopes for gaps in ordinals.
2110            while _next_ordinal_to_read < 5 {
2111                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2112                _next_ordinal_to_read += 1;
2113                next_offset += envelope_size;
2114            }
2115
2116            let next_out_of_line = decoder.next_out_of_line();
2117            let handles_before = decoder.remaining_handles();
2118            if let Some((inlined, num_bytes, num_handles)) =
2119                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2120            {
2121                let member_inline_size = <fidl::encoding::Array<fidl_fuchsia_input_common::Axis, 2> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2122                if inlined != (member_inline_size <= 4) {
2123                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2124                }
2125                let inner_offset;
2126                let mut inner_depth = depth.clone();
2127                if inlined {
2128                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2129                    inner_offset = next_offset;
2130                } else {
2131                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2132                    inner_depth.increment()?;
2133                }
2134                let val_ref =
2135                self.relative_motion_range.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<fidl_fuchsia_input_common::Axis, 2>, D));
2136                fidl::decode!(fidl::encoding::Array<fidl_fuchsia_input_common::Axis, 2>, D, val_ref, decoder, inner_offset, inner_depth)?;
2137                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2138                {
2139                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2140                }
2141                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2142                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2143                }
2144            }
2145
2146            next_offset += envelope_size;
2147
2148            // Decode the remaining unknown envelopes.
2149            while next_offset < end_offset {
2150                _next_ordinal_to_read += 1;
2151                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2152                next_offset += envelope_size;
2153            }
2154
2155            Ok(())
2156        }
2157    }
2158
2159    impl MousePointerSample {
2160        #[inline(always)]
2161        fn max_ordinal_present(&self) -> u64 {
2162            if let Some(_) = self.is_precision_scroll {
2163                return 9;
2164            }
2165            if let Some(_) = self.scroll_h_physical_pixel {
2166                return 8;
2167            }
2168            if let Some(_) = self.scroll_v_physical_pixel {
2169                return 7;
2170            }
2171            if let Some(_) = self.relative_motion {
2172                return 6;
2173            }
2174            if let Some(_) = self.pressed_buttons {
2175                return 5;
2176            }
2177            if let Some(_) = self.scroll_h {
2178                return 4;
2179            }
2180            if let Some(_) = self.scroll_v {
2181                return 3;
2182            }
2183            if let Some(_) = self.position_in_viewport {
2184                return 2;
2185            }
2186            if let Some(_) = self.device_id {
2187                return 1;
2188            }
2189            0
2190        }
2191    }
2192
2193    impl fidl::encoding::ValueTypeMarker for MousePointerSample {
2194        type Borrowed<'a> = &'a Self;
2195        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2196            value
2197        }
2198    }
2199
2200    unsafe impl fidl::encoding::TypeMarker for MousePointerSample {
2201        type Owned = Self;
2202
2203        #[inline(always)]
2204        fn inline_align(_context: fidl::encoding::Context) -> usize {
2205            8
2206        }
2207
2208        #[inline(always)]
2209        fn inline_size(_context: fidl::encoding::Context) -> usize {
2210            16
2211        }
2212    }
2213
2214    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<MousePointerSample, D>
2215        for &MousePointerSample
2216    {
2217        unsafe fn encode(
2218            self,
2219            encoder: &mut fidl::encoding::Encoder<'_, D>,
2220            offset: usize,
2221            mut depth: fidl::encoding::Depth,
2222        ) -> fidl::Result<()> {
2223            encoder.debug_check_bounds::<MousePointerSample>(offset);
2224            // Vector header
2225            let max_ordinal: u64 = self.max_ordinal_present();
2226            encoder.write_num(max_ordinal, offset);
2227            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2228            // Calling encoder.out_of_line_offset(0) is not allowed.
2229            if max_ordinal == 0 {
2230                return Ok(());
2231            }
2232            depth.increment()?;
2233            let envelope_size = 8;
2234            let bytes_len = max_ordinal as usize * envelope_size;
2235            #[allow(unused_variables)]
2236            let offset = encoder.out_of_line_offset(bytes_len);
2237            let mut _prev_end_offset: usize = 0;
2238            if 1 > max_ordinal {
2239                return Ok(());
2240            }
2241
2242            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2243            // are envelope_size bytes.
2244            let cur_offset: usize = (1 - 1) * envelope_size;
2245
2246            // Zero reserved fields.
2247            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2248
2249            // Safety:
2250            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2251            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2252            //   envelope_size bytes, there is always sufficient room.
2253            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2254                self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2255                encoder,
2256                offset + cur_offset,
2257                depth,
2258            )?;
2259
2260            _prev_end_offset = cur_offset + envelope_size;
2261            if 2 > max_ordinal {
2262                return Ok(());
2263            }
2264
2265            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2266            // are envelope_size bytes.
2267            let cur_offset: usize = (2 - 1) * envelope_size;
2268
2269            // Zero reserved fields.
2270            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2271
2272            // Safety:
2273            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2274            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2275            //   envelope_size bytes, there is always sufficient room.
2276            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<f32, 2>, D>(
2277                self.position_in_viewport.as_ref().map(
2278                    <fidl::encoding::Array<f32, 2> as fidl::encoding::ValueTypeMarker>::borrow,
2279                ),
2280                encoder,
2281                offset + cur_offset,
2282                depth,
2283            )?;
2284
2285            _prev_end_offset = cur_offset + envelope_size;
2286            if 3 > max_ordinal {
2287                return Ok(());
2288            }
2289
2290            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2291            // are envelope_size bytes.
2292            let cur_offset: usize = (3 - 1) * envelope_size;
2293
2294            // Zero reserved fields.
2295            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2296
2297            // Safety:
2298            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2299            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2300            //   envelope_size bytes, there is always sufficient room.
2301            fidl::encoding::encode_in_envelope_optional::<i64, D>(
2302                self.scroll_v.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
2303                encoder,
2304                offset + cur_offset,
2305                depth,
2306            )?;
2307
2308            _prev_end_offset = cur_offset + envelope_size;
2309            if 4 > max_ordinal {
2310                return Ok(());
2311            }
2312
2313            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2314            // are envelope_size bytes.
2315            let cur_offset: usize = (4 - 1) * envelope_size;
2316
2317            // Zero reserved fields.
2318            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2319
2320            // Safety:
2321            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2322            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2323            //   envelope_size bytes, there is always sufficient room.
2324            fidl::encoding::encode_in_envelope_optional::<i64, D>(
2325                self.scroll_h.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
2326                encoder,
2327                offset + cur_offset,
2328                depth,
2329            )?;
2330
2331            _prev_end_offset = cur_offset + envelope_size;
2332            if 5 > max_ordinal {
2333                return Ok(());
2334            }
2335
2336            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2337            // are envelope_size bytes.
2338            let cur_offset: usize = (5 - 1) * envelope_size;
2339
2340            // Zero reserved fields.
2341            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2342
2343            // Safety:
2344            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2345            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2346            //   envelope_size bytes, there is always sufficient room.
2347            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 32>, D>(
2348                self.pressed_buttons.as_ref().map(
2349                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow,
2350                ),
2351                encoder,
2352                offset + cur_offset,
2353                depth,
2354            )?;
2355
2356            _prev_end_offset = cur_offset + envelope_size;
2357            if 6 > max_ordinal {
2358                return Ok(());
2359            }
2360
2361            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2362            // are envelope_size bytes.
2363            let cur_offset: usize = (6 - 1) * envelope_size;
2364
2365            // Zero reserved fields.
2366            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2367
2368            // Safety:
2369            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2370            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2371            //   envelope_size bytes, there is always sufficient room.
2372            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<f32, 2>, D>(
2373                self.relative_motion.as_ref().map(
2374                    <fidl::encoding::Array<f32, 2> as fidl::encoding::ValueTypeMarker>::borrow,
2375                ),
2376                encoder,
2377                offset + cur_offset,
2378                depth,
2379            )?;
2380
2381            _prev_end_offset = cur_offset + envelope_size;
2382            if 7 > max_ordinal {
2383                return Ok(());
2384            }
2385
2386            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2387            // are envelope_size bytes.
2388            let cur_offset: usize = (7 - 1) * envelope_size;
2389
2390            // Zero reserved fields.
2391            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2392
2393            // Safety:
2394            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2395            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2396            //   envelope_size bytes, there is always sufficient room.
2397            fidl::encoding::encode_in_envelope_optional::<f64, D>(
2398                self.scroll_v_physical_pixel
2399                    .as_ref()
2400                    .map(<f64 as fidl::encoding::ValueTypeMarker>::borrow),
2401                encoder,
2402                offset + cur_offset,
2403                depth,
2404            )?;
2405
2406            _prev_end_offset = cur_offset + envelope_size;
2407            if 8 > max_ordinal {
2408                return Ok(());
2409            }
2410
2411            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2412            // are envelope_size bytes.
2413            let cur_offset: usize = (8 - 1) * envelope_size;
2414
2415            // Zero reserved fields.
2416            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2417
2418            // Safety:
2419            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2420            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2421            //   envelope_size bytes, there is always sufficient room.
2422            fidl::encoding::encode_in_envelope_optional::<f64, D>(
2423                self.scroll_h_physical_pixel
2424                    .as_ref()
2425                    .map(<f64 as fidl::encoding::ValueTypeMarker>::borrow),
2426                encoder,
2427                offset + cur_offset,
2428                depth,
2429            )?;
2430
2431            _prev_end_offset = cur_offset + envelope_size;
2432            if 9 > max_ordinal {
2433                return Ok(());
2434            }
2435
2436            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2437            // are envelope_size bytes.
2438            let cur_offset: usize = (9 - 1) * envelope_size;
2439
2440            // Zero reserved fields.
2441            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2442
2443            // Safety:
2444            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2445            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2446            //   envelope_size bytes, there is always sufficient room.
2447            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2448                self.is_precision_scroll
2449                    .as_ref()
2450                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2451                encoder,
2452                offset + cur_offset,
2453                depth,
2454            )?;
2455
2456            _prev_end_offset = cur_offset + envelope_size;
2457
2458            Ok(())
2459        }
2460    }
2461
2462    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MousePointerSample {
2463        #[inline(always)]
2464        fn new_empty() -> Self {
2465            Self::default()
2466        }
2467
2468        unsafe fn decode(
2469            &mut self,
2470            decoder: &mut fidl::encoding::Decoder<'_, D>,
2471            offset: usize,
2472            mut depth: fidl::encoding::Depth,
2473        ) -> fidl::Result<()> {
2474            decoder.debug_check_bounds::<Self>(offset);
2475            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2476                None => return Err(fidl::Error::NotNullable),
2477                Some(len) => len,
2478            };
2479            // Calling decoder.out_of_line_offset(0) is not allowed.
2480            if len == 0 {
2481                return Ok(());
2482            };
2483            depth.increment()?;
2484            let envelope_size = 8;
2485            let bytes_len = len * envelope_size;
2486            let offset = decoder.out_of_line_offset(bytes_len)?;
2487            // Decode the envelope for each type.
2488            let mut _next_ordinal_to_read = 0;
2489            let mut next_offset = offset;
2490            let end_offset = offset + bytes_len;
2491            _next_ordinal_to_read += 1;
2492            if next_offset >= end_offset {
2493                return Ok(());
2494            }
2495
2496            // Decode unknown envelopes for gaps in ordinals.
2497            while _next_ordinal_to_read < 1 {
2498                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2499                _next_ordinal_to_read += 1;
2500                next_offset += envelope_size;
2501            }
2502
2503            let next_out_of_line = decoder.next_out_of_line();
2504            let handles_before = decoder.remaining_handles();
2505            if let Some((inlined, num_bytes, num_handles)) =
2506                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2507            {
2508                let member_inline_size =
2509                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2510                if inlined != (member_inline_size <= 4) {
2511                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2512                }
2513                let inner_offset;
2514                let mut inner_depth = depth.clone();
2515                if inlined {
2516                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2517                    inner_offset = next_offset;
2518                } else {
2519                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2520                    inner_depth.increment()?;
2521                }
2522                let val_ref = self.device_id.get_or_insert_with(|| fidl::new_empty!(u32, D));
2523                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2524                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2525                {
2526                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2527                }
2528                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2529                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2530                }
2531            }
2532
2533            next_offset += envelope_size;
2534            _next_ordinal_to_read += 1;
2535            if next_offset >= end_offset {
2536                return Ok(());
2537            }
2538
2539            // Decode unknown envelopes for gaps in ordinals.
2540            while _next_ordinal_to_read < 2 {
2541                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2542                _next_ordinal_to_read += 1;
2543                next_offset += envelope_size;
2544            }
2545
2546            let next_out_of_line = decoder.next_out_of_line();
2547            let handles_before = decoder.remaining_handles();
2548            if let Some((inlined, num_bytes, num_handles)) =
2549                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2550            {
2551                let member_inline_size =
2552                    <fidl::encoding::Array<f32, 2> as fidl::encoding::TypeMarker>::inline_size(
2553                        decoder.context,
2554                    );
2555                if inlined != (member_inline_size <= 4) {
2556                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2557                }
2558                let inner_offset;
2559                let mut inner_depth = depth.clone();
2560                if inlined {
2561                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2562                    inner_offset = next_offset;
2563                } else {
2564                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2565                    inner_depth.increment()?;
2566                }
2567                let val_ref = self
2568                    .position_in_viewport
2569                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<f32, 2>, D));
2570                fidl::decode!(fidl::encoding::Array<f32, 2>, D, val_ref, decoder, inner_offset, inner_depth)?;
2571                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2572                {
2573                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2574                }
2575                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2576                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2577                }
2578            }
2579
2580            next_offset += envelope_size;
2581            _next_ordinal_to_read += 1;
2582            if next_offset >= end_offset {
2583                return Ok(());
2584            }
2585
2586            // Decode unknown envelopes for gaps in ordinals.
2587            while _next_ordinal_to_read < 3 {
2588                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2589                _next_ordinal_to_read += 1;
2590                next_offset += envelope_size;
2591            }
2592
2593            let next_out_of_line = decoder.next_out_of_line();
2594            let handles_before = decoder.remaining_handles();
2595            if let Some((inlined, num_bytes, num_handles)) =
2596                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2597            {
2598                let member_inline_size =
2599                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2600                if inlined != (member_inline_size <= 4) {
2601                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2602                }
2603                let inner_offset;
2604                let mut inner_depth = depth.clone();
2605                if inlined {
2606                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2607                    inner_offset = next_offset;
2608                } else {
2609                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2610                    inner_depth.increment()?;
2611                }
2612                let val_ref = self.scroll_v.get_or_insert_with(|| fidl::new_empty!(i64, D));
2613                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
2614                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2615                {
2616                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2617                }
2618                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2619                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2620                }
2621            }
2622
2623            next_offset += envelope_size;
2624            _next_ordinal_to_read += 1;
2625            if next_offset >= end_offset {
2626                return Ok(());
2627            }
2628
2629            // Decode unknown envelopes for gaps in ordinals.
2630            while _next_ordinal_to_read < 4 {
2631                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2632                _next_ordinal_to_read += 1;
2633                next_offset += envelope_size;
2634            }
2635
2636            let next_out_of_line = decoder.next_out_of_line();
2637            let handles_before = decoder.remaining_handles();
2638            if let Some((inlined, num_bytes, num_handles)) =
2639                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2640            {
2641                let member_inline_size =
2642                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2643                if inlined != (member_inline_size <= 4) {
2644                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2645                }
2646                let inner_offset;
2647                let mut inner_depth = depth.clone();
2648                if inlined {
2649                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2650                    inner_offset = next_offset;
2651                } else {
2652                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2653                    inner_depth.increment()?;
2654                }
2655                let val_ref = self.scroll_h.get_or_insert_with(|| fidl::new_empty!(i64, D));
2656                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
2657                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2658                {
2659                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2660                }
2661                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2662                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2663                }
2664            }
2665
2666            next_offset += envelope_size;
2667            _next_ordinal_to_read += 1;
2668            if next_offset >= end_offset {
2669                return Ok(());
2670            }
2671
2672            // Decode unknown envelopes for gaps in ordinals.
2673            while _next_ordinal_to_read < 5 {
2674                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2675                _next_ordinal_to_read += 1;
2676                next_offset += envelope_size;
2677            }
2678
2679            let next_out_of_line = decoder.next_out_of_line();
2680            let handles_before = decoder.remaining_handles();
2681            if let Some((inlined, num_bytes, num_handles)) =
2682                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2683            {
2684                let member_inline_size =
2685                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::TypeMarker>::inline_size(
2686                        decoder.context,
2687                    );
2688                if inlined != (member_inline_size <= 4) {
2689                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2690                }
2691                let inner_offset;
2692                let mut inner_depth = depth.clone();
2693                if inlined {
2694                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2695                    inner_offset = next_offset;
2696                } else {
2697                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2698                    inner_depth.increment()?;
2699                }
2700                let val_ref = self
2701                    .pressed_buttons
2702                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 32>, D));
2703                fidl::decode!(fidl::encoding::Vector<u8, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
2704                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2705                {
2706                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2707                }
2708                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2709                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2710                }
2711            }
2712
2713            next_offset += envelope_size;
2714            _next_ordinal_to_read += 1;
2715            if next_offset >= end_offset {
2716                return Ok(());
2717            }
2718
2719            // Decode unknown envelopes for gaps in ordinals.
2720            while _next_ordinal_to_read < 6 {
2721                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2722                _next_ordinal_to_read += 1;
2723                next_offset += envelope_size;
2724            }
2725
2726            let next_out_of_line = decoder.next_out_of_line();
2727            let handles_before = decoder.remaining_handles();
2728            if let Some((inlined, num_bytes, num_handles)) =
2729                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2730            {
2731                let member_inline_size =
2732                    <fidl::encoding::Array<f32, 2> as fidl::encoding::TypeMarker>::inline_size(
2733                        decoder.context,
2734                    );
2735                if inlined != (member_inline_size <= 4) {
2736                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2737                }
2738                let inner_offset;
2739                let mut inner_depth = depth.clone();
2740                if inlined {
2741                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2742                    inner_offset = next_offset;
2743                } else {
2744                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2745                    inner_depth.increment()?;
2746                }
2747                let val_ref = self
2748                    .relative_motion
2749                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<f32, 2>, D));
2750                fidl::decode!(fidl::encoding::Array<f32, 2>, D, val_ref, decoder, inner_offset, inner_depth)?;
2751                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2752                {
2753                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2754                }
2755                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2756                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2757                }
2758            }
2759
2760            next_offset += envelope_size;
2761            _next_ordinal_to_read += 1;
2762            if next_offset >= end_offset {
2763                return Ok(());
2764            }
2765
2766            // Decode unknown envelopes for gaps in ordinals.
2767            while _next_ordinal_to_read < 7 {
2768                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2769                _next_ordinal_to_read += 1;
2770                next_offset += envelope_size;
2771            }
2772
2773            let next_out_of_line = decoder.next_out_of_line();
2774            let handles_before = decoder.remaining_handles();
2775            if let Some((inlined, num_bytes, num_handles)) =
2776                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2777            {
2778                let member_inline_size =
2779                    <f64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2780                if inlined != (member_inline_size <= 4) {
2781                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2782                }
2783                let inner_offset;
2784                let mut inner_depth = depth.clone();
2785                if inlined {
2786                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2787                    inner_offset = next_offset;
2788                } else {
2789                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2790                    inner_depth.increment()?;
2791                }
2792                let val_ref =
2793                    self.scroll_v_physical_pixel.get_or_insert_with(|| fidl::new_empty!(f64, D));
2794                fidl::decode!(f64, D, val_ref, decoder, inner_offset, inner_depth)?;
2795                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2796                {
2797                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2798                }
2799                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2800                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2801                }
2802            }
2803
2804            next_offset += envelope_size;
2805            _next_ordinal_to_read += 1;
2806            if next_offset >= end_offset {
2807                return Ok(());
2808            }
2809
2810            // Decode unknown envelopes for gaps in ordinals.
2811            while _next_ordinal_to_read < 8 {
2812                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2813                _next_ordinal_to_read += 1;
2814                next_offset += envelope_size;
2815            }
2816
2817            let next_out_of_line = decoder.next_out_of_line();
2818            let handles_before = decoder.remaining_handles();
2819            if let Some((inlined, num_bytes, num_handles)) =
2820                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2821            {
2822                let member_inline_size =
2823                    <f64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2824                if inlined != (member_inline_size <= 4) {
2825                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2826                }
2827                let inner_offset;
2828                let mut inner_depth = depth.clone();
2829                if inlined {
2830                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2831                    inner_offset = next_offset;
2832                } else {
2833                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2834                    inner_depth.increment()?;
2835                }
2836                let val_ref =
2837                    self.scroll_h_physical_pixel.get_or_insert_with(|| fidl::new_empty!(f64, D));
2838                fidl::decode!(f64, D, val_ref, decoder, inner_offset, inner_depth)?;
2839                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2840                {
2841                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2842                }
2843                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2844                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2845                }
2846            }
2847
2848            next_offset += envelope_size;
2849            _next_ordinal_to_read += 1;
2850            if next_offset >= end_offset {
2851                return Ok(());
2852            }
2853
2854            // Decode unknown envelopes for gaps in ordinals.
2855            while _next_ordinal_to_read < 9 {
2856                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2857                _next_ordinal_to_read += 1;
2858                next_offset += envelope_size;
2859            }
2860
2861            let next_out_of_line = decoder.next_out_of_line();
2862            let handles_before = decoder.remaining_handles();
2863            if let Some((inlined, num_bytes, num_handles)) =
2864                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2865            {
2866                let member_inline_size =
2867                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2868                if inlined != (member_inline_size <= 4) {
2869                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2870                }
2871                let inner_offset;
2872                let mut inner_depth = depth.clone();
2873                if inlined {
2874                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2875                    inner_offset = next_offset;
2876                } else {
2877                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2878                    inner_depth.increment()?;
2879                }
2880                let val_ref =
2881                    self.is_precision_scroll.get_or_insert_with(|| fidl::new_empty!(bool, D));
2882                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2883                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2884                {
2885                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2886                }
2887                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2888                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2889                }
2890            }
2891
2892            next_offset += envelope_size;
2893
2894            // Decode the remaining unknown envelopes.
2895            while next_offset < end_offset {
2896                _next_ordinal_to_read += 1;
2897                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2898                next_offset += envelope_size;
2899            }
2900
2901            Ok(())
2902        }
2903    }
2904
2905    impl TouchDeviceInfo {
2906        #[inline(always)]
2907        fn max_ordinal_present(&self) -> u64 {
2908            if let Some(_) = self.id {
2909                return 1;
2910            }
2911            0
2912        }
2913    }
2914
2915    impl fidl::encoding::ValueTypeMarker for TouchDeviceInfo {
2916        type Borrowed<'a> = &'a Self;
2917        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2918            value
2919        }
2920    }
2921
2922    unsafe impl fidl::encoding::TypeMarker for TouchDeviceInfo {
2923        type Owned = Self;
2924
2925        #[inline(always)]
2926        fn inline_align(_context: fidl::encoding::Context) -> usize {
2927            8
2928        }
2929
2930        #[inline(always)]
2931        fn inline_size(_context: fidl::encoding::Context) -> usize {
2932            16
2933        }
2934    }
2935
2936    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TouchDeviceInfo, D>
2937        for &TouchDeviceInfo
2938    {
2939        unsafe fn encode(
2940            self,
2941            encoder: &mut fidl::encoding::Encoder<'_, D>,
2942            offset: usize,
2943            mut depth: fidl::encoding::Depth,
2944        ) -> fidl::Result<()> {
2945            encoder.debug_check_bounds::<TouchDeviceInfo>(offset);
2946            // Vector header
2947            let max_ordinal: u64 = self.max_ordinal_present();
2948            encoder.write_num(max_ordinal, offset);
2949            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2950            // Calling encoder.out_of_line_offset(0) is not allowed.
2951            if max_ordinal == 0 {
2952                return Ok(());
2953            }
2954            depth.increment()?;
2955            let envelope_size = 8;
2956            let bytes_len = max_ordinal as usize * envelope_size;
2957            #[allow(unused_variables)]
2958            let offset = encoder.out_of_line_offset(bytes_len);
2959            let mut _prev_end_offset: usize = 0;
2960            if 1 > max_ordinal {
2961                return Ok(());
2962            }
2963
2964            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2965            // are envelope_size bytes.
2966            let cur_offset: usize = (1 - 1) * envelope_size;
2967
2968            // Zero reserved fields.
2969            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2970
2971            // Safety:
2972            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2973            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2974            //   envelope_size bytes, there is always sufficient room.
2975            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2976                self.id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2977                encoder,
2978                offset + cur_offset,
2979                depth,
2980            )?;
2981
2982            _prev_end_offset = cur_offset + envelope_size;
2983
2984            Ok(())
2985        }
2986    }
2987
2988    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TouchDeviceInfo {
2989        #[inline(always)]
2990        fn new_empty() -> Self {
2991            Self::default()
2992        }
2993
2994        unsafe fn decode(
2995            &mut self,
2996            decoder: &mut fidl::encoding::Decoder<'_, D>,
2997            offset: usize,
2998            mut depth: fidl::encoding::Depth,
2999        ) -> fidl::Result<()> {
3000            decoder.debug_check_bounds::<Self>(offset);
3001            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3002                None => return Err(fidl::Error::NotNullable),
3003                Some(len) => len,
3004            };
3005            // Calling decoder.out_of_line_offset(0) is not allowed.
3006            if len == 0 {
3007                return Ok(());
3008            };
3009            depth.increment()?;
3010            let envelope_size = 8;
3011            let bytes_len = len * envelope_size;
3012            let offset = decoder.out_of_line_offset(bytes_len)?;
3013            // Decode the envelope for each type.
3014            let mut _next_ordinal_to_read = 0;
3015            let mut next_offset = offset;
3016            let end_offset = offset + bytes_len;
3017            _next_ordinal_to_read += 1;
3018            if next_offset >= end_offset {
3019                return Ok(());
3020            }
3021
3022            // Decode unknown envelopes for gaps in ordinals.
3023            while _next_ordinal_to_read < 1 {
3024                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3025                _next_ordinal_to_read += 1;
3026                next_offset += envelope_size;
3027            }
3028
3029            let next_out_of_line = decoder.next_out_of_line();
3030            let handles_before = decoder.remaining_handles();
3031            if let Some((inlined, num_bytes, num_handles)) =
3032                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3033            {
3034                let member_inline_size =
3035                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3036                if inlined != (member_inline_size <= 4) {
3037                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3038                }
3039                let inner_offset;
3040                let mut inner_depth = depth.clone();
3041                if inlined {
3042                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3043                    inner_offset = next_offset;
3044                } else {
3045                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3046                    inner_depth.increment()?;
3047                }
3048                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u32, D));
3049                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3050                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3051                {
3052                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3053                }
3054                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3055                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3056                }
3057            }
3058
3059            next_offset += envelope_size;
3060
3061            // Decode the remaining unknown envelopes.
3062            while next_offset < end_offset {
3063                _next_ordinal_to_read += 1;
3064                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3065                next_offset += envelope_size;
3066            }
3067
3068            Ok(())
3069        }
3070    }
3071
3072    impl TouchPointerSample {
3073        #[inline(always)]
3074        fn max_ordinal_present(&self) -> u64 {
3075            if let Some(_) = self.position_in_viewport {
3076                return 3;
3077            }
3078            if let Some(_) = self.phase {
3079                return 2;
3080            }
3081            if let Some(_) = self.interaction {
3082                return 1;
3083            }
3084            0
3085        }
3086    }
3087
3088    impl fidl::encoding::ValueTypeMarker for TouchPointerSample {
3089        type Borrowed<'a> = &'a Self;
3090        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3091            value
3092        }
3093    }
3094
3095    unsafe impl fidl::encoding::TypeMarker for TouchPointerSample {
3096        type Owned = Self;
3097
3098        #[inline(always)]
3099        fn inline_align(_context: fidl::encoding::Context) -> usize {
3100            8
3101        }
3102
3103        #[inline(always)]
3104        fn inline_size(_context: fidl::encoding::Context) -> usize {
3105            16
3106        }
3107    }
3108
3109    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TouchPointerSample, D>
3110        for &TouchPointerSample
3111    {
3112        unsafe fn encode(
3113            self,
3114            encoder: &mut fidl::encoding::Encoder<'_, D>,
3115            offset: usize,
3116            mut depth: fidl::encoding::Depth,
3117        ) -> fidl::Result<()> {
3118            encoder.debug_check_bounds::<TouchPointerSample>(offset);
3119            // Vector header
3120            let max_ordinal: u64 = self.max_ordinal_present();
3121            encoder.write_num(max_ordinal, offset);
3122            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3123            // Calling encoder.out_of_line_offset(0) is not allowed.
3124            if max_ordinal == 0 {
3125                return Ok(());
3126            }
3127            depth.increment()?;
3128            let envelope_size = 8;
3129            let bytes_len = max_ordinal as usize * envelope_size;
3130            #[allow(unused_variables)]
3131            let offset = encoder.out_of_line_offset(bytes_len);
3132            let mut _prev_end_offset: usize = 0;
3133            if 1 > max_ordinal {
3134                return Ok(());
3135            }
3136
3137            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3138            // are envelope_size bytes.
3139            let cur_offset: usize = (1 - 1) * envelope_size;
3140
3141            // Zero reserved fields.
3142            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3143
3144            // Safety:
3145            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3146            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3147            //   envelope_size bytes, there is always sufficient room.
3148            fidl::encoding::encode_in_envelope_optional::<TouchInteractionId, D>(
3149                self.interaction
3150                    .as_ref()
3151                    .map(<TouchInteractionId as fidl::encoding::ValueTypeMarker>::borrow),
3152                encoder,
3153                offset + cur_offset,
3154                depth,
3155            )?;
3156
3157            _prev_end_offset = cur_offset + envelope_size;
3158            if 2 > max_ordinal {
3159                return Ok(());
3160            }
3161
3162            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3163            // are envelope_size bytes.
3164            let cur_offset: usize = (2 - 1) * envelope_size;
3165
3166            // Zero reserved fields.
3167            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3168
3169            // Safety:
3170            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3171            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3172            //   envelope_size bytes, there is always sufficient room.
3173            fidl::encoding::encode_in_envelope_optional::<EventPhase, D>(
3174                self.phase.as_ref().map(<EventPhase as fidl::encoding::ValueTypeMarker>::borrow),
3175                encoder,
3176                offset + cur_offset,
3177                depth,
3178            )?;
3179
3180            _prev_end_offset = cur_offset + envelope_size;
3181            if 3 > max_ordinal {
3182                return Ok(());
3183            }
3184
3185            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3186            // are envelope_size bytes.
3187            let cur_offset: usize = (3 - 1) * envelope_size;
3188
3189            // Zero reserved fields.
3190            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3191
3192            // Safety:
3193            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3194            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3195            //   envelope_size bytes, there is always sufficient room.
3196            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<f32, 2>, D>(
3197                self.position_in_viewport.as_ref().map(
3198                    <fidl::encoding::Array<f32, 2> as fidl::encoding::ValueTypeMarker>::borrow,
3199                ),
3200                encoder,
3201                offset + cur_offset,
3202                depth,
3203            )?;
3204
3205            _prev_end_offset = cur_offset + envelope_size;
3206
3207            Ok(())
3208        }
3209    }
3210
3211    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TouchPointerSample {
3212        #[inline(always)]
3213        fn new_empty() -> Self {
3214            Self::default()
3215        }
3216
3217        unsafe fn decode(
3218            &mut self,
3219            decoder: &mut fidl::encoding::Decoder<'_, D>,
3220            offset: usize,
3221            mut depth: fidl::encoding::Depth,
3222        ) -> fidl::Result<()> {
3223            decoder.debug_check_bounds::<Self>(offset);
3224            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3225                None => return Err(fidl::Error::NotNullable),
3226                Some(len) => len,
3227            };
3228            // Calling decoder.out_of_line_offset(0) is not allowed.
3229            if len == 0 {
3230                return Ok(());
3231            };
3232            depth.increment()?;
3233            let envelope_size = 8;
3234            let bytes_len = len * envelope_size;
3235            let offset = decoder.out_of_line_offset(bytes_len)?;
3236            // Decode the envelope for each type.
3237            let mut _next_ordinal_to_read = 0;
3238            let mut next_offset = offset;
3239            let end_offset = offset + bytes_len;
3240            _next_ordinal_to_read += 1;
3241            if next_offset >= end_offset {
3242                return Ok(());
3243            }
3244
3245            // Decode unknown envelopes for gaps in ordinals.
3246            while _next_ordinal_to_read < 1 {
3247                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3248                _next_ordinal_to_read += 1;
3249                next_offset += envelope_size;
3250            }
3251
3252            let next_out_of_line = decoder.next_out_of_line();
3253            let handles_before = decoder.remaining_handles();
3254            if let Some((inlined, num_bytes, num_handles)) =
3255                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3256            {
3257                let member_inline_size =
3258                    <TouchInteractionId as fidl::encoding::TypeMarker>::inline_size(
3259                        decoder.context,
3260                    );
3261                if inlined != (member_inline_size <= 4) {
3262                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3263                }
3264                let inner_offset;
3265                let mut inner_depth = depth.clone();
3266                if inlined {
3267                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3268                    inner_offset = next_offset;
3269                } else {
3270                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3271                    inner_depth.increment()?;
3272                }
3273                let val_ref =
3274                    self.interaction.get_or_insert_with(|| fidl::new_empty!(TouchInteractionId, D));
3275                fidl::decode!(TouchInteractionId, D, val_ref, decoder, inner_offset, inner_depth)?;
3276                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3277                {
3278                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3279                }
3280                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3281                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3282                }
3283            }
3284
3285            next_offset += envelope_size;
3286            _next_ordinal_to_read += 1;
3287            if next_offset >= end_offset {
3288                return Ok(());
3289            }
3290
3291            // Decode unknown envelopes for gaps in ordinals.
3292            while _next_ordinal_to_read < 2 {
3293                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3294                _next_ordinal_to_read += 1;
3295                next_offset += envelope_size;
3296            }
3297
3298            let next_out_of_line = decoder.next_out_of_line();
3299            let handles_before = decoder.remaining_handles();
3300            if let Some((inlined, num_bytes, num_handles)) =
3301                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3302            {
3303                let member_inline_size =
3304                    <EventPhase as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3305                if inlined != (member_inline_size <= 4) {
3306                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3307                }
3308                let inner_offset;
3309                let mut inner_depth = depth.clone();
3310                if inlined {
3311                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3312                    inner_offset = next_offset;
3313                } else {
3314                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3315                    inner_depth.increment()?;
3316                }
3317                let val_ref = self.phase.get_or_insert_with(|| fidl::new_empty!(EventPhase, D));
3318                fidl::decode!(EventPhase, D, val_ref, decoder, inner_offset, inner_depth)?;
3319                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3320                {
3321                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3322                }
3323                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3324                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3325                }
3326            }
3327
3328            next_offset += envelope_size;
3329            _next_ordinal_to_read += 1;
3330            if next_offset >= end_offset {
3331                return Ok(());
3332            }
3333
3334            // Decode unknown envelopes for gaps in ordinals.
3335            while _next_ordinal_to_read < 3 {
3336                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3337                _next_ordinal_to_read += 1;
3338                next_offset += envelope_size;
3339            }
3340
3341            let next_out_of_line = decoder.next_out_of_line();
3342            let handles_before = decoder.remaining_handles();
3343            if let Some((inlined, num_bytes, num_handles)) =
3344                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3345            {
3346                let member_inline_size =
3347                    <fidl::encoding::Array<f32, 2> as fidl::encoding::TypeMarker>::inline_size(
3348                        decoder.context,
3349                    );
3350                if inlined != (member_inline_size <= 4) {
3351                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3352                }
3353                let inner_offset;
3354                let mut inner_depth = depth.clone();
3355                if inlined {
3356                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3357                    inner_offset = next_offset;
3358                } else {
3359                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3360                    inner_depth.increment()?;
3361                }
3362                let val_ref = self
3363                    .position_in_viewport
3364                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<f32, 2>, D));
3365                fidl::decode!(fidl::encoding::Array<f32, 2>, D, val_ref, decoder, inner_offset, inner_depth)?;
3366                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3367                {
3368                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3369                }
3370                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3371                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3372                }
3373            }
3374
3375            next_offset += envelope_size;
3376
3377            // Decode the remaining unknown envelopes.
3378            while next_offset < end_offset {
3379                _next_ordinal_to_read += 1;
3380                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3381                next_offset += envelope_size;
3382            }
3383
3384            Ok(())
3385        }
3386    }
3387
3388    impl TouchResponse {
3389        #[inline(always)]
3390        fn max_ordinal_present(&self) -> u64 {
3391            if let Some(_) = self.trace_flow_id {
3392                return 2;
3393            }
3394            if let Some(_) = self.response_type {
3395                return 1;
3396            }
3397            0
3398        }
3399    }
3400
3401    impl fidl::encoding::ValueTypeMarker for TouchResponse {
3402        type Borrowed<'a> = &'a Self;
3403        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3404            value
3405        }
3406    }
3407
3408    unsafe impl fidl::encoding::TypeMarker for TouchResponse {
3409        type Owned = Self;
3410
3411        #[inline(always)]
3412        fn inline_align(_context: fidl::encoding::Context) -> usize {
3413            8
3414        }
3415
3416        #[inline(always)]
3417        fn inline_size(_context: fidl::encoding::Context) -> usize {
3418            16
3419        }
3420    }
3421
3422    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TouchResponse, D>
3423        for &TouchResponse
3424    {
3425        unsafe fn encode(
3426            self,
3427            encoder: &mut fidl::encoding::Encoder<'_, D>,
3428            offset: usize,
3429            mut depth: fidl::encoding::Depth,
3430        ) -> fidl::Result<()> {
3431            encoder.debug_check_bounds::<TouchResponse>(offset);
3432            // Vector header
3433            let max_ordinal: u64 = self.max_ordinal_present();
3434            encoder.write_num(max_ordinal, offset);
3435            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3436            // Calling encoder.out_of_line_offset(0) is not allowed.
3437            if max_ordinal == 0 {
3438                return Ok(());
3439            }
3440            depth.increment()?;
3441            let envelope_size = 8;
3442            let bytes_len = max_ordinal as usize * envelope_size;
3443            #[allow(unused_variables)]
3444            let offset = encoder.out_of_line_offset(bytes_len);
3445            let mut _prev_end_offset: usize = 0;
3446            if 1 > max_ordinal {
3447                return Ok(());
3448            }
3449
3450            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3451            // are envelope_size bytes.
3452            let cur_offset: usize = (1 - 1) * envelope_size;
3453
3454            // Zero reserved fields.
3455            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3456
3457            // Safety:
3458            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3459            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3460            //   envelope_size bytes, there is always sufficient room.
3461            fidl::encoding::encode_in_envelope_optional::<TouchResponseType, D>(
3462                self.response_type
3463                    .as_ref()
3464                    .map(<TouchResponseType as fidl::encoding::ValueTypeMarker>::borrow),
3465                encoder,
3466                offset + cur_offset,
3467                depth,
3468            )?;
3469
3470            _prev_end_offset = cur_offset + envelope_size;
3471            if 2 > max_ordinal {
3472                return Ok(());
3473            }
3474
3475            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3476            // are envelope_size bytes.
3477            let cur_offset: usize = (2 - 1) * envelope_size;
3478
3479            // Zero reserved fields.
3480            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3481
3482            // Safety:
3483            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3484            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3485            //   envelope_size bytes, there is always sufficient room.
3486            fidl::encoding::encode_in_envelope_optional::<u64, D>(
3487                self.trace_flow_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3488                encoder,
3489                offset + cur_offset,
3490                depth,
3491            )?;
3492
3493            _prev_end_offset = cur_offset + envelope_size;
3494
3495            Ok(())
3496        }
3497    }
3498
3499    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TouchResponse {
3500        #[inline(always)]
3501        fn new_empty() -> Self {
3502            Self::default()
3503        }
3504
3505        unsafe fn decode(
3506            &mut self,
3507            decoder: &mut fidl::encoding::Decoder<'_, D>,
3508            offset: usize,
3509            mut depth: fidl::encoding::Depth,
3510        ) -> fidl::Result<()> {
3511            decoder.debug_check_bounds::<Self>(offset);
3512            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3513                None => return Err(fidl::Error::NotNullable),
3514                Some(len) => len,
3515            };
3516            // Calling decoder.out_of_line_offset(0) is not allowed.
3517            if len == 0 {
3518                return Ok(());
3519            };
3520            depth.increment()?;
3521            let envelope_size = 8;
3522            let bytes_len = len * envelope_size;
3523            let offset = decoder.out_of_line_offset(bytes_len)?;
3524            // Decode the envelope for each type.
3525            let mut _next_ordinal_to_read = 0;
3526            let mut next_offset = offset;
3527            let end_offset = offset + bytes_len;
3528            _next_ordinal_to_read += 1;
3529            if next_offset >= end_offset {
3530                return Ok(());
3531            }
3532
3533            // Decode unknown envelopes for gaps in ordinals.
3534            while _next_ordinal_to_read < 1 {
3535                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3536                _next_ordinal_to_read += 1;
3537                next_offset += envelope_size;
3538            }
3539
3540            let next_out_of_line = decoder.next_out_of_line();
3541            let handles_before = decoder.remaining_handles();
3542            if let Some((inlined, num_bytes, num_handles)) =
3543                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3544            {
3545                let member_inline_size =
3546                    <TouchResponseType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3547                if inlined != (member_inline_size <= 4) {
3548                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3549                }
3550                let inner_offset;
3551                let mut inner_depth = depth.clone();
3552                if inlined {
3553                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3554                    inner_offset = next_offset;
3555                } else {
3556                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3557                    inner_depth.increment()?;
3558                }
3559                let val_ref = self
3560                    .response_type
3561                    .get_or_insert_with(|| fidl::new_empty!(TouchResponseType, D));
3562                fidl::decode!(TouchResponseType, D, val_ref, decoder, inner_offset, inner_depth)?;
3563                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3564                {
3565                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3566                }
3567                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3568                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3569                }
3570            }
3571
3572            next_offset += envelope_size;
3573            _next_ordinal_to_read += 1;
3574            if next_offset >= end_offset {
3575                return Ok(());
3576            }
3577
3578            // Decode unknown envelopes for gaps in ordinals.
3579            while _next_ordinal_to_read < 2 {
3580                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3581                _next_ordinal_to_read += 1;
3582                next_offset += envelope_size;
3583            }
3584
3585            let next_out_of_line = decoder.next_out_of_line();
3586            let handles_before = decoder.remaining_handles();
3587            if let Some((inlined, num_bytes, num_handles)) =
3588                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3589            {
3590                let member_inline_size =
3591                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3592                if inlined != (member_inline_size <= 4) {
3593                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3594                }
3595                let inner_offset;
3596                let mut inner_depth = depth.clone();
3597                if inlined {
3598                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3599                    inner_offset = next_offset;
3600                } else {
3601                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3602                    inner_depth.increment()?;
3603                }
3604                let val_ref = self.trace_flow_id.get_or_insert_with(|| fidl::new_empty!(u64, D));
3605                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
3606                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3607                {
3608                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3609                }
3610                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3611                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3612                }
3613            }
3614
3615            next_offset += envelope_size;
3616
3617            // Decode the remaining unknown envelopes.
3618            while next_offset < end_offset {
3619                _next_ordinal_to_read += 1;
3620                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3621                next_offset += envelope_size;
3622            }
3623
3624            Ok(())
3625        }
3626    }
3627}