fidl_fuchsia_ui_pointerinjector__common/
fidl_fuchsia_ui_pointerinjector__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 pair of points, representing minimal and maximal extents.
12/// - The values are placed in (minimal, maximal) order.
13pub type Extents = [[f32; 2]; 2];
14
15/// A floating-point 3x3 matrix.
16/// - The values are placed in column-major order.
17pub type Mat3 = [f32; 9];
18
19/// A floating-point two-dimensional point.
20/// - The values are placed in (x, y) order.
21pub type Point2 = [f32; 2];
22
23/// The relative motion performed by a mouse device.
24/// - The valid range is defined in [`Config.RelativeMotionRange`].
25/// - The values are placed in (x, y) order.
26pub type RelativeMotion = [f32; 2];
27
28/// The valid values of relative motion for a mouse device.
29/// - The ranges are placed in (x, y) order.
30pub type RelativeMotionRange = [fidl_fuchsia_input_report__common::Axis; 2];
31
32pub const MAX_INJECT: u32 = 128;
33
34/// A characterization of a device that issues pointer event streams.
35#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
36#[repr(u32)]
37pub enum DeviceType {
38    /// A device intended for manipulation by direct contact over its surface.
39    Touch = 1,
40    /// A device intended for manipulation by precise movement over a surface.
41    Mouse = 2,
42}
43
44impl DeviceType {
45    #[inline]
46    pub fn from_primitive(prim: u32) -> Option<Self> {
47        match prim {
48            1 => Some(Self::Touch),
49            2 => Some(Self::Mouse),
50            _ => None,
51        }
52    }
53
54    #[inline]
55    pub const fn into_primitive(self) -> u32 {
56        self as u32
57    }
58}
59
60/// A specification of the UI clients that may have injected events dispatched
61/// to them in an |Target|. One is specified in |Config|.
62///
63/// A useful concept is "latching", where one or more clients may start
64/// receiving the pointer event stream, prior to assignment of stream ownership.
65/// After ownership is assigned (e.g., through a gesture disambiguation
66/// protocol), non-owning clients have their latch terminated -- they stop
67/// receiving the pointer event stream.
68/// - A client's latch does not itself confer stream ownership (receiving the
69///   entire pointer event stream); gesture disambiguation or device termination
70///   may prematurely end the stream dispatched to that client.
71/// - It's possible for a client to latch while hidden from the user (i.e.,
72///   manipulate a surface that is invisible to the user), where the occluding
73///   surface is owned by a client outside of |Target|. Conversely, these
74///   occluding clients cannot latch, because latched clients must be in
75///   |Target|'s view tree.
76#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
77#[repr(u32)]
78pub enum DispatchPolicy {
79    /// A single client latches onto a pointer event stream, where:
80    /// - the pointer event stream starts within the viewport rectangle,
81    /// - the latch happens on the ADD phase of the pointer event stream,
82    /// - the client is the |Target| itself.
83    /// Ownership is assigned immediately to the client.
84    ///
85    /// Note: This policy guarantees confidentiality, integrity, and
86    ///       availability of dispatch to the client, but by itself, does *not*
87    ///       confer immunity against UI redress attacks.
88    ExclusiveTarget = 1,
89    /// Multiple clients may latch onto a pointer stream, where:
90    /// - the pointer stream starts within the viewport rectangle,
91    /// - a hit test is performed on the ADD phase of the pointer event stream,
92    ///   which returns the top-most surface (in paint order) in the |Target|'s
93    ///   view tree,
94    /// - the top-most surface's client latches onto the pointer stream,
95    /// - the client's ancestors in the |Target|'s view tree also latch onto the
96    ///   pointer stream.
97    ///
98    /// With multiple latches, a pointer stream is dispatched in parallel to
99    /// each latched client, until ownership is assigned via gesture
100    /// disambiguation. The owner client will continue to receive the pointer
101    /// stream, and non-owners will receive a final CANCEL event for the stream.
102    ///
103    /// Note: It's possible for no clients to latch, if the hit test fails to
104    ///       hit any surface in any sub-view of |Target|.
105    /// Note: Each client will have its own copy of the viewport, placed
106    ///       accordingly in its own coordinate system.
107    TopHitAndAncestorsInTarget = 2,
108    /// The top hit client in the |Target|'s view tree receives hover events when
109    /// a cursor is positioned over it, unless the mouse is latched to a specific
110    /// client.
111    ///
112    /// A mouse initiates a latch via button down, and until the release of that
113    /// latch, mouse events are delivered to that latched client; other clients
114    /// do not receive hover events in the latch duration.
115    ///
116    /// Note: It's possible for no client to latch, if the hit test fails to
117    ///       hit any surface in any sub-view of |Target|.
118    /// Note: Each client will have its own copy of the viewport, placed
119    ///       accordingly in its own coordinate system.
120    MouseHoverAndLatchInTarget = 3,
121}
122
123impl DispatchPolicy {
124    #[inline]
125    pub fn from_primitive(prim: u32) -> Option<Self> {
126        match prim {
127            1 => Some(Self::ExclusiveTarget),
128            2 => Some(Self::TopHitAndAncestorsInTarget),
129            3 => Some(Self::MouseHoverAndLatchInTarget),
130            _ => None,
131        }
132    }
133
134    #[inline]
135    pub const fn into_primitive(self) -> u32 {
136        self as u32
137    }
138}
139
140/// The possible states of a pointer event stream's state machine.
141///
142/// A typical pointer will move through this state machine:
143/// ADD - CHANGE* - REMOVE
144#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
145#[repr(u32)]
146pub enum EventPhase {
147    /// The device has started tracking the pointer.
148    Add = 1,
149    /// The device has reported an update to the pointer state.
150    Change = 2,
151    /// The device has stopped tracking the pointer.
152    Remove = 3,
153    /// The event stream is no longer available.
154    Cancel = 4,
155}
156
157impl EventPhase {
158    #[inline]
159    pub fn from_primitive(prim: u32) -> Option<Self> {
160        match prim {
161            1 => Some(Self::Add),
162            2 => Some(Self::Change),
163            3 => Some(Self::Remove),
164            4 => Some(Self::Cancel),
165            _ => None,
166        }
167    }
168
169    #[inline]
170    pub const fn into_primitive(self) -> u32 {
171        self as u32
172    }
173}
174
175#[derive(Clone, Debug, PartialEq)]
176pub struct DeviceInjectRequest {
177    pub events: Vec<Event>,
178}
179
180impl fidl::Persistable for DeviceInjectRequest {}
181
182#[derive(Clone, Debug, Default, PartialEq)]
183pub struct Event {
184    /// The time when this event was observed.
185    ///
186    /// Required.
187    pub timestamp: Option<i64>,
188    /// The event's data.
189    ///
190    /// Required.
191    pub data: Option<Data>,
192    /// An identifier to correlate this event's send/receive occurrence across
193    /// component boundaries or abstraction layers.
194    pub trace_flow_id: Option<u64>,
195    #[doc(hidden)]
196    pub __source_breaking: fidl::marker::SourceBreaking,
197}
198
199impl fidl::Persistable for Event {}
200
201/// A description of each sampled data point for a pointer device.
202#[derive(Clone, Debug, Default, PartialEq)]
203pub struct PointerSample {
204    /// An identifier of the pointer that issued this event.
205    /// It is unique only to a specific pointer device.
206    pub pointer_id: Option<u32>,
207    /// The state of this event in the pointer event stream's state machine.
208    pub phase: Option<EventPhase>,
209    /// The position of this event, in the viewport's coordinate system.
210    pub position_in_viewport: Option<[f32; 2]>,
211    /// Relative vertical scrolling displacement by detent.
212    pub scroll_v: Option<i64>,
213    /// Relative horizontal scrolling displacement by detent.
214    pub scroll_h: Option<i64>,
215    /// Identifiers of currently pressed buttons.
216    pub pressed_buttons: Option<Vec<u8>>,
217    /// The movement of a mouse, independent of the viewport's coordinate
218    /// system.
219    pub relative_motion: Option<[f32; 2]>,
220    /// Recommended vertical scrolling displacement by physical pixel, it is
221    /// computed with accelerator, detent / mm to pixel ratio, etc.
222    pub scroll_v_physical_pixel: Option<f64>,
223    /// Recommended horizontal scrolling displacement by physical pixel, it
224    /// is computed with accelerator, detent / mm to pixel ratio, etc.
225    pub scroll_h_physical_pixel: Option<f64>,
226    /// Indicated if the scroll event is from a precision scroll device (HI_RES
227    /// mouse or touchpad). Clients may want to play interpolation animations
228    /// on non precision scroll device for smooth scrolling.
229    pub is_precision_scroll: Option<bool>,
230    #[doc(hidden)]
231    pub __source_breaking: fidl::marker::SourceBreaking,
232}
233
234impl fidl::Persistable for PointerSample {}
235
236/// A rectangular region that directs injected events into a target.
237///
238/// The viewport relates a pointer's position across multiple independent
239/// coordinate systems: the context, the viewport, and the dispatch clients.
240/// Intuitively, the viewport is how a pointer's position is mapped to an
241/// interactive part of the scene.
242///
243/// A matrix is used to relate the viewport coordinate system to the context
244/// coordinate system. A pair of extents defines the viewport's size in the
245/// viewport coordinate system. Together, they define the viewport's placement
246/// in the context coordinate system.
247///
248/// The viewport coordinate system is used to convey a pointer's coordinates in
249/// a scale-invariant way to dispatch clients, so that pointer movement can be
250/// interpreted correctly under effects like magnification. The context defines
251/// the viewport's minimal and maximal extents in the viewport coordinate
252/// system.
253/// - The boundary of the viewport, a rectangle, is axis aligned with the
254///   viewport coordinate system; however it may otherwise be freely positioned
255///   ("float") within it: there is translation and scaling, but no rotation.
256/// - Floating gives the injector some choice in how to convey coordinates, such
257///   as in Vulkan NDC, or in display pixel coordinates.
258/// - The viewport rectangle defines a latch region used in dispatch (described
259///   below).
260///
261/// A dispatch client receives a pointer's coordinates in the viewport
262/// coordinate system, along with a matrix to convert coordinates from the
263/// viewport coordinate system to the dispatch client's coordinate system.
264///
265/// All fields required.
266///
267/// TODO(https://fxbug.dev/42162296): Rename Viewport, it is used in Flatland.
268#[derive(Clone, Debug, Default, PartialEq)]
269pub struct Viewport {
270    /// The viewport's minimal and maximal extents in the viewport coordinate
271    /// system.
272    pub extents: Option<[[f32; 2]; 2]>,
273    /// A transformation matrix that describes how to map the viewport
274    /// coordinate system to the context coordinate system.
275    ///
276    /// This transform, together with |extents|, defines the viewport's
277    /// placement in the context coordinate system.
278    ///
279    /// This transform must be an invertible matrix (i.e., has a non-zero
280    /// determinant), which guarantees it describes a bijection between the
281    /// viewport coordinate system and the context coordinate system. A
282    /// non-invertible matrix is rejected.
283    pub viewport_to_context_transform: Option<[f32; 9]>,
284    #[doc(hidden)]
285    pub __source_breaking: fidl::marker::SourceBreaking,
286}
287
288impl fidl::Persistable for Viewport {}
289
290/// A selection of FIFO data sent over the channel.
291/// Each data may have a different issuance policy.
292#[derive(Clone, Debug)]
293pub enum Data {
294    /// The parameters of the viewport, sufficient for a client to correctly
295    /// interpret the position and scale of pointer events dispatched to it.
296    /// - It is issued on every change to the viewport.
297    Viewport(Viewport),
298    /// A description of each sampled data point in a pointer event stream.
299    /// - It is issued on every sample in the pointer event stream.
300    PointerSample(PointerSample),
301    #[doc(hidden)]
302    __SourceBreaking { unknown_ordinal: u64 },
303}
304
305/// Pattern that matches an unknown `Data` member.
306#[macro_export]
307macro_rules! DataUnknown {
308    () => {
309        _
310    };
311}
312
313// Custom PartialEq so that unknown variants are not equal to themselves.
314impl PartialEq for Data {
315    fn eq(&self, other: &Self) -> bool {
316        match (self, other) {
317            (Self::Viewport(x), Self::Viewport(y)) => *x == *y,
318            (Self::PointerSample(x), Self::PointerSample(y)) => *x == *y,
319            _ => false,
320        }
321    }
322}
323
324impl Data {
325    #[inline]
326    pub fn ordinal(&self) -> u64 {
327        match *self {
328            Self::Viewport(_) => 1,
329            Self::PointerSample(_) => 2,
330            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
331        }
332    }
333
334    #[inline]
335    pub fn unknown_variant_for_testing() -> Self {
336        Self::__SourceBreaking { unknown_ordinal: 0 }
337    }
338
339    #[inline]
340    pub fn is_unknown(&self) -> bool {
341        match self {
342            Self::__SourceBreaking { .. } => true,
343            _ => false,
344        }
345    }
346}
347
348impl fidl::Persistable for Data {}
349
350pub mod device_ordinals {
351    pub const INJECT: u64 = 0x123882bb65bff40;
352}
353
354pub mod registry_ordinals {
355    pub const REGISTER: u64 = 0x9f8410fe7326a00;
356}
357
358mod internal {
359    use super::*;
360    unsafe impl fidl::encoding::TypeMarker for DeviceType {
361        type Owned = Self;
362
363        #[inline(always)]
364        fn inline_align(_context: fidl::encoding::Context) -> usize {
365            std::mem::align_of::<u32>()
366        }
367
368        #[inline(always)]
369        fn inline_size(_context: fidl::encoding::Context) -> usize {
370            std::mem::size_of::<u32>()
371        }
372
373        #[inline(always)]
374        fn encode_is_copy() -> bool {
375            true
376        }
377
378        #[inline(always)]
379        fn decode_is_copy() -> bool {
380            false
381        }
382    }
383
384    impl fidl::encoding::ValueTypeMarker for DeviceType {
385        type Borrowed<'a> = Self;
386        #[inline(always)]
387        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
388            *value
389        }
390    }
391
392    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DeviceType {
393        #[inline]
394        unsafe fn encode(
395            self,
396            encoder: &mut fidl::encoding::Encoder<'_, D>,
397            offset: usize,
398            _depth: fidl::encoding::Depth,
399        ) -> fidl::Result<()> {
400            encoder.debug_check_bounds::<Self>(offset);
401            encoder.write_num(self.into_primitive(), offset);
402            Ok(())
403        }
404    }
405
406    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceType {
407        #[inline(always)]
408        fn new_empty() -> Self {
409            Self::Touch
410        }
411
412        #[inline]
413        unsafe fn decode(
414            &mut self,
415            decoder: &mut fidl::encoding::Decoder<'_, D>,
416            offset: usize,
417            _depth: fidl::encoding::Depth,
418        ) -> fidl::Result<()> {
419            decoder.debug_check_bounds::<Self>(offset);
420            let prim = decoder.read_num::<u32>(offset);
421
422            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
423            Ok(())
424        }
425    }
426    unsafe impl fidl::encoding::TypeMarker for DispatchPolicy {
427        type Owned = Self;
428
429        #[inline(always)]
430        fn inline_align(_context: fidl::encoding::Context) -> usize {
431            std::mem::align_of::<u32>()
432        }
433
434        #[inline(always)]
435        fn inline_size(_context: fidl::encoding::Context) -> usize {
436            std::mem::size_of::<u32>()
437        }
438
439        #[inline(always)]
440        fn encode_is_copy() -> bool {
441            true
442        }
443
444        #[inline(always)]
445        fn decode_is_copy() -> bool {
446            false
447        }
448    }
449
450    impl fidl::encoding::ValueTypeMarker for DispatchPolicy {
451        type Borrowed<'a> = Self;
452        #[inline(always)]
453        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
454            *value
455        }
456    }
457
458    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DispatchPolicy {
459        #[inline]
460        unsafe fn encode(
461            self,
462            encoder: &mut fidl::encoding::Encoder<'_, D>,
463            offset: usize,
464            _depth: fidl::encoding::Depth,
465        ) -> fidl::Result<()> {
466            encoder.debug_check_bounds::<Self>(offset);
467            encoder.write_num(self.into_primitive(), offset);
468            Ok(())
469        }
470    }
471
472    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DispatchPolicy {
473        #[inline(always)]
474        fn new_empty() -> Self {
475            Self::ExclusiveTarget
476        }
477
478        #[inline]
479        unsafe fn decode(
480            &mut self,
481            decoder: &mut fidl::encoding::Decoder<'_, D>,
482            offset: usize,
483            _depth: fidl::encoding::Depth,
484        ) -> fidl::Result<()> {
485            decoder.debug_check_bounds::<Self>(offset);
486            let prim = decoder.read_num::<u32>(offset);
487
488            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
489            Ok(())
490        }
491    }
492    unsafe impl fidl::encoding::TypeMarker for EventPhase {
493        type Owned = Self;
494
495        #[inline(always)]
496        fn inline_align(_context: fidl::encoding::Context) -> usize {
497            std::mem::align_of::<u32>()
498        }
499
500        #[inline(always)]
501        fn inline_size(_context: fidl::encoding::Context) -> usize {
502            std::mem::size_of::<u32>()
503        }
504
505        #[inline(always)]
506        fn encode_is_copy() -> bool {
507            true
508        }
509
510        #[inline(always)]
511        fn decode_is_copy() -> bool {
512            false
513        }
514    }
515
516    impl fidl::encoding::ValueTypeMarker for EventPhase {
517        type Borrowed<'a> = Self;
518        #[inline(always)]
519        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
520            *value
521        }
522    }
523
524    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for EventPhase {
525        #[inline]
526        unsafe fn encode(
527            self,
528            encoder: &mut fidl::encoding::Encoder<'_, D>,
529            offset: usize,
530            _depth: fidl::encoding::Depth,
531        ) -> fidl::Result<()> {
532            encoder.debug_check_bounds::<Self>(offset);
533            encoder.write_num(self.into_primitive(), offset);
534            Ok(())
535        }
536    }
537
538    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EventPhase {
539        #[inline(always)]
540        fn new_empty() -> Self {
541            Self::Add
542        }
543
544        #[inline]
545        unsafe fn decode(
546            &mut self,
547            decoder: &mut fidl::encoding::Decoder<'_, D>,
548            offset: usize,
549            _depth: fidl::encoding::Depth,
550        ) -> fidl::Result<()> {
551            decoder.debug_check_bounds::<Self>(offset);
552            let prim = decoder.read_num::<u32>(offset);
553
554            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
555            Ok(())
556        }
557    }
558
559    impl fidl::encoding::ValueTypeMarker for DeviceInjectRequest {
560        type Borrowed<'a> = &'a Self;
561        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
562            value
563        }
564    }
565
566    unsafe impl fidl::encoding::TypeMarker for DeviceInjectRequest {
567        type Owned = Self;
568
569        #[inline(always)]
570        fn inline_align(_context: fidl::encoding::Context) -> usize {
571            8
572        }
573
574        #[inline(always)]
575        fn inline_size(_context: fidl::encoding::Context) -> usize {
576            16
577        }
578    }
579
580    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceInjectRequest, D>
581        for &DeviceInjectRequest
582    {
583        #[inline]
584        unsafe fn encode(
585            self,
586            encoder: &mut fidl::encoding::Encoder<'_, D>,
587            offset: usize,
588            _depth: fidl::encoding::Depth,
589        ) -> fidl::Result<()> {
590            encoder.debug_check_bounds::<DeviceInjectRequest>(offset);
591            // Delegate to tuple encoding.
592            fidl::encoding::Encode::<DeviceInjectRequest, D>::encode(
593                (<fidl::encoding::Vector<Event, 128> as fidl::encoding::ValueTypeMarker>::borrow(
594                    &self.events,
595                ),),
596                encoder,
597                offset,
598                _depth,
599            )
600        }
601    }
602    unsafe impl<
603            D: fidl::encoding::ResourceDialect,
604            T0: fidl::encoding::Encode<fidl::encoding::Vector<Event, 128>, D>,
605        > fidl::encoding::Encode<DeviceInjectRequest, D> for (T0,)
606    {
607        #[inline]
608        unsafe fn encode(
609            self,
610            encoder: &mut fidl::encoding::Encoder<'_, D>,
611            offset: usize,
612            depth: fidl::encoding::Depth,
613        ) -> fidl::Result<()> {
614            encoder.debug_check_bounds::<DeviceInjectRequest>(offset);
615            // Zero out padding regions. There's no need to apply masks
616            // because the unmasked parts will be overwritten by fields.
617            // Write the fields.
618            self.0.encode(encoder, offset + 0, depth)?;
619            Ok(())
620        }
621    }
622
623    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceInjectRequest {
624        #[inline(always)]
625        fn new_empty() -> Self {
626            Self { events: fidl::new_empty!(fidl::encoding::Vector<Event, 128>, D) }
627        }
628
629        #[inline]
630        unsafe fn decode(
631            &mut self,
632            decoder: &mut fidl::encoding::Decoder<'_, D>,
633            offset: usize,
634            _depth: fidl::encoding::Depth,
635        ) -> fidl::Result<()> {
636            decoder.debug_check_bounds::<Self>(offset);
637            // Verify that padding bytes are zero.
638            fidl::decode!(fidl::encoding::Vector<Event, 128>, D, &mut self.events, decoder, offset + 0, _depth)?;
639            Ok(())
640        }
641    }
642
643    impl Event {
644        #[inline(always)]
645        fn max_ordinal_present(&self) -> u64 {
646            if let Some(_) = self.trace_flow_id {
647                return 3;
648            }
649            if let Some(_) = self.data {
650                return 2;
651            }
652            if let Some(_) = self.timestamp {
653                return 1;
654            }
655            0
656        }
657    }
658
659    impl fidl::encoding::ValueTypeMarker for Event {
660        type Borrowed<'a> = &'a Self;
661        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
662            value
663        }
664    }
665
666    unsafe impl fidl::encoding::TypeMarker for Event {
667        type Owned = Self;
668
669        #[inline(always)]
670        fn inline_align(_context: fidl::encoding::Context) -> usize {
671            8
672        }
673
674        #[inline(always)]
675        fn inline_size(_context: fidl::encoding::Context) -> usize {
676            16
677        }
678    }
679
680    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Event, D> for &Event {
681        unsafe fn encode(
682            self,
683            encoder: &mut fidl::encoding::Encoder<'_, D>,
684            offset: usize,
685            mut depth: fidl::encoding::Depth,
686        ) -> fidl::Result<()> {
687            encoder.debug_check_bounds::<Event>(offset);
688            // Vector header
689            let max_ordinal: u64 = self.max_ordinal_present();
690            encoder.write_num(max_ordinal, offset);
691            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
692            // Calling encoder.out_of_line_offset(0) is not allowed.
693            if max_ordinal == 0 {
694                return Ok(());
695            }
696            depth.increment()?;
697            let envelope_size = 8;
698            let bytes_len = max_ordinal as usize * envelope_size;
699            #[allow(unused_variables)]
700            let offset = encoder.out_of_line_offset(bytes_len);
701            let mut _prev_end_offset: usize = 0;
702            if 1 > max_ordinal {
703                return Ok(());
704            }
705
706            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
707            // are envelope_size bytes.
708            let cur_offset: usize = (1 - 1) * envelope_size;
709
710            // Zero reserved fields.
711            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
712
713            // Safety:
714            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
715            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
716            //   envelope_size bytes, there is always sufficient room.
717            fidl::encoding::encode_in_envelope_optional::<i64, D>(
718                self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
719                encoder,
720                offset + cur_offset,
721                depth,
722            )?;
723
724            _prev_end_offset = cur_offset + envelope_size;
725            if 2 > max_ordinal {
726                return Ok(());
727            }
728
729            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
730            // are envelope_size bytes.
731            let cur_offset: usize = (2 - 1) * envelope_size;
732
733            // Zero reserved fields.
734            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
735
736            // Safety:
737            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
738            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
739            //   envelope_size bytes, there is always sufficient room.
740            fidl::encoding::encode_in_envelope_optional::<Data, D>(
741                self.data.as_ref().map(<Data as fidl::encoding::ValueTypeMarker>::borrow),
742                encoder,
743                offset + cur_offset,
744                depth,
745            )?;
746
747            _prev_end_offset = cur_offset + envelope_size;
748            if 3 > max_ordinal {
749                return Ok(());
750            }
751
752            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
753            // are envelope_size bytes.
754            let cur_offset: usize = (3 - 1) * envelope_size;
755
756            // Zero reserved fields.
757            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
758
759            // Safety:
760            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
761            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
762            //   envelope_size bytes, there is always sufficient room.
763            fidl::encoding::encode_in_envelope_optional::<u64, D>(
764                self.trace_flow_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
765                encoder,
766                offset + cur_offset,
767                depth,
768            )?;
769
770            _prev_end_offset = cur_offset + envelope_size;
771
772            Ok(())
773        }
774    }
775
776    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Event {
777        #[inline(always)]
778        fn new_empty() -> Self {
779            Self::default()
780        }
781
782        unsafe fn decode(
783            &mut self,
784            decoder: &mut fidl::encoding::Decoder<'_, D>,
785            offset: usize,
786            mut depth: fidl::encoding::Depth,
787        ) -> fidl::Result<()> {
788            decoder.debug_check_bounds::<Self>(offset);
789            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
790                None => return Err(fidl::Error::NotNullable),
791                Some(len) => len,
792            };
793            // Calling decoder.out_of_line_offset(0) is not allowed.
794            if len == 0 {
795                return Ok(());
796            };
797            depth.increment()?;
798            let envelope_size = 8;
799            let bytes_len = len * envelope_size;
800            let offset = decoder.out_of_line_offset(bytes_len)?;
801            // Decode the envelope for each type.
802            let mut _next_ordinal_to_read = 0;
803            let mut next_offset = offset;
804            let end_offset = offset + bytes_len;
805            _next_ordinal_to_read += 1;
806            if next_offset >= end_offset {
807                return Ok(());
808            }
809
810            // Decode unknown envelopes for gaps in ordinals.
811            while _next_ordinal_to_read < 1 {
812                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
813                _next_ordinal_to_read += 1;
814                next_offset += envelope_size;
815            }
816
817            let next_out_of_line = decoder.next_out_of_line();
818            let handles_before = decoder.remaining_handles();
819            if let Some((inlined, num_bytes, num_handles)) =
820                fidl::encoding::decode_envelope_header(decoder, next_offset)?
821            {
822                let member_inline_size =
823                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
824                if inlined != (member_inline_size <= 4) {
825                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
826                }
827                let inner_offset;
828                let mut inner_depth = depth.clone();
829                if inlined {
830                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
831                    inner_offset = next_offset;
832                } else {
833                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
834                    inner_depth.increment()?;
835                }
836                let val_ref = self.timestamp.get_or_insert_with(|| fidl::new_empty!(i64, D));
837                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
838                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
839                {
840                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
841                }
842                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
843                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
844                }
845            }
846
847            next_offset += envelope_size;
848            _next_ordinal_to_read += 1;
849            if next_offset >= end_offset {
850                return Ok(());
851            }
852
853            // Decode unknown envelopes for gaps in ordinals.
854            while _next_ordinal_to_read < 2 {
855                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
856                _next_ordinal_to_read += 1;
857                next_offset += envelope_size;
858            }
859
860            let next_out_of_line = decoder.next_out_of_line();
861            let handles_before = decoder.remaining_handles();
862            if let Some((inlined, num_bytes, num_handles)) =
863                fidl::encoding::decode_envelope_header(decoder, next_offset)?
864            {
865                let member_inline_size =
866                    <Data as fidl::encoding::TypeMarker>::inline_size(decoder.context);
867                if inlined != (member_inline_size <= 4) {
868                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
869                }
870                let inner_offset;
871                let mut inner_depth = depth.clone();
872                if inlined {
873                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
874                    inner_offset = next_offset;
875                } else {
876                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
877                    inner_depth.increment()?;
878                }
879                let val_ref = self.data.get_or_insert_with(|| fidl::new_empty!(Data, D));
880                fidl::decode!(Data, D, val_ref, decoder, inner_offset, inner_depth)?;
881                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
882                {
883                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
884                }
885                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
886                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
887                }
888            }
889
890            next_offset += envelope_size;
891            _next_ordinal_to_read += 1;
892            if next_offset >= end_offset {
893                return Ok(());
894            }
895
896            // Decode unknown envelopes for gaps in ordinals.
897            while _next_ordinal_to_read < 3 {
898                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
899                _next_ordinal_to_read += 1;
900                next_offset += envelope_size;
901            }
902
903            let next_out_of_line = decoder.next_out_of_line();
904            let handles_before = decoder.remaining_handles();
905            if let Some((inlined, num_bytes, num_handles)) =
906                fidl::encoding::decode_envelope_header(decoder, next_offset)?
907            {
908                let member_inline_size =
909                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
910                if inlined != (member_inline_size <= 4) {
911                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
912                }
913                let inner_offset;
914                let mut inner_depth = depth.clone();
915                if inlined {
916                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
917                    inner_offset = next_offset;
918                } else {
919                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
920                    inner_depth.increment()?;
921                }
922                let val_ref = self.trace_flow_id.get_or_insert_with(|| fidl::new_empty!(u64, D));
923                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
924                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
925                {
926                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
927                }
928                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
929                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
930                }
931            }
932
933            next_offset += envelope_size;
934
935            // Decode the remaining unknown envelopes.
936            while next_offset < end_offset {
937                _next_ordinal_to_read += 1;
938                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
939                next_offset += envelope_size;
940            }
941
942            Ok(())
943        }
944    }
945
946    impl PointerSample {
947        #[inline(always)]
948        fn max_ordinal_present(&self) -> u64 {
949            if let Some(_) = self.is_precision_scroll {
950                return 10;
951            }
952            if let Some(_) = self.scroll_h_physical_pixel {
953                return 9;
954            }
955            if let Some(_) = self.scroll_v_physical_pixel {
956                return 8;
957            }
958            if let Some(_) = self.relative_motion {
959                return 7;
960            }
961            if let Some(_) = self.pressed_buttons {
962                return 6;
963            }
964            if let Some(_) = self.scroll_h {
965                return 5;
966            }
967            if let Some(_) = self.scroll_v {
968                return 4;
969            }
970            if let Some(_) = self.position_in_viewport {
971                return 3;
972            }
973            if let Some(_) = self.phase {
974                return 2;
975            }
976            if let Some(_) = self.pointer_id {
977                return 1;
978            }
979            0
980        }
981    }
982
983    impl fidl::encoding::ValueTypeMarker for PointerSample {
984        type Borrowed<'a> = &'a Self;
985        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
986            value
987        }
988    }
989
990    unsafe impl fidl::encoding::TypeMarker for PointerSample {
991        type Owned = Self;
992
993        #[inline(always)]
994        fn inline_align(_context: fidl::encoding::Context) -> usize {
995            8
996        }
997
998        #[inline(always)]
999        fn inline_size(_context: fidl::encoding::Context) -> usize {
1000            16
1001        }
1002    }
1003
1004    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PointerSample, D>
1005        for &PointerSample
1006    {
1007        unsafe fn encode(
1008            self,
1009            encoder: &mut fidl::encoding::Encoder<'_, D>,
1010            offset: usize,
1011            mut depth: fidl::encoding::Depth,
1012        ) -> fidl::Result<()> {
1013            encoder.debug_check_bounds::<PointerSample>(offset);
1014            // Vector header
1015            let max_ordinal: u64 = self.max_ordinal_present();
1016            encoder.write_num(max_ordinal, offset);
1017            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1018            // Calling encoder.out_of_line_offset(0) is not allowed.
1019            if max_ordinal == 0 {
1020                return Ok(());
1021            }
1022            depth.increment()?;
1023            let envelope_size = 8;
1024            let bytes_len = max_ordinal as usize * envelope_size;
1025            #[allow(unused_variables)]
1026            let offset = encoder.out_of_line_offset(bytes_len);
1027            let mut _prev_end_offset: usize = 0;
1028            if 1 > max_ordinal {
1029                return Ok(());
1030            }
1031
1032            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1033            // are envelope_size bytes.
1034            let cur_offset: usize = (1 - 1) * envelope_size;
1035
1036            // Zero reserved fields.
1037            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1038
1039            // Safety:
1040            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1041            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1042            //   envelope_size bytes, there is always sufficient room.
1043            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1044                self.pointer_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1045                encoder,
1046                offset + cur_offset,
1047                depth,
1048            )?;
1049
1050            _prev_end_offset = cur_offset + envelope_size;
1051            if 2 > max_ordinal {
1052                return Ok(());
1053            }
1054
1055            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1056            // are envelope_size bytes.
1057            let cur_offset: usize = (2 - 1) * envelope_size;
1058
1059            // Zero reserved fields.
1060            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1061
1062            // Safety:
1063            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1064            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1065            //   envelope_size bytes, there is always sufficient room.
1066            fidl::encoding::encode_in_envelope_optional::<EventPhase, D>(
1067                self.phase.as_ref().map(<EventPhase as fidl::encoding::ValueTypeMarker>::borrow),
1068                encoder,
1069                offset + cur_offset,
1070                depth,
1071            )?;
1072
1073            _prev_end_offset = cur_offset + envelope_size;
1074            if 3 > max_ordinal {
1075                return Ok(());
1076            }
1077
1078            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1079            // are envelope_size bytes.
1080            let cur_offset: usize = (3 - 1) * envelope_size;
1081
1082            // Zero reserved fields.
1083            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1084
1085            // Safety:
1086            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1087            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1088            //   envelope_size bytes, there is always sufficient room.
1089            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<f32, 2>, D>(
1090                self.position_in_viewport.as_ref().map(
1091                    <fidl::encoding::Array<f32, 2> as fidl::encoding::ValueTypeMarker>::borrow,
1092                ),
1093                encoder,
1094                offset + cur_offset,
1095                depth,
1096            )?;
1097
1098            _prev_end_offset = cur_offset + envelope_size;
1099            if 4 > max_ordinal {
1100                return Ok(());
1101            }
1102
1103            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1104            // are envelope_size bytes.
1105            let cur_offset: usize = (4 - 1) * envelope_size;
1106
1107            // Zero reserved fields.
1108            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1109
1110            // Safety:
1111            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1112            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1113            //   envelope_size bytes, there is always sufficient room.
1114            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1115                self.scroll_v.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1116                encoder,
1117                offset + cur_offset,
1118                depth,
1119            )?;
1120
1121            _prev_end_offset = cur_offset + envelope_size;
1122            if 5 > max_ordinal {
1123                return Ok(());
1124            }
1125
1126            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1127            // are envelope_size bytes.
1128            let cur_offset: usize = (5 - 1) * envelope_size;
1129
1130            // Zero reserved fields.
1131            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1132
1133            // Safety:
1134            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1135            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1136            //   envelope_size bytes, there is always sufficient room.
1137            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1138                self.scroll_h.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1139                encoder,
1140                offset + cur_offset,
1141                depth,
1142            )?;
1143
1144            _prev_end_offset = cur_offset + envelope_size;
1145            if 6 > max_ordinal {
1146                return Ok(());
1147            }
1148
1149            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1150            // are envelope_size bytes.
1151            let cur_offset: usize = (6 - 1) * envelope_size;
1152
1153            // Zero reserved fields.
1154            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1155
1156            // Safety:
1157            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1158            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1159            //   envelope_size bytes, there is always sufficient room.
1160            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 32>, D>(
1161                self.pressed_buttons.as_ref().map(
1162                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow,
1163                ),
1164                encoder,
1165                offset + cur_offset,
1166                depth,
1167            )?;
1168
1169            _prev_end_offset = cur_offset + envelope_size;
1170            if 7 > max_ordinal {
1171                return Ok(());
1172            }
1173
1174            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1175            // are envelope_size bytes.
1176            let cur_offset: usize = (7 - 1) * envelope_size;
1177
1178            // Zero reserved fields.
1179            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1180
1181            // Safety:
1182            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1183            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1184            //   envelope_size bytes, there is always sufficient room.
1185            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<f32, 2>, D>(
1186                self.relative_motion.as_ref().map(
1187                    <fidl::encoding::Array<f32, 2> as fidl::encoding::ValueTypeMarker>::borrow,
1188                ),
1189                encoder,
1190                offset + cur_offset,
1191                depth,
1192            )?;
1193
1194            _prev_end_offset = cur_offset + envelope_size;
1195            if 8 > max_ordinal {
1196                return Ok(());
1197            }
1198
1199            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1200            // are envelope_size bytes.
1201            let cur_offset: usize = (8 - 1) * envelope_size;
1202
1203            // Zero reserved fields.
1204            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1205
1206            // Safety:
1207            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1208            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1209            //   envelope_size bytes, there is always sufficient room.
1210            fidl::encoding::encode_in_envelope_optional::<f64, D>(
1211                self.scroll_v_physical_pixel
1212                    .as_ref()
1213                    .map(<f64 as fidl::encoding::ValueTypeMarker>::borrow),
1214                encoder,
1215                offset + cur_offset,
1216                depth,
1217            )?;
1218
1219            _prev_end_offset = cur_offset + envelope_size;
1220            if 9 > max_ordinal {
1221                return Ok(());
1222            }
1223
1224            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1225            // are envelope_size bytes.
1226            let cur_offset: usize = (9 - 1) * envelope_size;
1227
1228            // Zero reserved fields.
1229            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1230
1231            // Safety:
1232            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1233            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1234            //   envelope_size bytes, there is always sufficient room.
1235            fidl::encoding::encode_in_envelope_optional::<f64, D>(
1236                self.scroll_h_physical_pixel
1237                    .as_ref()
1238                    .map(<f64 as fidl::encoding::ValueTypeMarker>::borrow),
1239                encoder,
1240                offset + cur_offset,
1241                depth,
1242            )?;
1243
1244            _prev_end_offset = cur_offset + envelope_size;
1245            if 10 > max_ordinal {
1246                return Ok(());
1247            }
1248
1249            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1250            // are envelope_size bytes.
1251            let cur_offset: usize = (10 - 1) * envelope_size;
1252
1253            // Zero reserved fields.
1254            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1255
1256            // Safety:
1257            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1258            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1259            //   envelope_size bytes, there is always sufficient room.
1260            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1261                self.is_precision_scroll
1262                    .as_ref()
1263                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1264                encoder,
1265                offset + cur_offset,
1266                depth,
1267            )?;
1268
1269            _prev_end_offset = cur_offset + envelope_size;
1270
1271            Ok(())
1272        }
1273    }
1274
1275    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PointerSample {
1276        #[inline(always)]
1277        fn new_empty() -> Self {
1278            Self::default()
1279        }
1280
1281        unsafe fn decode(
1282            &mut self,
1283            decoder: &mut fidl::encoding::Decoder<'_, D>,
1284            offset: usize,
1285            mut depth: fidl::encoding::Depth,
1286        ) -> fidl::Result<()> {
1287            decoder.debug_check_bounds::<Self>(offset);
1288            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1289                None => return Err(fidl::Error::NotNullable),
1290                Some(len) => len,
1291            };
1292            // Calling decoder.out_of_line_offset(0) is not allowed.
1293            if len == 0 {
1294                return Ok(());
1295            };
1296            depth.increment()?;
1297            let envelope_size = 8;
1298            let bytes_len = len * envelope_size;
1299            let offset = decoder.out_of_line_offset(bytes_len)?;
1300            // Decode the envelope for each type.
1301            let mut _next_ordinal_to_read = 0;
1302            let mut next_offset = offset;
1303            let end_offset = offset + bytes_len;
1304            _next_ordinal_to_read += 1;
1305            if next_offset >= end_offset {
1306                return Ok(());
1307            }
1308
1309            // Decode unknown envelopes for gaps in ordinals.
1310            while _next_ordinal_to_read < 1 {
1311                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1312                _next_ordinal_to_read += 1;
1313                next_offset += envelope_size;
1314            }
1315
1316            let next_out_of_line = decoder.next_out_of_line();
1317            let handles_before = decoder.remaining_handles();
1318            if let Some((inlined, num_bytes, num_handles)) =
1319                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1320            {
1321                let member_inline_size =
1322                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1323                if inlined != (member_inline_size <= 4) {
1324                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1325                }
1326                let inner_offset;
1327                let mut inner_depth = depth.clone();
1328                if inlined {
1329                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1330                    inner_offset = next_offset;
1331                } else {
1332                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1333                    inner_depth.increment()?;
1334                }
1335                let val_ref = self.pointer_id.get_or_insert_with(|| fidl::new_empty!(u32, D));
1336                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1337                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1338                {
1339                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1340                }
1341                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1342                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1343                }
1344            }
1345
1346            next_offset += envelope_size;
1347            _next_ordinal_to_read += 1;
1348            if next_offset >= end_offset {
1349                return Ok(());
1350            }
1351
1352            // Decode unknown envelopes for gaps in ordinals.
1353            while _next_ordinal_to_read < 2 {
1354                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1355                _next_ordinal_to_read += 1;
1356                next_offset += envelope_size;
1357            }
1358
1359            let next_out_of_line = decoder.next_out_of_line();
1360            let handles_before = decoder.remaining_handles();
1361            if let Some((inlined, num_bytes, num_handles)) =
1362                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1363            {
1364                let member_inline_size =
1365                    <EventPhase as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1366                if inlined != (member_inline_size <= 4) {
1367                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1368                }
1369                let inner_offset;
1370                let mut inner_depth = depth.clone();
1371                if inlined {
1372                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1373                    inner_offset = next_offset;
1374                } else {
1375                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1376                    inner_depth.increment()?;
1377                }
1378                let val_ref = self.phase.get_or_insert_with(|| fidl::new_empty!(EventPhase, D));
1379                fidl::decode!(EventPhase, D, val_ref, decoder, inner_offset, inner_depth)?;
1380                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1381                {
1382                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1383                }
1384                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1385                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1386                }
1387            }
1388
1389            next_offset += envelope_size;
1390            _next_ordinal_to_read += 1;
1391            if next_offset >= end_offset {
1392                return Ok(());
1393            }
1394
1395            // Decode unknown envelopes for gaps in ordinals.
1396            while _next_ordinal_to_read < 3 {
1397                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1398                _next_ordinal_to_read += 1;
1399                next_offset += envelope_size;
1400            }
1401
1402            let next_out_of_line = decoder.next_out_of_line();
1403            let handles_before = decoder.remaining_handles();
1404            if let Some((inlined, num_bytes, num_handles)) =
1405                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1406            {
1407                let member_inline_size =
1408                    <fidl::encoding::Array<f32, 2> as fidl::encoding::TypeMarker>::inline_size(
1409                        decoder.context,
1410                    );
1411                if inlined != (member_inline_size <= 4) {
1412                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1413                }
1414                let inner_offset;
1415                let mut inner_depth = depth.clone();
1416                if inlined {
1417                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1418                    inner_offset = next_offset;
1419                } else {
1420                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1421                    inner_depth.increment()?;
1422                }
1423                let val_ref = self
1424                    .position_in_viewport
1425                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<f32, 2>, D));
1426                fidl::decode!(fidl::encoding::Array<f32, 2>, D, val_ref, decoder, inner_offset, inner_depth)?;
1427                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1428                {
1429                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1430                }
1431                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1432                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1433                }
1434            }
1435
1436            next_offset += envelope_size;
1437            _next_ordinal_to_read += 1;
1438            if next_offset >= end_offset {
1439                return Ok(());
1440            }
1441
1442            // Decode unknown envelopes for gaps in ordinals.
1443            while _next_ordinal_to_read < 4 {
1444                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1445                _next_ordinal_to_read += 1;
1446                next_offset += envelope_size;
1447            }
1448
1449            let next_out_of_line = decoder.next_out_of_line();
1450            let handles_before = decoder.remaining_handles();
1451            if let Some((inlined, num_bytes, num_handles)) =
1452                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1453            {
1454                let member_inline_size =
1455                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1456                if inlined != (member_inline_size <= 4) {
1457                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1458                }
1459                let inner_offset;
1460                let mut inner_depth = depth.clone();
1461                if inlined {
1462                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1463                    inner_offset = next_offset;
1464                } else {
1465                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1466                    inner_depth.increment()?;
1467                }
1468                let val_ref = self.scroll_v.get_or_insert_with(|| fidl::new_empty!(i64, D));
1469                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1470                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1471                {
1472                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1473                }
1474                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1475                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1476                }
1477            }
1478
1479            next_offset += envelope_size;
1480            _next_ordinal_to_read += 1;
1481            if next_offset >= end_offset {
1482                return Ok(());
1483            }
1484
1485            // Decode unknown envelopes for gaps in ordinals.
1486            while _next_ordinal_to_read < 5 {
1487                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1488                _next_ordinal_to_read += 1;
1489                next_offset += envelope_size;
1490            }
1491
1492            let next_out_of_line = decoder.next_out_of_line();
1493            let handles_before = decoder.remaining_handles();
1494            if let Some((inlined, num_bytes, num_handles)) =
1495                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1496            {
1497                let member_inline_size =
1498                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1499                if inlined != (member_inline_size <= 4) {
1500                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1501                }
1502                let inner_offset;
1503                let mut inner_depth = depth.clone();
1504                if inlined {
1505                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1506                    inner_offset = next_offset;
1507                } else {
1508                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1509                    inner_depth.increment()?;
1510                }
1511                let val_ref = self.scroll_h.get_or_insert_with(|| fidl::new_empty!(i64, D));
1512                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1513                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1514                {
1515                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1516                }
1517                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1518                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1519                }
1520            }
1521
1522            next_offset += envelope_size;
1523            _next_ordinal_to_read += 1;
1524            if next_offset >= end_offset {
1525                return Ok(());
1526            }
1527
1528            // Decode unknown envelopes for gaps in ordinals.
1529            while _next_ordinal_to_read < 6 {
1530                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1531                _next_ordinal_to_read += 1;
1532                next_offset += envelope_size;
1533            }
1534
1535            let next_out_of_line = decoder.next_out_of_line();
1536            let handles_before = decoder.remaining_handles();
1537            if let Some((inlined, num_bytes, num_handles)) =
1538                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1539            {
1540                let member_inline_size =
1541                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::TypeMarker>::inline_size(
1542                        decoder.context,
1543                    );
1544                if inlined != (member_inline_size <= 4) {
1545                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1546                }
1547                let inner_offset;
1548                let mut inner_depth = depth.clone();
1549                if inlined {
1550                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1551                    inner_offset = next_offset;
1552                } else {
1553                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1554                    inner_depth.increment()?;
1555                }
1556                let val_ref = self
1557                    .pressed_buttons
1558                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 32>, D));
1559                fidl::decode!(fidl::encoding::Vector<u8, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
1560                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1561                {
1562                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1563                }
1564                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1565                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1566                }
1567            }
1568
1569            next_offset += envelope_size;
1570            _next_ordinal_to_read += 1;
1571            if next_offset >= end_offset {
1572                return Ok(());
1573            }
1574
1575            // Decode unknown envelopes for gaps in ordinals.
1576            while _next_ordinal_to_read < 7 {
1577                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1578                _next_ordinal_to_read += 1;
1579                next_offset += envelope_size;
1580            }
1581
1582            let next_out_of_line = decoder.next_out_of_line();
1583            let handles_before = decoder.remaining_handles();
1584            if let Some((inlined, num_bytes, num_handles)) =
1585                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1586            {
1587                let member_inline_size =
1588                    <fidl::encoding::Array<f32, 2> as fidl::encoding::TypeMarker>::inline_size(
1589                        decoder.context,
1590                    );
1591                if inlined != (member_inline_size <= 4) {
1592                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1593                }
1594                let inner_offset;
1595                let mut inner_depth = depth.clone();
1596                if inlined {
1597                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1598                    inner_offset = next_offset;
1599                } else {
1600                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1601                    inner_depth.increment()?;
1602                }
1603                let val_ref = self
1604                    .relative_motion
1605                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<f32, 2>, D));
1606                fidl::decode!(fidl::encoding::Array<f32, 2>, D, val_ref, decoder, inner_offset, inner_depth)?;
1607                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1608                {
1609                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1610                }
1611                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1612                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1613                }
1614            }
1615
1616            next_offset += envelope_size;
1617            _next_ordinal_to_read += 1;
1618            if next_offset >= end_offset {
1619                return Ok(());
1620            }
1621
1622            // Decode unknown envelopes for gaps in ordinals.
1623            while _next_ordinal_to_read < 8 {
1624                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1625                _next_ordinal_to_read += 1;
1626                next_offset += envelope_size;
1627            }
1628
1629            let next_out_of_line = decoder.next_out_of_line();
1630            let handles_before = decoder.remaining_handles();
1631            if let Some((inlined, num_bytes, num_handles)) =
1632                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1633            {
1634                let member_inline_size =
1635                    <f64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1636                if inlined != (member_inline_size <= 4) {
1637                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1638                }
1639                let inner_offset;
1640                let mut inner_depth = depth.clone();
1641                if inlined {
1642                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1643                    inner_offset = next_offset;
1644                } else {
1645                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1646                    inner_depth.increment()?;
1647                }
1648                let val_ref =
1649                    self.scroll_v_physical_pixel.get_or_insert_with(|| fidl::new_empty!(f64, D));
1650                fidl::decode!(f64, D, val_ref, decoder, inner_offset, inner_depth)?;
1651                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1652                {
1653                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1654                }
1655                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1656                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1657                }
1658            }
1659
1660            next_offset += envelope_size;
1661            _next_ordinal_to_read += 1;
1662            if next_offset >= end_offset {
1663                return Ok(());
1664            }
1665
1666            // Decode unknown envelopes for gaps in ordinals.
1667            while _next_ordinal_to_read < 9 {
1668                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1669                _next_ordinal_to_read += 1;
1670                next_offset += envelope_size;
1671            }
1672
1673            let next_out_of_line = decoder.next_out_of_line();
1674            let handles_before = decoder.remaining_handles();
1675            if let Some((inlined, num_bytes, num_handles)) =
1676                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1677            {
1678                let member_inline_size =
1679                    <f64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1680                if inlined != (member_inline_size <= 4) {
1681                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1682                }
1683                let inner_offset;
1684                let mut inner_depth = depth.clone();
1685                if inlined {
1686                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1687                    inner_offset = next_offset;
1688                } else {
1689                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1690                    inner_depth.increment()?;
1691                }
1692                let val_ref =
1693                    self.scroll_h_physical_pixel.get_or_insert_with(|| fidl::new_empty!(f64, D));
1694                fidl::decode!(f64, D, val_ref, decoder, inner_offset, inner_depth)?;
1695                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1696                {
1697                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1698                }
1699                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1700                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1701                }
1702            }
1703
1704            next_offset += envelope_size;
1705            _next_ordinal_to_read += 1;
1706            if next_offset >= end_offset {
1707                return Ok(());
1708            }
1709
1710            // Decode unknown envelopes for gaps in ordinals.
1711            while _next_ordinal_to_read < 10 {
1712                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1713                _next_ordinal_to_read += 1;
1714                next_offset += envelope_size;
1715            }
1716
1717            let next_out_of_line = decoder.next_out_of_line();
1718            let handles_before = decoder.remaining_handles();
1719            if let Some((inlined, num_bytes, num_handles)) =
1720                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1721            {
1722                let member_inline_size =
1723                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1724                if inlined != (member_inline_size <= 4) {
1725                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1726                }
1727                let inner_offset;
1728                let mut inner_depth = depth.clone();
1729                if inlined {
1730                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1731                    inner_offset = next_offset;
1732                } else {
1733                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1734                    inner_depth.increment()?;
1735                }
1736                let val_ref =
1737                    self.is_precision_scroll.get_or_insert_with(|| fidl::new_empty!(bool, D));
1738                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1739                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1740                {
1741                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1742                }
1743                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1744                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1745                }
1746            }
1747
1748            next_offset += envelope_size;
1749
1750            // Decode the remaining unknown envelopes.
1751            while next_offset < end_offset {
1752                _next_ordinal_to_read += 1;
1753                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1754                next_offset += envelope_size;
1755            }
1756
1757            Ok(())
1758        }
1759    }
1760
1761    impl Viewport {
1762        #[inline(always)]
1763        fn max_ordinal_present(&self) -> u64 {
1764            if let Some(_) = self.viewport_to_context_transform {
1765                return 2;
1766            }
1767            if let Some(_) = self.extents {
1768                return 1;
1769            }
1770            0
1771        }
1772    }
1773
1774    impl fidl::encoding::ValueTypeMarker for Viewport {
1775        type Borrowed<'a> = &'a Self;
1776        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1777            value
1778        }
1779    }
1780
1781    unsafe impl fidl::encoding::TypeMarker for Viewport {
1782        type Owned = Self;
1783
1784        #[inline(always)]
1785        fn inline_align(_context: fidl::encoding::Context) -> usize {
1786            8
1787        }
1788
1789        #[inline(always)]
1790        fn inline_size(_context: fidl::encoding::Context) -> usize {
1791            16
1792        }
1793    }
1794
1795    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Viewport, D> for &Viewport {
1796        unsafe fn encode(
1797            self,
1798            encoder: &mut fidl::encoding::Encoder<'_, D>,
1799            offset: usize,
1800            mut depth: fidl::encoding::Depth,
1801        ) -> fidl::Result<()> {
1802            encoder.debug_check_bounds::<Viewport>(offset);
1803            // Vector header
1804            let max_ordinal: u64 = self.max_ordinal_present();
1805            encoder.write_num(max_ordinal, offset);
1806            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1807            // Calling encoder.out_of_line_offset(0) is not allowed.
1808            if max_ordinal == 0 {
1809                return Ok(());
1810            }
1811            depth.increment()?;
1812            let envelope_size = 8;
1813            let bytes_len = max_ordinal as usize * envelope_size;
1814            #[allow(unused_variables)]
1815            let offset = encoder.out_of_line_offset(bytes_len);
1816            let mut _prev_end_offset: usize = 0;
1817            if 1 > max_ordinal {
1818                return Ok(());
1819            }
1820
1821            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1822            // are envelope_size bytes.
1823            let cur_offset: usize = (1 - 1) * envelope_size;
1824
1825            // Zero reserved fields.
1826            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1827
1828            // Safety:
1829            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1830            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1831            //   envelope_size bytes, there is always sufficient room.
1832            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<fidl::encoding::Array<f32, 2>, 2>, D>(
1833            self.extents.as_ref().map(<fidl::encoding::Array<fidl::encoding::Array<f32, 2>, 2> as fidl::encoding::ValueTypeMarker>::borrow),
1834            encoder, offset + cur_offset, depth
1835        )?;
1836
1837            _prev_end_offset = cur_offset + envelope_size;
1838            if 2 > max_ordinal {
1839                return Ok(());
1840            }
1841
1842            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1843            // are envelope_size bytes.
1844            let cur_offset: usize = (2 - 1) * envelope_size;
1845
1846            // Zero reserved fields.
1847            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1848
1849            // Safety:
1850            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1851            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1852            //   envelope_size bytes, there is always sufficient room.
1853            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<f32, 9>, D>(
1854                self.viewport_to_context_transform.as_ref().map(
1855                    <fidl::encoding::Array<f32, 9> as fidl::encoding::ValueTypeMarker>::borrow,
1856                ),
1857                encoder,
1858                offset + cur_offset,
1859                depth,
1860            )?;
1861
1862            _prev_end_offset = cur_offset + envelope_size;
1863
1864            Ok(())
1865        }
1866    }
1867
1868    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Viewport {
1869        #[inline(always)]
1870        fn new_empty() -> Self {
1871            Self::default()
1872        }
1873
1874        unsafe fn decode(
1875            &mut self,
1876            decoder: &mut fidl::encoding::Decoder<'_, D>,
1877            offset: usize,
1878            mut depth: fidl::encoding::Depth,
1879        ) -> fidl::Result<()> {
1880            decoder.debug_check_bounds::<Self>(offset);
1881            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1882                None => return Err(fidl::Error::NotNullable),
1883                Some(len) => len,
1884            };
1885            // Calling decoder.out_of_line_offset(0) is not allowed.
1886            if len == 0 {
1887                return Ok(());
1888            };
1889            depth.increment()?;
1890            let envelope_size = 8;
1891            let bytes_len = len * envelope_size;
1892            let offset = decoder.out_of_line_offset(bytes_len)?;
1893            // Decode the envelope for each type.
1894            let mut _next_ordinal_to_read = 0;
1895            let mut next_offset = offset;
1896            let end_offset = offset + bytes_len;
1897            _next_ordinal_to_read += 1;
1898            if next_offset >= end_offset {
1899                return Ok(());
1900            }
1901
1902            // Decode unknown envelopes for gaps in ordinals.
1903            while _next_ordinal_to_read < 1 {
1904                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1905                _next_ordinal_to_read += 1;
1906                next_offset += envelope_size;
1907            }
1908
1909            let next_out_of_line = decoder.next_out_of_line();
1910            let handles_before = decoder.remaining_handles();
1911            if let Some((inlined, num_bytes, num_handles)) =
1912                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1913            {
1914                let member_inline_size = <fidl::encoding::Array<fidl::encoding::Array<f32, 2>, 2> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1915                if inlined != (member_inline_size <= 4) {
1916                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1917                }
1918                let inner_offset;
1919                let mut inner_depth = depth.clone();
1920                if inlined {
1921                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1922                    inner_offset = next_offset;
1923                } else {
1924                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1925                    inner_depth.increment()?;
1926                }
1927                let val_ref = self.extents.get_or_insert_with(|| {
1928                    fidl::new_empty!(fidl::encoding::Array<fidl::encoding::Array<f32, 2>, 2>, D)
1929                });
1930                fidl::decode!(
1931                    fidl::encoding::Array<fidl::encoding::Array<f32, 2>, 2>,
1932                    D,
1933                    val_ref,
1934                    decoder,
1935                    inner_offset,
1936                    inner_depth
1937                )?;
1938                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1939                {
1940                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1941                }
1942                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1943                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1944                }
1945            }
1946
1947            next_offset += envelope_size;
1948            _next_ordinal_to_read += 1;
1949            if next_offset >= end_offset {
1950                return Ok(());
1951            }
1952
1953            // Decode unknown envelopes for gaps in ordinals.
1954            while _next_ordinal_to_read < 2 {
1955                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1956                _next_ordinal_to_read += 1;
1957                next_offset += envelope_size;
1958            }
1959
1960            let next_out_of_line = decoder.next_out_of_line();
1961            let handles_before = decoder.remaining_handles();
1962            if let Some((inlined, num_bytes, num_handles)) =
1963                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1964            {
1965                let member_inline_size =
1966                    <fidl::encoding::Array<f32, 9> as fidl::encoding::TypeMarker>::inline_size(
1967                        decoder.context,
1968                    );
1969                if inlined != (member_inline_size <= 4) {
1970                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1971                }
1972                let inner_offset;
1973                let mut inner_depth = depth.clone();
1974                if inlined {
1975                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1976                    inner_offset = next_offset;
1977                } else {
1978                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1979                    inner_depth.increment()?;
1980                }
1981                let val_ref = self
1982                    .viewport_to_context_transform
1983                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<f32, 9>, D));
1984                fidl::decode!(fidl::encoding::Array<f32, 9>, D, val_ref, decoder, inner_offset, inner_depth)?;
1985                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1986                {
1987                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1988                }
1989                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1990                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1991                }
1992            }
1993
1994            next_offset += envelope_size;
1995
1996            // Decode the remaining unknown envelopes.
1997            while next_offset < end_offset {
1998                _next_ordinal_to_read += 1;
1999                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2000                next_offset += envelope_size;
2001            }
2002
2003            Ok(())
2004        }
2005    }
2006
2007    impl fidl::encoding::ValueTypeMarker for Data {
2008        type Borrowed<'a> = &'a Self;
2009        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2010            value
2011        }
2012    }
2013
2014    unsafe impl fidl::encoding::TypeMarker for Data {
2015        type Owned = Self;
2016
2017        #[inline(always)]
2018        fn inline_align(_context: fidl::encoding::Context) -> usize {
2019            8
2020        }
2021
2022        #[inline(always)]
2023        fn inline_size(_context: fidl::encoding::Context) -> usize {
2024            16
2025        }
2026    }
2027
2028    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Data, D> for &Data {
2029        #[inline]
2030        unsafe fn encode(
2031            self,
2032            encoder: &mut fidl::encoding::Encoder<'_, D>,
2033            offset: usize,
2034            _depth: fidl::encoding::Depth,
2035        ) -> fidl::Result<()> {
2036            encoder.debug_check_bounds::<Data>(offset);
2037            encoder.write_num::<u64>(self.ordinal(), offset);
2038            match self {
2039                Data::Viewport(ref val) => fidl::encoding::encode_in_envelope::<Viewport, D>(
2040                    <Viewport as fidl::encoding::ValueTypeMarker>::borrow(val),
2041                    encoder,
2042                    offset + 8,
2043                    _depth,
2044                ),
2045                Data::PointerSample(ref val) => {
2046                    fidl::encoding::encode_in_envelope::<PointerSample, D>(
2047                        <PointerSample as fidl::encoding::ValueTypeMarker>::borrow(val),
2048                        encoder,
2049                        offset + 8,
2050                        _depth,
2051                    )
2052                }
2053                Data::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2054            }
2055        }
2056    }
2057
2058    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Data {
2059        #[inline(always)]
2060        fn new_empty() -> Self {
2061            Self::__SourceBreaking { unknown_ordinal: 0 }
2062        }
2063
2064        #[inline]
2065        unsafe fn decode(
2066            &mut self,
2067            decoder: &mut fidl::encoding::Decoder<'_, D>,
2068            offset: usize,
2069            mut depth: fidl::encoding::Depth,
2070        ) -> fidl::Result<()> {
2071            decoder.debug_check_bounds::<Self>(offset);
2072            #[allow(unused_variables)]
2073            let next_out_of_line = decoder.next_out_of_line();
2074            let handles_before = decoder.remaining_handles();
2075            let (ordinal, inlined, num_bytes, num_handles) =
2076                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2077
2078            let member_inline_size = match ordinal {
2079                1 => <Viewport as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2080                2 => <PointerSample as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2081                0 => return Err(fidl::Error::UnknownUnionTag),
2082                _ => num_bytes as usize,
2083            };
2084
2085            if inlined != (member_inline_size <= 4) {
2086                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2087            }
2088            let _inner_offset;
2089            if inlined {
2090                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2091                _inner_offset = offset + 8;
2092            } else {
2093                depth.increment()?;
2094                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2095            }
2096            match ordinal {
2097                1 => {
2098                    #[allow(irrefutable_let_patterns)]
2099                    if let Data::Viewport(_) = self {
2100                        // Do nothing, read the value into the object
2101                    } else {
2102                        // Initialize `self` to the right variant
2103                        *self = Data::Viewport(fidl::new_empty!(Viewport, D));
2104                    }
2105                    #[allow(irrefutable_let_patterns)]
2106                    if let Data::Viewport(ref mut val) = self {
2107                        fidl::decode!(Viewport, D, val, decoder, _inner_offset, depth)?;
2108                    } else {
2109                        unreachable!()
2110                    }
2111                }
2112                2 => {
2113                    #[allow(irrefutable_let_patterns)]
2114                    if let Data::PointerSample(_) = self {
2115                        // Do nothing, read the value into the object
2116                    } else {
2117                        // Initialize `self` to the right variant
2118                        *self = Data::PointerSample(fidl::new_empty!(PointerSample, D));
2119                    }
2120                    #[allow(irrefutable_let_patterns)]
2121                    if let Data::PointerSample(ref mut val) = self {
2122                        fidl::decode!(PointerSample, D, val, decoder, _inner_offset, depth)?;
2123                    } else {
2124                        unreachable!()
2125                    }
2126                }
2127                #[allow(deprecated)]
2128                ordinal => {
2129                    for _ in 0..num_handles {
2130                        decoder.drop_next_handle()?;
2131                    }
2132                    *self = Data::__SourceBreaking { unknown_ordinal: ordinal };
2133                }
2134            }
2135            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2136                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2137            }
2138            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2139                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2140            }
2141            Ok(())
2142        }
2143    }
2144}