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
350mod internal {
351    use super::*;
352    unsafe impl fidl::encoding::TypeMarker for DeviceType {
353        type Owned = Self;
354
355        #[inline(always)]
356        fn inline_align(_context: fidl::encoding::Context) -> usize {
357            std::mem::align_of::<u32>()
358        }
359
360        #[inline(always)]
361        fn inline_size(_context: fidl::encoding::Context) -> usize {
362            std::mem::size_of::<u32>()
363        }
364
365        #[inline(always)]
366        fn encode_is_copy() -> bool {
367            true
368        }
369
370        #[inline(always)]
371        fn decode_is_copy() -> bool {
372            false
373        }
374    }
375
376    impl fidl::encoding::ValueTypeMarker for DeviceType {
377        type Borrowed<'a> = Self;
378        #[inline(always)]
379        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
380            *value
381        }
382    }
383
384    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DeviceType {
385        #[inline]
386        unsafe fn encode(
387            self,
388            encoder: &mut fidl::encoding::Encoder<'_, D>,
389            offset: usize,
390            _depth: fidl::encoding::Depth,
391        ) -> fidl::Result<()> {
392            encoder.debug_check_bounds::<Self>(offset);
393            encoder.write_num(self.into_primitive(), offset);
394            Ok(())
395        }
396    }
397
398    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceType {
399        #[inline(always)]
400        fn new_empty() -> Self {
401            Self::Touch
402        }
403
404        #[inline]
405        unsafe fn decode(
406            &mut self,
407            decoder: &mut fidl::encoding::Decoder<'_, D>,
408            offset: usize,
409            _depth: fidl::encoding::Depth,
410        ) -> fidl::Result<()> {
411            decoder.debug_check_bounds::<Self>(offset);
412            let prim = decoder.read_num::<u32>(offset);
413
414            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
415            Ok(())
416        }
417    }
418    unsafe impl fidl::encoding::TypeMarker for DispatchPolicy {
419        type Owned = Self;
420
421        #[inline(always)]
422        fn inline_align(_context: fidl::encoding::Context) -> usize {
423            std::mem::align_of::<u32>()
424        }
425
426        #[inline(always)]
427        fn inline_size(_context: fidl::encoding::Context) -> usize {
428            std::mem::size_of::<u32>()
429        }
430
431        #[inline(always)]
432        fn encode_is_copy() -> bool {
433            true
434        }
435
436        #[inline(always)]
437        fn decode_is_copy() -> bool {
438            false
439        }
440    }
441
442    impl fidl::encoding::ValueTypeMarker for DispatchPolicy {
443        type Borrowed<'a> = Self;
444        #[inline(always)]
445        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
446            *value
447        }
448    }
449
450    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DispatchPolicy {
451        #[inline]
452        unsafe fn encode(
453            self,
454            encoder: &mut fidl::encoding::Encoder<'_, D>,
455            offset: usize,
456            _depth: fidl::encoding::Depth,
457        ) -> fidl::Result<()> {
458            encoder.debug_check_bounds::<Self>(offset);
459            encoder.write_num(self.into_primitive(), offset);
460            Ok(())
461        }
462    }
463
464    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DispatchPolicy {
465        #[inline(always)]
466        fn new_empty() -> Self {
467            Self::ExclusiveTarget
468        }
469
470        #[inline]
471        unsafe fn decode(
472            &mut self,
473            decoder: &mut fidl::encoding::Decoder<'_, D>,
474            offset: usize,
475            _depth: fidl::encoding::Depth,
476        ) -> fidl::Result<()> {
477            decoder.debug_check_bounds::<Self>(offset);
478            let prim = decoder.read_num::<u32>(offset);
479
480            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
481            Ok(())
482        }
483    }
484    unsafe impl fidl::encoding::TypeMarker for EventPhase {
485        type Owned = Self;
486
487        #[inline(always)]
488        fn inline_align(_context: fidl::encoding::Context) -> usize {
489            std::mem::align_of::<u32>()
490        }
491
492        #[inline(always)]
493        fn inline_size(_context: fidl::encoding::Context) -> usize {
494            std::mem::size_of::<u32>()
495        }
496
497        #[inline(always)]
498        fn encode_is_copy() -> bool {
499            true
500        }
501
502        #[inline(always)]
503        fn decode_is_copy() -> bool {
504            false
505        }
506    }
507
508    impl fidl::encoding::ValueTypeMarker for EventPhase {
509        type Borrowed<'a> = Self;
510        #[inline(always)]
511        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
512            *value
513        }
514    }
515
516    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for EventPhase {
517        #[inline]
518        unsafe fn encode(
519            self,
520            encoder: &mut fidl::encoding::Encoder<'_, D>,
521            offset: usize,
522            _depth: fidl::encoding::Depth,
523        ) -> fidl::Result<()> {
524            encoder.debug_check_bounds::<Self>(offset);
525            encoder.write_num(self.into_primitive(), offset);
526            Ok(())
527        }
528    }
529
530    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EventPhase {
531        #[inline(always)]
532        fn new_empty() -> Self {
533            Self::Add
534        }
535
536        #[inline]
537        unsafe fn decode(
538            &mut self,
539            decoder: &mut fidl::encoding::Decoder<'_, D>,
540            offset: usize,
541            _depth: fidl::encoding::Depth,
542        ) -> fidl::Result<()> {
543            decoder.debug_check_bounds::<Self>(offset);
544            let prim = decoder.read_num::<u32>(offset);
545
546            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
547            Ok(())
548        }
549    }
550
551    impl fidl::encoding::ValueTypeMarker for DeviceInjectRequest {
552        type Borrowed<'a> = &'a Self;
553        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
554            value
555        }
556    }
557
558    unsafe impl fidl::encoding::TypeMarker for DeviceInjectRequest {
559        type Owned = Self;
560
561        #[inline(always)]
562        fn inline_align(_context: fidl::encoding::Context) -> usize {
563            8
564        }
565
566        #[inline(always)]
567        fn inline_size(_context: fidl::encoding::Context) -> usize {
568            16
569        }
570    }
571
572    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceInjectRequest, D>
573        for &DeviceInjectRequest
574    {
575        #[inline]
576        unsafe fn encode(
577            self,
578            encoder: &mut fidl::encoding::Encoder<'_, D>,
579            offset: usize,
580            _depth: fidl::encoding::Depth,
581        ) -> fidl::Result<()> {
582            encoder.debug_check_bounds::<DeviceInjectRequest>(offset);
583            // Delegate to tuple encoding.
584            fidl::encoding::Encode::<DeviceInjectRequest, D>::encode(
585                (<fidl::encoding::Vector<Event, 128> as fidl::encoding::ValueTypeMarker>::borrow(
586                    &self.events,
587                ),),
588                encoder,
589                offset,
590                _depth,
591            )
592        }
593    }
594    unsafe impl<
595            D: fidl::encoding::ResourceDialect,
596            T0: fidl::encoding::Encode<fidl::encoding::Vector<Event, 128>, D>,
597        > fidl::encoding::Encode<DeviceInjectRequest, D> for (T0,)
598    {
599        #[inline]
600        unsafe fn encode(
601            self,
602            encoder: &mut fidl::encoding::Encoder<'_, D>,
603            offset: usize,
604            depth: fidl::encoding::Depth,
605        ) -> fidl::Result<()> {
606            encoder.debug_check_bounds::<DeviceInjectRequest>(offset);
607            // Zero out padding regions. There's no need to apply masks
608            // because the unmasked parts will be overwritten by fields.
609            // Write the fields.
610            self.0.encode(encoder, offset + 0, depth)?;
611            Ok(())
612        }
613    }
614
615    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceInjectRequest {
616        #[inline(always)]
617        fn new_empty() -> Self {
618            Self { events: fidl::new_empty!(fidl::encoding::Vector<Event, 128>, D) }
619        }
620
621        #[inline]
622        unsafe fn decode(
623            &mut self,
624            decoder: &mut fidl::encoding::Decoder<'_, D>,
625            offset: usize,
626            _depth: fidl::encoding::Depth,
627        ) -> fidl::Result<()> {
628            decoder.debug_check_bounds::<Self>(offset);
629            // Verify that padding bytes are zero.
630            fidl::decode!(fidl::encoding::Vector<Event, 128>, D, &mut self.events, decoder, offset + 0, _depth)?;
631            Ok(())
632        }
633    }
634
635    impl Event {
636        #[inline(always)]
637        fn max_ordinal_present(&self) -> u64 {
638            if let Some(_) = self.trace_flow_id {
639                return 3;
640            }
641            if let Some(_) = self.data {
642                return 2;
643            }
644            if let Some(_) = self.timestamp {
645                return 1;
646            }
647            0
648        }
649    }
650
651    impl fidl::encoding::ValueTypeMarker for Event {
652        type Borrowed<'a> = &'a Self;
653        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
654            value
655        }
656    }
657
658    unsafe impl fidl::encoding::TypeMarker for Event {
659        type Owned = Self;
660
661        #[inline(always)]
662        fn inline_align(_context: fidl::encoding::Context) -> usize {
663            8
664        }
665
666        #[inline(always)]
667        fn inline_size(_context: fidl::encoding::Context) -> usize {
668            16
669        }
670    }
671
672    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Event, D> for &Event {
673        unsafe fn encode(
674            self,
675            encoder: &mut fidl::encoding::Encoder<'_, D>,
676            offset: usize,
677            mut depth: fidl::encoding::Depth,
678        ) -> fidl::Result<()> {
679            encoder.debug_check_bounds::<Event>(offset);
680            // Vector header
681            let max_ordinal: u64 = self.max_ordinal_present();
682            encoder.write_num(max_ordinal, offset);
683            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
684            // Calling encoder.out_of_line_offset(0) is not allowed.
685            if max_ordinal == 0 {
686                return Ok(());
687            }
688            depth.increment()?;
689            let envelope_size = 8;
690            let bytes_len = max_ordinal as usize * envelope_size;
691            #[allow(unused_variables)]
692            let offset = encoder.out_of_line_offset(bytes_len);
693            let mut _prev_end_offset: usize = 0;
694            if 1 > max_ordinal {
695                return Ok(());
696            }
697
698            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
699            // are envelope_size bytes.
700            let cur_offset: usize = (1 - 1) * envelope_size;
701
702            // Zero reserved fields.
703            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
704
705            // Safety:
706            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
707            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
708            //   envelope_size bytes, there is always sufficient room.
709            fidl::encoding::encode_in_envelope_optional::<i64, D>(
710                self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
711                encoder,
712                offset + cur_offset,
713                depth,
714            )?;
715
716            _prev_end_offset = cur_offset + envelope_size;
717            if 2 > max_ordinal {
718                return Ok(());
719            }
720
721            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
722            // are envelope_size bytes.
723            let cur_offset: usize = (2 - 1) * envelope_size;
724
725            // Zero reserved fields.
726            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
727
728            // Safety:
729            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
730            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
731            //   envelope_size bytes, there is always sufficient room.
732            fidl::encoding::encode_in_envelope_optional::<Data, D>(
733                self.data.as_ref().map(<Data as fidl::encoding::ValueTypeMarker>::borrow),
734                encoder,
735                offset + cur_offset,
736                depth,
737            )?;
738
739            _prev_end_offset = cur_offset + envelope_size;
740            if 3 > max_ordinal {
741                return Ok(());
742            }
743
744            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
745            // are envelope_size bytes.
746            let cur_offset: usize = (3 - 1) * envelope_size;
747
748            // Zero reserved fields.
749            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
750
751            // Safety:
752            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
753            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
754            //   envelope_size bytes, there is always sufficient room.
755            fidl::encoding::encode_in_envelope_optional::<u64, D>(
756                self.trace_flow_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
757                encoder,
758                offset + cur_offset,
759                depth,
760            )?;
761
762            _prev_end_offset = cur_offset + envelope_size;
763
764            Ok(())
765        }
766    }
767
768    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Event {
769        #[inline(always)]
770        fn new_empty() -> Self {
771            Self::default()
772        }
773
774        unsafe fn decode(
775            &mut self,
776            decoder: &mut fidl::encoding::Decoder<'_, D>,
777            offset: usize,
778            mut depth: fidl::encoding::Depth,
779        ) -> fidl::Result<()> {
780            decoder.debug_check_bounds::<Self>(offset);
781            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
782                None => return Err(fidl::Error::NotNullable),
783                Some(len) => len,
784            };
785            // Calling decoder.out_of_line_offset(0) is not allowed.
786            if len == 0 {
787                return Ok(());
788            };
789            depth.increment()?;
790            let envelope_size = 8;
791            let bytes_len = len * envelope_size;
792            let offset = decoder.out_of_line_offset(bytes_len)?;
793            // Decode the envelope for each type.
794            let mut _next_ordinal_to_read = 0;
795            let mut next_offset = offset;
796            let end_offset = offset + bytes_len;
797            _next_ordinal_to_read += 1;
798            if next_offset >= end_offset {
799                return Ok(());
800            }
801
802            // Decode unknown envelopes for gaps in ordinals.
803            while _next_ordinal_to_read < 1 {
804                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
805                _next_ordinal_to_read += 1;
806                next_offset += envelope_size;
807            }
808
809            let next_out_of_line = decoder.next_out_of_line();
810            let handles_before = decoder.remaining_handles();
811            if let Some((inlined, num_bytes, num_handles)) =
812                fidl::encoding::decode_envelope_header(decoder, next_offset)?
813            {
814                let member_inline_size =
815                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
816                if inlined != (member_inline_size <= 4) {
817                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
818                }
819                let inner_offset;
820                let mut inner_depth = depth.clone();
821                if inlined {
822                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
823                    inner_offset = next_offset;
824                } else {
825                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
826                    inner_depth.increment()?;
827                }
828                let val_ref = self.timestamp.get_or_insert_with(|| fidl::new_empty!(i64, D));
829                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
830                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
831                {
832                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
833                }
834                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
835                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
836                }
837            }
838
839            next_offset += envelope_size;
840            _next_ordinal_to_read += 1;
841            if next_offset >= end_offset {
842                return Ok(());
843            }
844
845            // Decode unknown envelopes for gaps in ordinals.
846            while _next_ordinal_to_read < 2 {
847                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
848                _next_ordinal_to_read += 1;
849                next_offset += envelope_size;
850            }
851
852            let next_out_of_line = decoder.next_out_of_line();
853            let handles_before = decoder.remaining_handles();
854            if let Some((inlined, num_bytes, num_handles)) =
855                fidl::encoding::decode_envelope_header(decoder, next_offset)?
856            {
857                let member_inline_size =
858                    <Data as fidl::encoding::TypeMarker>::inline_size(decoder.context);
859                if inlined != (member_inline_size <= 4) {
860                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
861                }
862                let inner_offset;
863                let mut inner_depth = depth.clone();
864                if inlined {
865                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
866                    inner_offset = next_offset;
867                } else {
868                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
869                    inner_depth.increment()?;
870                }
871                let val_ref = self.data.get_or_insert_with(|| fidl::new_empty!(Data, D));
872                fidl::decode!(Data, D, val_ref, decoder, inner_offset, inner_depth)?;
873                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
874                {
875                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
876                }
877                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
878                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
879                }
880            }
881
882            next_offset += envelope_size;
883            _next_ordinal_to_read += 1;
884            if next_offset >= end_offset {
885                return Ok(());
886            }
887
888            // Decode unknown envelopes for gaps in ordinals.
889            while _next_ordinal_to_read < 3 {
890                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
891                _next_ordinal_to_read += 1;
892                next_offset += envelope_size;
893            }
894
895            let next_out_of_line = decoder.next_out_of_line();
896            let handles_before = decoder.remaining_handles();
897            if let Some((inlined, num_bytes, num_handles)) =
898                fidl::encoding::decode_envelope_header(decoder, next_offset)?
899            {
900                let member_inline_size =
901                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
902                if inlined != (member_inline_size <= 4) {
903                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
904                }
905                let inner_offset;
906                let mut inner_depth = depth.clone();
907                if inlined {
908                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
909                    inner_offset = next_offset;
910                } else {
911                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
912                    inner_depth.increment()?;
913                }
914                let val_ref = self.trace_flow_id.get_or_insert_with(|| fidl::new_empty!(u64, D));
915                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
916                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
917                {
918                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
919                }
920                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
921                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
922                }
923            }
924
925            next_offset += envelope_size;
926
927            // Decode the remaining unknown envelopes.
928            while next_offset < end_offset {
929                _next_ordinal_to_read += 1;
930                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
931                next_offset += envelope_size;
932            }
933
934            Ok(())
935        }
936    }
937
938    impl PointerSample {
939        #[inline(always)]
940        fn max_ordinal_present(&self) -> u64 {
941            if let Some(_) = self.is_precision_scroll {
942                return 10;
943            }
944            if let Some(_) = self.scroll_h_physical_pixel {
945                return 9;
946            }
947            if let Some(_) = self.scroll_v_physical_pixel {
948                return 8;
949            }
950            if let Some(_) = self.relative_motion {
951                return 7;
952            }
953            if let Some(_) = self.pressed_buttons {
954                return 6;
955            }
956            if let Some(_) = self.scroll_h {
957                return 5;
958            }
959            if let Some(_) = self.scroll_v {
960                return 4;
961            }
962            if let Some(_) = self.position_in_viewport {
963                return 3;
964            }
965            if let Some(_) = self.phase {
966                return 2;
967            }
968            if let Some(_) = self.pointer_id {
969                return 1;
970            }
971            0
972        }
973    }
974
975    impl fidl::encoding::ValueTypeMarker for PointerSample {
976        type Borrowed<'a> = &'a Self;
977        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
978            value
979        }
980    }
981
982    unsafe impl fidl::encoding::TypeMarker for PointerSample {
983        type Owned = Self;
984
985        #[inline(always)]
986        fn inline_align(_context: fidl::encoding::Context) -> usize {
987            8
988        }
989
990        #[inline(always)]
991        fn inline_size(_context: fidl::encoding::Context) -> usize {
992            16
993        }
994    }
995
996    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PointerSample, D>
997        for &PointerSample
998    {
999        unsafe fn encode(
1000            self,
1001            encoder: &mut fidl::encoding::Encoder<'_, D>,
1002            offset: usize,
1003            mut depth: fidl::encoding::Depth,
1004        ) -> fidl::Result<()> {
1005            encoder.debug_check_bounds::<PointerSample>(offset);
1006            // Vector header
1007            let max_ordinal: u64 = self.max_ordinal_present();
1008            encoder.write_num(max_ordinal, offset);
1009            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1010            // Calling encoder.out_of_line_offset(0) is not allowed.
1011            if max_ordinal == 0 {
1012                return Ok(());
1013            }
1014            depth.increment()?;
1015            let envelope_size = 8;
1016            let bytes_len = max_ordinal as usize * envelope_size;
1017            #[allow(unused_variables)]
1018            let offset = encoder.out_of_line_offset(bytes_len);
1019            let mut _prev_end_offset: usize = 0;
1020            if 1 > max_ordinal {
1021                return Ok(());
1022            }
1023
1024            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1025            // are envelope_size bytes.
1026            let cur_offset: usize = (1 - 1) * envelope_size;
1027
1028            // Zero reserved fields.
1029            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1030
1031            // Safety:
1032            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1033            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1034            //   envelope_size bytes, there is always sufficient room.
1035            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1036                self.pointer_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1037                encoder,
1038                offset + cur_offset,
1039                depth,
1040            )?;
1041
1042            _prev_end_offset = cur_offset + envelope_size;
1043            if 2 > max_ordinal {
1044                return Ok(());
1045            }
1046
1047            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1048            // are envelope_size bytes.
1049            let cur_offset: usize = (2 - 1) * envelope_size;
1050
1051            // Zero reserved fields.
1052            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1053
1054            // Safety:
1055            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1056            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1057            //   envelope_size bytes, there is always sufficient room.
1058            fidl::encoding::encode_in_envelope_optional::<EventPhase, D>(
1059                self.phase.as_ref().map(<EventPhase as fidl::encoding::ValueTypeMarker>::borrow),
1060                encoder,
1061                offset + cur_offset,
1062                depth,
1063            )?;
1064
1065            _prev_end_offset = cur_offset + envelope_size;
1066            if 3 > max_ordinal {
1067                return Ok(());
1068            }
1069
1070            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1071            // are envelope_size bytes.
1072            let cur_offset: usize = (3 - 1) * envelope_size;
1073
1074            // Zero reserved fields.
1075            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1076
1077            // Safety:
1078            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1079            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1080            //   envelope_size bytes, there is always sufficient room.
1081            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<f32, 2>, D>(
1082                self.position_in_viewport.as_ref().map(
1083                    <fidl::encoding::Array<f32, 2> as fidl::encoding::ValueTypeMarker>::borrow,
1084                ),
1085                encoder,
1086                offset + cur_offset,
1087                depth,
1088            )?;
1089
1090            _prev_end_offset = cur_offset + envelope_size;
1091            if 4 > max_ordinal {
1092                return Ok(());
1093            }
1094
1095            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1096            // are envelope_size bytes.
1097            let cur_offset: usize = (4 - 1) * envelope_size;
1098
1099            // Zero reserved fields.
1100            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1101
1102            // Safety:
1103            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1104            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1105            //   envelope_size bytes, there is always sufficient room.
1106            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1107                self.scroll_v.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1108                encoder,
1109                offset + cur_offset,
1110                depth,
1111            )?;
1112
1113            _prev_end_offset = cur_offset + envelope_size;
1114            if 5 > max_ordinal {
1115                return Ok(());
1116            }
1117
1118            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1119            // are envelope_size bytes.
1120            let cur_offset: usize = (5 - 1) * envelope_size;
1121
1122            // Zero reserved fields.
1123            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1124
1125            // Safety:
1126            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1127            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1128            //   envelope_size bytes, there is always sufficient room.
1129            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1130                self.scroll_h.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1131                encoder,
1132                offset + cur_offset,
1133                depth,
1134            )?;
1135
1136            _prev_end_offset = cur_offset + envelope_size;
1137            if 6 > max_ordinal {
1138                return Ok(());
1139            }
1140
1141            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1142            // are envelope_size bytes.
1143            let cur_offset: usize = (6 - 1) * envelope_size;
1144
1145            // Zero reserved fields.
1146            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1147
1148            // Safety:
1149            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1150            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1151            //   envelope_size bytes, there is always sufficient room.
1152            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 32>, D>(
1153                self.pressed_buttons.as_ref().map(
1154                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow,
1155                ),
1156                encoder,
1157                offset + cur_offset,
1158                depth,
1159            )?;
1160
1161            _prev_end_offset = cur_offset + envelope_size;
1162            if 7 > max_ordinal {
1163                return Ok(());
1164            }
1165
1166            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1167            // are envelope_size bytes.
1168            let cur_offset: usize = (7 - 1) * envelope_size;
1169
1170            // Zero reserved fields.
1171            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1172
1173            // Safety:
1174            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1175            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1176            //   envelope_size bytes, there is always sufficient room.
1177            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<f32, 2>, D>(
1178                self.relative_motion.as_ref().map(
1179                    <fidl::encoding::Array<f32, 2> as fidl::encoding::ValueTypeMarker>::borrow,
1180                ),
1181                encoder,
1182                offset + cur_offset,
1183                depth,
1184            )?;
1185
1186            _prev_end_offset = cur_offset + envelope_size;
1187            if 8 > max_ordinal {
1188                return Ok(());
1189            }
1190
1191            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1192            // are envelope_size bytes.
1193            let cur_offset: usize = (8 - 1) * envelope_size;
1194
1195            // Zero reserved fields.
1196            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1197
1198            // Safety:
1199            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1200            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1201            //   envelope_size bytes, there is always sufficient room.
1202            fidl::encoding::encode_in_envelope_optional::<f64, D>(
1203                self.scroll_v_physical_pixel
1204                    .as_ref()
1205                    .map(<f64 as fidl::encoding::ValueTypeMarker>::borrow),
1206                encoder,
1207                offset + cur_offset,
1208                depth,
1209            )?;
1210
1211            _prev_end_offset = cur_offset + envelope_size;
1212            if 9 > max_ordinal {
1213                return Ok(());
1214            }
1215
1216            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1217            // are envelope_size bytes.
1218            let cur_offset: usize = (9 - 1) * envelope_size;
1219
1220            // Zero reserved fields.
1221            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1222
1223            // Safety:
1224            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1225            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1226            //   envelope_size bytes, there is always sufficient room.
1227            fidl::encoding::encode_in_envelope_optional::<f64, D>(
1228                self.scroll_h_physical_pixel
1229                    .as_ref()
1230                    .map(<f64 as fidl::encoding::ValueTypeMarker>::borrow),
1231                encoder,
1232                offset + cur_offset,
1233                depth,
1234            )?;
1235
1236            _prev_end_offset = cur_offset + envelope_size;
1237            if 10 > max_ordinal {
1238                return Ok(());
1239            }
1240
1241            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1242            // are envelope_size bytes.
1243            let cur_offset: usize = (10 - 1) * envelope_size;
1244
1245            // Zero reserved fields.
1246            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1247
1248            // Safety:
1249            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1250            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1251            //   envelope_size bytes, there is always sufficient room.
1252            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1253                self.is_precision_scroll
1254                    .as_ref()
1255                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1256                encoder,
1257                offset + cur_offset,
1258                depth,
1259            )?;
1260
1261            _prev_end_offset = cur_offset + envelope_size;
1262
1263            Ok(())
1264        }
1265    }
1266
1267    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PointerSample {
1268        #[inline(always)]
1269        fn new_empty() -> Self {
1270            Self::default()
1271        }
1272
1273        unsafe fn decode(
1274            &mut self,
1275            decoder: &mut fidl::encoding::Decoder<'_, D>,
1276            offset: usize,
1277            mut depth: fidl::encoding::Depth,
1278        ) -> fidl::Result<()> {
1279            decoder.debug_check_bounds::<Self>(offset);
1280            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1281                None => return Err(fidl::Error::NotNullable),
1282                Some(len) => len,
1283            };
1284            // Calling decoder.out_of_line_offset(0) is not allowed.
1285            if len == 0 {
1286                return Ok(());
1287            };
1288            depth.increment()?;
1289            let envelope_size = 8;
1290            let bytes_len = len * envelope_size;
1291            let offset = decoder.out_of_line_offset(bytes_len)?;
1292            // Decode the envelope for each type.
1293            let mut _next_ordinal_to_read = 0;
1294            let mut next_offset = offset;
1295            let end_offset = offset + bytes_len;
1296            _next_ordinal_to_read += 1;
1297            if next_offset >= end_offset {
1298                return Ok(());
1299            }
1300
1301            // Decode unknown envelopes for gaps in ordinals.
1302            while _next_ordinal_to_read < 1 {
1303                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1304                _next_ordinal_to_read += 1;
1305                next_offset += envelope_size;
1306            }
1307
1308            let next_out_of_line = decoder.next_out_of_line();
1309            let handles_before = decoder.remaining_handles();
1310            if let Some((inlined, num_bytes, num_handles)) =
1311                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1312            {
1313                let member_inline_size =
1314                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1315                if inlined != (member_inline_size <= 4) {
1316                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1317                }
1318                let inner_offset;
1319                let mut inner_depth = depth.clone();
1320                if inlined {
1321                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1322                    inner_offset = next_offset;
1323                } else {
1324                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1325                    inner_depth.increment()?;
1326                }
1327                let val_ref = self.pointer_id.get_or_insert_with(|| fidl::new_empty!(u32, D));
1328                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1329                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1330                {
1331                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1332                }
1333                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1334                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1335                }
1336            }
1337
1338            next_offset += envelope_size;
1339            _next_ordinal_to_read += 1;
1340            if next_offset >= end_offset {
1341                return Ok(());
1342            }
1343
1344            // Decode unknown envelopes for gaps in ordinals.
1345            while _next_ordinal_to_read < 2 {
1346                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1347                _next_ordinal_to_read += 1;
1348                next_offset += envelope_size;
1349            }
1350
1351            let next_out_of_line = decoder.next_out_of_line();
1352            let handles_before = decoder.remaining_handles();
1353            if let Some((inlined, num_bytes, num_handles)) =
1354                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1355            {
1356                let member_inline_size =
1357                    <EventPhase as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1358                if inlined != (member_inline_size <= 4) {
1359                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1360                }
1361                let inner_offset;
1362                let mut inner_depth = depth.clone();
1363                if inlined {
1364                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1365                    inner_offset = next_offset;
1366                } else {
1367                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1368                    inner_depth.increment()?;
1369                }
1370                let val_ref = self.phase.get_or_insert_with(|| fidl::new_empty!(EventPhase, D));
1371                fidl::decode!(EventPhase, D, val_ref, decoder, inner_offset, inner_depth)?;
1372                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1373                {
1374                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1375                }
1376                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1377                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1378                }
1379            }
1380
1381            next_offset += envelope_size;
1382            _next_ordinal_to_read += 1;
1383            if next_offset >= end_offset {
1384                return Ok(());
1385            }
1386
1387            // Decode unknown envelopes for gaps in ordinals.
1388            while _next_ordinal_to_read < 3 {
1389                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1390                _next_ordinal_to_read += 1;
1391                next_offset += envelope_size;
1392            }
1393
1394            let next_out_of_line = decoder.next_out_of_line();
1395            let handles_before = decoder.remaining_handles();
1396            if let Some((inlined, num_bytes, num_handles)) =
1397                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1398            {
1399                let member_inline_size =
1400                    <fidl::encoding::Array<f32, 2> as fidl::encoding::TypeMarker>::inline_size(
1401                        decoder.context,
1402                    );
1403                if inlined != (member_inline_size <= 4) {
1404                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1405                }
1406                let inner_offset;
1407                let mut inner_depth = depth.clone();
1408                if inlined {
1409                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1410                    inner_offset = next_offset;
1411                } else {
1412                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1413                    inner_depth.increment()?;
1414                }
1415                let val_ref = self
1416                    .position_in_viewport
1417                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<f32, 2>, D));
1418                fidl::decode!(fidl::encoding::Array<f32, 2>, D, val_ref, decoder, inner_offset, inner_depth)?;
1419                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1420                {
1421                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1422                }
1423                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1424                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1425                }
1426            }
1427
1428            next_offset += envelope_size;
1429            _next_ordinal_to_read += 1;
1430            if next_offset >= end_offset {
1431                return Ok(());
1432            }
1433
1434            // Decode unknown envelopes for gaps in ordinals.
1435            while _next_ordinal_to_read < 4 {
1436                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1437                _next_ordinal_to_read += 1;
1438                next_offset += envelope_size;
1439            }
1440
1441            let next_out_of_line = decoder.next_out_of_line();
1442            let handles_before = decoder.remaining_handles();
1443            if let Some((inlined, num_bytes, num_handles)) =
1444                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1445            {
1446                let member_inline_size =
1447                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1448                if inlined != (member_inline_size <= 4) {
1449                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1450                }
1451                let inner_offset;
1452                let mut inner_depth = depth.clone();
1453                if inlined {
1454                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1455                    inner_offset = next_offset;
1456                } else {
1457                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1458                    inner_depth.increment()?;
1459                }
1460                let val_ref = self.scroll_v.get_or_insert_with(|| fidl::new_empty!(i64, D));
1461                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1462                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1463                {
1464                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1465                }
1466                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1467                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1468                }
1469            }
1470
1471            next_offset += envelope_size;
1472            _next_ordinal_to_read += 1;
1473            if next_offset >= end_offset {
1474                return Ok(());
1475            }
1476
1477            // Decode unknown envelopes for gaps in ordinals.
1478            while _next_ordinal_to_read < 5 {
1479                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1480                _next_ordinal_to_read += 1;
1481                next_offset += envelope_size;
1482            }
1483
1484            let next_out_of_line = decoder.next_out_of_line();
1485            let handles_before = decoder.remaining_handles();
1486            if let Some((inlined, num_bytes, num_handles)) =
1487                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1488            {
1489                let member_inline_size =
1490                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1491                if inlined != (member_inline_size <= 4) {
1492                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1493                }
1494                let inner_offset;
1495                let mut inner_depth = depth.clone();
1496                if inlined {
1497                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1498                    inner_offset = next_offset;
1499                } else {
1500                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1501                    inner_depth.increment()?;
1502                }
1503                let val_ref = self.scroll_h.get_or_insert_with(|| fidl::new_empty!(i64, D));
1504                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1505                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1506                {
1507                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1508                }
1509                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1510                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1511                }
1512            }
1513
1514            next_offset += envelope_size;
1515            _next_ordinal_to_read += 1;
1516            if next_offset >= end_offset {
1517                return Ok(());
1518            }
1519
1520            // Decode unknown envelopes for gaps in ordinals.
1521            while _next_ordinal_to_read < 6 {
1522                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1523                _next_ordinal_to_read += 1;
1524                next_offset += envelope_size;
1525            }
1526
1527            let next_out_of_line = decoder.next_out_of_line();
1528            let handles_before = decoder.remaining_handles();
1529            if let Some((inlined, num_bytes, num_handles)) =
1530                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1531            {
1532                let member_inline_size =
1533                    <fidl::encoding::Vector<u8, 32> as fidl::encoding::TypeMarker>::inline_size(
1534                        decoder.context,
1535                    );
1536                if inlined != (member_inline_size <= 4) {
1537                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1538                }
1539                let inner_offset;
1540                let mut inner_depth = depth.clone();
1541                if inlined {
1542                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1543                    inner_offset = next_offset;
1544                } else {
1545                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1546                    inner_depth.increment()?;
1547                }
1548                let val_ref = self
1549                    .pressed_buttons
1550                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 32>, D));
1551                fidl::decode!(fidl::encoding::Vector<u8, 32>, D, val_ref, decoder, inner_offset, inner_depth)?;
1552                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1553                {
1554                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1555                }
1556                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1557                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1558                }
1559            }
1560
1561            next_offset += envelope_size;
1562            _next_ordinal_to_read += 1;
1563            if next_offset >= end_offset {
1564                return Ok(());
1565            }
1566
1567            // Decode unknown envelopes for gaps in ordinals.
1568            while _next_ordinal_to_read < 7 {
1569                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1570                _next_ordinal_to_read += 1;
1571                next_offset += envelope_size;
1572            }
1573
1574            let next_out_of_line = decoder.next_out_of_line();
1575            let handles_before = decoder.remaining_handles();
1576            if let Some((inlined, num_bytes, num_handles)) =
1577                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1578            {
1579                let member_inline_size =
1580                    <fidl::encoding::Array<f32, 2> as fidl::encoding::TypeMarker>::inline_size(
1581                        decoder.context,
1582                    );
1583                if inlined != (member_inline_size <= 4) {
1584                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1585                }
1586                let inner_offset;
1587                let mut inner_depth = depth.clone();
1588                if inlined {
1589                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1590                    inner_offset = next_offset;
1591                } else {
1592                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1593                    inner_depth.increment()?;
1594                }
1595                let val_ref = self
1596                    .relative_motion
1597                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<f32, 2>, D));
1598                fidl::decode!(fidl::encoding::Array<f32, 2>, D, val_ref, decoder, inner_offset, inner_depth)?;
1599                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1600                {
1601                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1602                }
1603                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1604                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1605                }
1606            }
1607
1608            next_offset += envelope_size;
1609            _next_ordinal_to_read += 1;
1610            if next_offset >= end_offset {
1611                return Ok(());
1612            }
1613
1614            // Decode unknown envelopes for gaps in ordinals.
1615            while _next_ordinal_to_read < 8 {
1616                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1617                _next_ordinal_to_read += 1;
1618                next_offset += envelope_size;
1619            }
1620
1621            let next_out_of_line = decoder.next_out_of_line();
1622            let handles_before = decoder.remaining_handles();
1623            if let Some((inlined, num_bytes, num_handles)) =
1624                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1625            {
1626                let member_inline_size =
1627                    <f64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1628                if inlined != (member_inline_size <= 4) {
1629                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1630                }
1631                let inner_offset;
1632                let mut inner_depth = depth.clone();
1633                if inlined {
1634                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1635                    inner_offset = next_offset;
1636                } else {
1637                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1638                    inner_depth.increment()?;
1639                }
1640                let val_ref =
1641                    self.scroll_v_physical_pixel.get_or_insert_with(|| fidl::new_empty!(f64, D));
1642                fidl::decode!(f64, D, val_ref, decoder, inner_offset, inner_depth)?;
1643                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1644                {
1645                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1646                }
1647                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1648                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1649                }
1650            }
1651
1652            next_offset += envelope_size;
1653            _next_ordinal_to_read += 1;
1654            if next_offset >= end_offset {
1655                return Ok(());
1656            }
1657
1658            // Decode unknown envelopes for gaps in ordinals.
1659            while _next_ordinal_to_read < 9 {
1660                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1661                _next_ordinal_to_read += 1;
1662                next_offset += envelope_size;
1663            }
1664
1665            let next_out_of_line = decoder.next_out_of_line();
1666            let handles_before = decoder.remaining_handles();
1667            if let Some((inlined, num_bytes, num_handles)) =
1668                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1669            {
1670                let member_inline_size =
1671                    <f64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1672                if inlined != (member_inline_size <= 4) {
1673                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1674                }
1675                let inner_offset;
1676                let mut inner_depth = depth.clone();
1677                if inlined {
1678                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1679                    inner_offset = next_offset;
1680                } else {
1681                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1682                    inner_depth.increment()?;
1683                }
1684                let val_ref =
1685                    self.scroll_h_physical_pixel.get_or_insert_with(|| fidl::new_empty!(f64, D));
1686                fidl::decode!(f64, D, val_ref, decoder, inner_offset, inner_depth)?;
1687                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1688                {
1689                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1690                }
1691                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1692                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1693                }
1694            }
1695
1696            next_offset += envelope_size;
1697            _next_ordinal_to_read += 1;
1698            if next_offset >= end_offset {
1699                return Ok(());
1700            }
1701
1702            // Decode unknown envelopes for gaps in ordinals.
1703            while _next_ordinal_to_read < 10 {
1704                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1705                _next_ordinal_to_read += 1;
1706                next_offset += envelope_size;
1707            }
1708
1709            let next_out_of_line = decoder.next_out_of_line();
1710            let handles_before = decoder.remaining_handles();
1711            if let Some((inlined, num_bytes, num_handles)) =
1712                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1713            {
1714                let member_inline_size =
1715                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1716                if inlined != (member_inline_size <= 4) {
1717                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1718                }
1719                let inner_offset;
1720                let mut inner_depth = depth.clone();
1721                if inlined {
1722                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1723                    inner_offset = next_offset;
1724                } else {
1725                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1726                    inner_depth.increment()?;
1727                }
1728                let val_ref =
1729                    self.is_precision_scroll.get_or_insert_with(|| fidl::new_empty!(bool, D));
1730                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1731                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1732                {
1733                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1734                }
1735                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1736                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1737                }
1738            }
1739
1740            next_offset += envelope_size;
1741
1742            // Decode the remaining unknown envelopes.
1743            while next_offset < end_offset {
1744                _next_ordinal_to_read += 1;
1745                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1746                next_offset += envelope_size;
1747            }
1748
1749            Ok(())
1750        }
1751    }
1752
1753    impl Viewport {
1754        #[inline(always)]
1755        fn max_ordinal_present(&self) -> u64 {
1756            if let Some(_) = self.viewport_to_context_transform {
1757                return 2;
1758            }
1759            if let Some(_) = self.extents {
1760                return 1;
1761            }
1762            0
1763        }
1764    }
1765
1766    impl fidl::encoding::ValueTypeMarker for Viewport {
1767        type Borrowed<'a> = &'a Self;
1768        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1769            value
1770        }
1771    }
1772
1773    unsafe impl fidl::encoding::TypeMarker for Viewport {
1774        type Owned = Self;
1775
1776        #[inline(always)]
1777        fn inline_align(_context: fidl::encoding::Context) -> usize {
1778            8
1779        }
1780
1781        #[inline(always)]
1782        fn inline_size(_context: fidl::encoding::Context) -> usize {
1783            16
1784        }
1785    }
1786
1787    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Viewport, D> for &Viewport {
1788        unsafe fn encode(
1789            self,
1790            encoder: &mut fidl::encoding::Encoder<'_, D>,
1791            offset: usize,
1792            mut depth: fidl::encoding::Depth,
1793        ) -> fidl::Result<()> {
1794            encoder.debug_check_bounds::<Viewport>(offset);
1795            // Vector header
1796            let max_ordinal: u64 = self.max_ordinal_present();
1797            encoder.write_num(max_ordinal, offset);
1798            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1799            // Calling encoder.out_of_line_offset(0) is not allowed.
1800            if max_ordinal == 0 {
1801                return Ok(());
1802            }
1803            depth.increment()?;
1804            let envelope_size = 8;
1805            let bytes_len = max_ordinal as usize * envelope_size;
1806            #[allow(unused_variables)]
1807            let offset = encoder.out_of_line_offset(bytes_len);
1808            let mut _prev_end_offset: usize = 0;
1809            if 1 > max_ordinal {
1810                return Ok(());
1811            }
1812
1813            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1814            // are envelope_size bytes.
1815            let cur_offset: usize = (1 - 1) * envelope_size;
1816
1817            // Zero reserved fields.
1818            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1819
1820            // Safety:
1821            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1822            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1823            //   envelope_size bytes, there is always sufficient room.
1824            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<fidl::encoding::Array<f32, 2>, 2>, D>(
1825            self.extents.as_ref().map(<fidl::encoding::Array<fidl::encoding::Array<f32, 2>, 2> as fidl::encoding::ValueTypeMarker>::borrow),
1826            encoder, offset + cur_offset, depth
1827        )?;
1828
1829            _prev_end_offset = cur_offset + envelope_size;
1830            if 2 > max_ordinal {
1831                return Ok(());
1832            }
1833
1834            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1835            // are envelope_size bytes.
1836            let cur_offset: usize = (2 - 1) * envelope_size;
1837
1838            // Zero reserved fields.
1839            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1840
1841            // Safety:
1842            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1843            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1844            //   envelope_size bytes, there is always sufficient room.
1845            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<f32, 9>, D>(
1846                self.viewport_to_context_transform.as_ref().map(
1847                    <fidl::encoding::Array<f32, 9> as fidl::encoding::ValueTypeMarker>::borrow,
1848                ),
1849                encoder,
1850                offset + cur_offset,
1851                depth,
1852            )?;
1853
1854            _prev_end_offset = cur_offset + envelope_size;
1855
1856            Ok(())
1857        }
1858    }
1859
1860    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Viewport {
1861        #[inline(always)]
1862        fn new_empty() -> Self {
1863            Self::default()
1864        }
1865
1866        unsafe fn decode(
1867            &mut self,
1868            decoder: &mut fidl::encoding::Decoder<'_, D>,
1869            offset: usize,
1870            mut depth: fidl::encoding::Depth,
1871        ) -> fidl::Result<()> {
1872            decoder.debug_check_bounds::<Self>(offset);
1873            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1874                None => return Err(fidl::Error::NotNullable),
1875                Some(len) => len,
1876            };
1877            // Calling decoder.out_of_line_offset(0) is not allowed.
1878            if len == 0 {
1879                return Ok(());
1880            };
1881            depth.increment()?;
1882            let envelope_size = 8;
1883            let bytes_len = len * envelope_size;
1884            let offset = decoder.out_of_line_offset(bytes_len)?;
1885            // Decode the envelope for each type.
1886            let mut _next_ordinal_to_read = 0;
1887            let mut next_offset = offset;
1888            let end_offset = offset + bytes_len;
1889            _next_ordinal_to_read += 1;
1890            if next_offset >= end_offset {
1891                return Ok(());
1892            }
1893
1894            // Decode unknown envelopes for gaps in ordinals.
1895            while _next_ordinal_to_read < 1 {
1896                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1897                _next_ordinal_to_read += 1;
1898                next_offset += envelope_size;
1899            }
1900
1901            let next_out_of_line = decoder.next_out_of_line();
1902            let handles_before = decoder.remaining_handles();
1903            if let Some((inlined, num_bytes, num_handles)) =
1904                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1905            {
1906                let member_inline_size = <fidl::encoding::Array<fidl::encoding::Array<f32, 2>, 2> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1907                if inlined != (member_inline_size <= 4) {
1908                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1909                }
1910                let inner_offset;
1911                let mut inner_depth = depth.clone();
1912                if inlined {
1913                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1914                    inner_offset = next_offset;
1915                } else {
1916                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1917                    inner_depth.increment()?;
1918                }
1919                let val_ref = self.extents.get_or_insert_with(|| {
1920                    fidl::new_empty!(fidl::encoding::Array<fidl::encoding::Array<f32, 2>, 2>, D)
1921                });
1922                fidl::decode!(
1923                    fidl::encoding::Array<fidl::encoding::Array<f32, 2>, 2>,
1924                    D,
1925                    val_ref,
1926                    decoder,
1927                    inner_offset,
1928                    inner_depth
1929                )?;
1930                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1931                {
1932                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1933                }
1934                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1935                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1936                }
1937            }
1938
1939            next_offset += envelope_size;
1940            _next_ordinal_to_read += 1;
1941            if next_offset >= end_offset {
1942                return Ok(());
1943            }
1944
1945            // Decode unknown envelopes for gaps in ordinals.
1946            while _next_ordinal_to_read < 2 {
1947                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1948                _next_ordinal_to_read += 1;
1949                next_offset += envelope_size;
1950            }
1951
1952            let next_out_of_line = decoder.next_out_of_line();
1953            let handles_before = decoder.remaining_handles();
1954            if let Some((inlined, num_bytes, num_handles)) =
1955                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1956            {
1957                let member_inline_size =
1958                    <fidl::encoding::Array<f32, 9> as fidl::encoding::TypeMarker>::inline_size(
1959                        decoder.context,
1960                    );
1961                if inlined != (member_inline_size <= 4) {
1962                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1963                }
1964                let inner_offset;
1965                let mut inner_depth = depth.clone();
1966                if inlined {
1967                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1968                    inner_offset = next_offset;
1969                } else {
1970                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1971                    inner_depth.increment()?;
1972                }
1973                let val_ref = self
1974                    .viewport_to_context_transform
1975                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<f32, 9>, D));
1976                fidl::decode!(fidl::encoding::Array<f32, 9>, D, val_ref, decoder, inner_offset, inner_depth)?;
1977                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1978                {
1979                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1980                }
1981                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1982                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1983                }
1984            }
1985
1986            next_offset += envelope_size;
1987
1988            // Decode the remaining unknown envelopes.
1989            while next_offset < end_offset {
1990                _next_ordinal_to_read += 1;
1991                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1992                next_offset += envelope_size;
1993            }
1994
1995            Ok(())
1996        }
1997    }
1998
1999    impl fidl::encoding::ValueTypeMarker for Data {
2000        type Borrowed<'a> = &'a Self;
2001        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2002            value
2003        }
2004    }
2005
2006    unsafe impl fidl::encoding::TypeMarker for Data {
2007        type Owned = Self;
2008
2009        #[inline(always)]
2010        fn inline_align(_context: fidl::encoding::Context) -> usize {
2011            8
2012        }
2013
2014        #[inline(always)]
2015        fn inline_size(_context: fidl::encoding::Context) -> usize {
2016            16
2017        }
2018    }
2019
2020    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Data, D> for &Data {
2021        #[inline]
2022        unsafe fn encode(
2023            self,
2024            encoder: &mut fidl::encoding::Encoder<'_, D>,
2025            offset: usize,
2026            _depth: fidl::encoding::Depth,
2027        ) -> fidl::Result<()> {
2028            encoder.debug_check_bounds::<Data>(offset);
2029            encoder.write_num::<u64>(self.ordinal(), offset);
2030            match self {
2031                Data::Viewport(ref val) => fidl::encoding::encode_in_envelope::<Viewport, D>(
2032                    <Viewport as fidl::encoding::ValueTypeMarker>::borrow(val),
2033                    encoder,
2034                    offset + 8,
2035                    _depth,
2036                ),
2037                Data::PointerSample(ref val) => {
2038                    fidl::encoding::encode_in_envelope::<PointerSample, D>(
2039                        <PointerSample as fidl::encoding::ValueTypeMarker>::borrow(val),
2040                        encoder,
2041                        offset + 8,
2042                        _depth,
2043                    )
2044                }
2045                Data::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2046            }
2047        }
2048    }
2049
2050    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Data {
2051        #[inline(always)]
2052        fn new_empty() -> Self {
2053            Self::__SourceBreaking { unknown_ordinal: 0 }
2054        }
2055
2056        #[inline]
2057        unsafe fn decode(
2058            &mut self,
2059            decoder: &mut fidl::encoding::Decoder<'_, D>,
2060            offset: usize,
2061            mut depth: fidl::encoding::Depth,
2062        ) -> fidl::Result<()> {
2063            decoder.debug_check_bounds::<Self>(offset);
2064            #[allow(unused_variables)]
2065            let next_out_of_line = decoder.next_out_of_line();
2066            let handles_before = decoder.remaining_handles();
2067            let (ordinal, inlined, num_bytes, num_handles) =
2068                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2069
2070            let member_inline_size = match ordinal {
2071                1 => <Viewport as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2072                2 => <PointerSample as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2073                0 => return Err(fidl::Error::UnknownUnionTag),
2074                _ => num_bytes as usize,
2075            };
2076
2077            if inlined != (member_inline_size <= 4) {
2078                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2079            }
2080            let _inner_offset;
2081            if inlined {
2082                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2083                _inner_offset = offset + 8;
2084            } else {
2085                depth.increment()?;
2086                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2087            }
2088            match ordinal {
2089                1 => {
2090                    #[allow(irrefutable_let_patterns)]
2091                    if let Data::Viewport(_) = self {
2092                        // Do nothing, read the value into the object
2093                    } else {
2094                        // Initialize `self` to the right variant
2095                        *self = Data::Viewport(fidl::new_empty!(Viewport, D));
2096                    }
2097                    #[allow(irrefutable_let_patterns)]
2098                    if let Data::Viewport(ref mut val) = self {
2099                        fidl::decode!(Viewport, D, val, decoder, _inner_offset, depth)?;
2100                    } else {
2101                        unreachable!()
2102                    }
2103                }
2104                2 => {
2105                    #[allow(irrefutable_let_patterns)]
2106                    if let Data::PointerSample(_) = self {
2107                        // Do nothing, read the value into the object
2108                    } else {
2109                        // Initialize `self` to the right variant
2110                        *self = Data::PointerSample(fidl::new_empty!(PointerSample, D));
2111                    }
2112                    #[allow(irrefutable_let_patterns)]
2113                    if let Data::PointerSample(ref mut val) = self {
2114                        fidl::decode!(PointerSample, D, val, decoder, _inner_offset, depth)?;
2115                    } else {
2116                        unreachable!()
2117                    }
2118                }
2119                #[allow(deprecated)]
2120                ordinal => {
2121                    for _ in 0..num_handles {
2122                        decoder.drop_next_handle()?;
2123                    }
2124                    *self = Data::__SourceBreaking { unknown_ordinal: ordinal };
2125                }
2126            }
2127            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2128                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2129            }
2130            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2131                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2132            }
2133            Ok(())
2134        }
2135    }
2136}