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