Skip to main content

fidl_fuchsia_ui_pointer/
fidl_fuchsia_ui_pointer.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_ui_pointer_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct MouseSourceWatchResponse {
16    pub events: Vec<MouseEvent>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for MouseSourceWatchResponse {}
20
21#[derive(Debug, PartialEq)]
22pub struct TouchSourceWatchResponse {
23    pub events: Vec<TouchEvent>,
24}
25
26impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for TouchSourceWatchResponse {}
27
28#[derive(Debug, Default, PartialEq)]
29pub struct MouseEvent {
30    /// The time this event was observed.
31    /// Required.
32    pub timestamp: Option<i64>,
33    /// The parameters of the associated view and viewport, sufficient to
34    /// correctly interpret the position, orientation, magnitude, and
35    /// inter-event distance of pointer events dispatched to a view.
36    /// - It is issued on connection and on change.
37    pub view_parameters: Option<ViewParameters>,
38    /// A description of the mouse device, sufficient to correctly interpret
39    /// the capabilities and usage intent of the device.
40    /// - It is issued once per device.
41    pub device_info: Option<MouseDeviceInfo>,
42    /// A description of each sampled data point in a mouse event stream.
43    ///
44    /// Issuance policy. There are two dispatch modes, "hover" and "latched".
45    /// Hover mode is default, and the stream is dispatched in fragments to the
46    /// visible client that each mouse event hovers above. Latched mode directs
47    /// the stream to a single client (regardless of view boundary) until
48    /// unlatched. Latched mode is typically toggled when the user presses the
49    /// primary mouse button, but is ultimately a product-specific policy.
50    pub pointer_sample: Option<MousePointerSample>,
51    /// The signal for view entry/exit in hover mode.
52    /// - It is issued on hover entry into a view, and hover exit from a view.
53    pub stream_info: Option<MouseEventStreamInfo>,
54    /// An identifier to correlate this event's send/receive occurrence across
55    /// component boundaries or abstraction layers.
56    pub trace_flow_id: Option<u64>,
57    /// Optional wake lease for power baton passing.
58    pub wake_lease: Option<fidl::EventPair>,
59    #[doc(hidden)]
60    pub __source_breaking: fidl::marker::SourceBreaking,
61}
62
63impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for MouseEvent {}
64
65#[derive(Debug, Default, PartialEq)]
66pub struct TouchEvent {
67    /// The time this event was observed.
68    /// Required.
69    pub timestamp: Option<i64>,
70    /// The parameters of the associated view and viewport, sufficient to
71    /// correctly interpret the position, orientation, magnitude, and
72    /// inter-event distance of touch events dispatched to a view.
73    /// - It is issued on connection and on change.
74    pub view_parameters: Option<ViewParameters>,
75    /// A description of the pointer device, sufficient to correctly interpret
76    /// the capabilities and usage intent of the device.
77    /// - It is issued once per device.
78    pub device_info: Option<TouchDeviceInfo>,
79    /// A description of each sampled data point in an interaction of touch
80    /// events.
81    /// - It is issued on every sample in the interaction.
82    pub pointer_sample: Option<TouchPointerSample>,
83    /// The result of gesture disambiguation for a interaction of touch events.
84    /// - It is issued once per interaction.
85    pub interaction_result: Option<TouchInteractionResult>,
86    /// An identifier to correlate this event's send/receive occurrence across
87    /// component boundaries or abstraction layers.
88    pub trace_flow_id: Option<u64>,
89    /// Optional wake lease for power baton passing.
90    pub wake_lease: Option<fidl::EventPair>,
91    #[doc(hidden)]
92    pub __source_breaking: fidl::marker::SourceBreaking,
93}
94
95impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for TouchEvent {}
96
97#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
98pub struct MouseSourceMarker;
99
100impl fidl::endpoints::ProtocolMarker for MouseSourceMarker {
101    type Proxy = MouseSourceProxy;
102    type RequestStream = MouseSourceRequestStream;
103    #[cfg(target_os = "fuchsia")]
104    type SynchronousProxy = MouseSourceSynchronousProxy;
105
106    const DEBUG_NAME: &'static str = "(anonymous) MouseSource";
107}
108
109pub trait MouseSourceProxyInterface: Send + Sync {
110    type WatchResponseFut: std::future::Future<Output = Result<Vec<MouseEvent>, fidl::Error>> + Send;
111    fn r#watch(&self) -> Self::WatchResponseFut;
112}
113#[derive(Debug)]
114#[cfg(target_os = "fuchsia")]
115pub struct MouseSourceSynchronousProxy {
116    client: fidl::client::sync::Client,
117}
118
119#[cfg(target_os = "fuchsia")]
120impl fidl::endpoints::SynchronousProxy for MouseSourceSynchronousProxy {
121    type Proxy = MouseSourceProxy;
122    type Protocol = MouseSourceMarker;
123
124    fn from_channel(inner: fidl::Channel) -> Self {
125        Self::new(inner)
126    }
127
128    fn into_channel(self) -> fidl::Channel {
129        self.client.into_channel()
130    }
131
132    fn as_channel(&self) -> &fidl::Channel {
133        self.client.as_channel()
134    }
135}
136
137#[cfg(target_os = "fuchsia")]
138impl MouseSourceSynchronousProxy {
139    pub fn new(channel: fidl::Channel) -> Self {
140        Self { client: fidl::client::sync::Client::new(channel) }
141    }
142
143    pub fn into_channel(self) -> fidl::Channel {
144        self.client.into_channel()
145    }
146
147    /// Waits until an event arrives and returns it. It is safe for other
148    /// threads to make concurrent requests while waiting for an event.
149    pub fn wait_for_event(
150        &self,
151        deadline: zx::MonotonicInstant,
152    ) -> Result<MouseSourceEvent, fidl::Error> {
153        MouseSourceEvent::decode(self.client.wait_for_event::<MouseSourceMarker>(deadline)?)
154    }
155
156    /// A method for a client to receive mouse pointer events.
157    ///
158    /// This call is formulated as a "hanging get" pattern: the client asks for
159    /// a set of recent events, and receives them via the callback. This
160    /// pull-based approach ensures that clients consume events at their own
161    /// pace; events don't clog up the channel in an unbounded manner.
162    ///
163    /// Flow control. The caller is allowed at most one in-flight |Watch| call
164    /// at a time; it is a logical error to have concurrent calls to |Watch|.
165    /// Non-compliance results in channel closure.
166    ///
167    /// Client pacing. The server will dispatch events to the caller on a FIFO,
168    /// lossless, best-effort basis, but the caller must allocate enough time to
169    /// keep up with new events.
170    ///
171    /// Event times. The timestamps on each event in the event vector are *not*
172    /// guaranteed monotonic; events from different devices may be injected into
173    /// Scenic at different times. Generally, events from a single device are
174    /// expected to have monotonically increasing timestamps.
175    ///
176    /// View parameters. Occasionally, changes in view or viewport require
177    /// notifying the client. If a |MouseEvent| carries |ViewParameters|, these
178    /// parameters apply to successive |MousePointerSample|s until the next
179    /// |ViewParameters|.
180    pub fn r#watch(
181        &self,
182        ___deadline: zx::MonotonicInstant,
183    ) -> Result<Vec<MouseEvent>, fidl::Error> {
184        let _response = self.client.send_query::<
185            fidl::encoding::EmptyPayload,
186            MouseSourceWatchResponse,
187            MouseSourceMarker,
188        >(
189            (),
190            0x5b1f6e917ac1abb4,
191            fidl::encoding::DynamicFlags::empty(),
192            ___deadline,
193        )?;
194        Ok(_response.events)
195    }
196}
197
198#[cfg(target_os = "fuchsia")]
199impl From<MouseSourceSynchronousProxy> for zx::NullableHandle {
200    fn from(value: MouseSourceSynchronousProxy) -> Self {
201        value.into_channel().into()
202    }
203}
204
205#[cfg(target_os = "fuchsia")]
206impl From<fidl::Channel> for MouseSourceSynchronousProxy {
207    fn from(value: fidl::Channel) -> Self {
208        Self::new(value)
209    }
210}
211
212#[cfg(target_os = "fuchsia")]
213impl fidl::endpoints::FromClient for MouseSourceSynchronousProxy {
214    type Protocol = MouseSourceMarker;
215
216    fn from_client(value: fidl::endpoints::ClientEnd<MouseSourceMarker>) -> Self {
217        Self::new(value.into_channel())
218    }
219}
220
221#[derive(Debug, Clone)]
222pub struct MouseSourceProxy {
223    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
224}
225
226impl fidl::endpoints::Proxy for MouseSourceProxy {
227    type Protocol = MouseSourceMarker;
228
229    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
230        Self::new(inner)
231    }
232
233    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
234        self.client.into_channel().map_err(|client| Self { client })
235    }
236
237    fn as_channel(&self) -> &::fidl::AsyncChannel {
238        self.client.as_channel()
239    }
240}
241
242impl MouseSourceProxy {
243    /// Create a new Proxy for fuchsia.ui.pointer/MouseSource.
244    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
245        let protocol_name = <MouseSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
246        Self { client: fidl::client::Client::new(channel, protocol_name) }
247    }
248
249    /// Get a Stream of events from the remote end of the protocol.
250    ///
251    /// # Panics
252    ///
253    /// Panics if the event stream was already taken.
254    pub fn take_event_stream(&self) -> MouseSourceEventStream {
255        MouseSourceEventStream { event_receiver: self.client.take_event_receiver() }
256    }
257
258    /// A method for a client to receive mouse pointer events.
259    ///
260    /// This call is formulated as a "hanging get" pattern: the client asks for
261    /// a set of recent events, and receives them via the callback. This
262    /// pull-based approach ensures that clients consume events at their own
263    /// pace; events don't clog up the channel in an unbounded manner.
264    ///
265    /// Flow control. The caller is allowed at most one in-flight |Watch| call
266    /// at a time; it is a logical error to have concurrent calls to |Watch|.
267    /// Non-compliance results in channel closure.
268    ///
269    /// Client pacing. The server will dispatch events to the caller on a FIFO,
270    /// lossless, best-effort basis, but the caller must allocate enough time to
271    /// keep up with new events.
272    ///
273    /// Event times. The timestamps on each event in the event vector are *not*
274    /// guaranteed monotonic; events from different devices may be injected into
275    /// Scenic at different times. Generally, events from a single device are
276    /// expected to have monotonically increasing timestamps.
277    ///
278    /// View parameters. Occasionally, changes in view or viewport require
279    /// notifying the client. If a |MouseEvent| carries |ViewParameters|, these
280    /// parameters apply to successive |MousePointerSample|s until the next
281    /// |ViewParameters|.
282    pub fn r#watch(
283        &self,
284    ) -> fidl::client::QueryResponseFut<
285        Vec<MouseEvent>,
286        fidl::encoding::DefaultFuchsiaResourceDialect,
287    > {
288        MouseSourceProxyInterface::r#watch(self)
289    }
290}
291
292impl MouseSourceProxyInterface for MouseSourceProxy {
293    type WatchResponseFut = fidl::client::QueryResponseFut<
294        Vec<MouseEvent>,
295        fidl::encoding::DefaultFuchsiaResourceDialect,
296    >;
297    fn r#watch(&self) -> Self::WatchResponseFut {
298        fn _decode(
299            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
300        ) -> Result<Vec<MouseEvent>, fidl::Error> {
301            let _response = fidl::client::decode_transaction_body::<
302                MouseSourceWatchResponse,
303                fidl::encoding::DefaultFuchsiaResourceDialect,
304                0x5b1f6e917ac1abb4,
305            >(_buf?)?;
306            Ok(_response.events)
307        }
308        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<MouseEvent>>(
309            (),
310            0x5b1f6e917ac1abb4,
311            fidl::encoding::DynamicFlags::empty(),
312            _decode,
313        )
314    }
315}
316
317pub struct MouseSourceEventStream {
318    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
319}
320
321impl std::marker::Unpin for MouseSourceEventStream {}
322
323impl futures::stream::FusedStream for MouseSourceEventStream {
324    fn is_terminated(&self) -> bool {
325        self.event_receiver.is_terminated()
326    }
327}
328
329impl futures::Stream for MouseSourceEventStream {
330    type Item = Result<MouseSourceEvent, fidl::Error>;
331
332    fn poll_next(
333        mut self: std::pin::Pin<&mut Self>,
334        cx: &mut std::task::Context<'_>,
335    ) -> std::task::Poll<Option<Self::Item>> {
336        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
337            &mut self.event_receiver,
338            cx
339        )?) {
340            Some(buf) => std::task::Poll::Ready(Some(MouseSourceEvent::decode(buf))),
341            None => std::task::Poll::Ready(None),
342        }
343    }
344}
345
346#[derive(Debug)]
347pub enum MouseSourceEvent {}
348
349impl MouseSourceEvent {
350    /// Decodes a message buffer as a [`MouseSourceEvent`].
351    fn decode(
352        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
353    ) -> Result<MouseSourceEvent, fidl::Error> {
354        let (bytes, _handles) = buf.split_mut();
355        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
356        debug_assert_eq!(tx_header.tx_id, 0);
357        match tx_header.ordinal {
358            _ => Err(fidl::Error::UnknownOrdinal {
359                ordinal: tx_header.ordinal,
360                protocol_name: <MouseSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
361            }),
362        }
363    }
364}
365
366/// A Stream of incoming requests for fuchsia.ui.pointer/MouseSource.
367pub struct MouseSourceRequestStream {
368    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
369    is_terminated: bool,
370}
371
372impl std::marker::Unpin for MouseSourceRequestStream {}
373
374impl futures::stream::FusedStream for MouseSourceRequestStream {
375    fn is_terminated(&self) -> bool {
376        self.is_terminated
377    }
378}
379
380impl fidl::endpoints::RequestStream for MouseSourceRequestStream {
381    type Protocol = MouseSourceMarker;
382    type ControlHandle = MouseSourceControlHandle;
383
384    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
385        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
386    }
387
388    fn control_handle(&self) -> Self::ControlHandle {
389        MouseSourceControlHandle { inner: self.inner.clone() }
390    }
391
392    fn into_inner(
393        self,
394    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
395    {
396        (self.inner, self.is_terminated)
397    }
398
399    fn from_inner(
400        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
401        is_terminated: bool,
402    ) -> Self {
403        Self { inner, is_terminated }
404    }
405}
406
407impl futures::Stream for MouseSourceRequestStream {
408    type Item = Result<MouseSourceRequest, fidl::Error>;
409
410    fn poll_next(
411        mut self: std::pin::Pin<&mut Self>,
412        cx: &mut std::task::Context<'_>,
413    ) -> std::task::Poll<Option<Self::Item>> {
414        let this = &mut *self;
415        if this.inner.check_shutdown(cx) {
416            this.is_terminated = true;
417            return std::task::Poll::Ready(None);
418        }
419        if this.is_terminated {
420            panic!("polled MouseSourceRequestStream after completion");
421        }
422        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
423            |bytes, handles| {
424                match this.inner.channel().read_etc(cx, bytes, handles) {
425                    std::task::Poll::Ready(Ok(())) => {}
426                    std::task::Poll::Pending => return std::task::Poll::Pending,
427                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
428                        this.is_terminated = true;
429                        return std::task::Poll::Ready(None);
430                    }
431                    std::task::Poll::Ready(Err(e)) => {
432                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
433                            e.into(),
434                        ))));
435                    }
436                }
437
438                // A message has been received from the channel
439                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
440
441                std::task::Poll::Ready(Some(match header.ordinal {
442                    0x5b1f6e917ac1abb4 => {
443                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
444                        let mut req = fidl::new_empty!(
445                            fidl::encoding::EmptyPayload,
446                            fidl::encoding::DefaultFuchsiaResourceDialect
447                        );
448                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
449                        let control_handle = MouseSourceControlHandle { inner: this.inner.clone() };
450                        Ok(MouseSourceRequest::Watch {
451                            responder: MouseSourceWatchResponder {
452                                control_handle: std::mem::ManuallyDrop::new(control_handle),
453                                tx_id: header.tx_id,
454                            },
455                        })
456                    }
457                    _ => Err(fidl::Error::UnknownOrdinal {
458                        ordinal: header.ordinal,
459                        protocol_name:
460                            <MouseSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
461                    }),
462                }))
463            },
464        )
465    }
466}
467
468/// A method for a client to receive mouse pointer events.
469///
470/// The position of a pointer event is defined in the context of a viewport,
471/// situated in the view. The dimensions of the view and viewport, and their
472/// spatial relationship (defined with a transform matrix), are supplied
473/// synchronously in a |ViewParameter| table. A view may retrieve a pointer's
474/// position in its local coordinate system by applying the viewport-to-view
475/// transform matrix.
476///
477/// The viewport is embedded in an independent and stable coordinate system,
478/// suitable for interpreting pointer events in a scale-independent manner;
479/// mouse movement will be observed at a constant scale, even under effects such
480/// as magnification or panning. However, other effects, such as enlargening the
481/// view's clip bounds, may trigger a change in the viewport extents.
482#[derive(Debug)]
483pub enum MouseSourceRequest {
484    /// A method for a client to receive mouse pointer events.
485    ///
486    /// This call is formulated as a "hanging get" pattern: the client asks for
487    /// a set of recent events, and receives them via the callback. This
488    /// pull-based approach ensures that clients consume events at their own
489    /// pace; events don't clog up the channel in an unbounded manner.
490    ///
491    /// Flow control. The caller is allowed at most one in-flight |Watch| call
492    /// at a time; it is a logical error to have concurrent calls to |Watch|.
493    /// Non-compliance results in channel closure.
494    ///
495    /// Client pacing. The server will dispatch events to the caller on a FIFO,
496    /// lossless, best-effort basis, but the caller must allocate enough time to
497    /// keep up with new events.
498    ///
499    /// Event times. The timestamps on each event in the event vector are *not*
500    /// guaranteed monotonic; events from different devices may be injected into
501    /// Scenic at different times. Generally, events from a single device are
502    /// expected to have monotonically increasing timestamps.
503    ///
504    /// View parameters. Occasionally, changes in view or viewport require
505    /// notifying the client. If a |MouseEvent| carries |ViewParameters|, these
506    /// parameters apply to successive |MousePointerSample|s until the next
507    /// |ViewParameters|.
508    Watch { responder: MouseSourceWatchResponder },
509}
510
511impl MouseSourceRequest {
512    #[allow(irrefutable_let_patterns)]
513    pub fn into_watch(self) -> Option<(MouseSourceWatchResponder)> {
514        if let MouseSourceRequest::Watch { responder } = self { Some((responder)) } else { None }
515    }
516
517    /// Name of the method defined in FIDL
518    pub fn method_name(&self) -> &'static str {
519        match *self {
520            MouseSourceRequest::Watch { .. } => "watch",
521        }
522    }
523}
524
525#[derive(Debug, Clone)]
526pub struct MouseSourceControlHandle {
527    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
528}
529
530impl MouseSourceControlHandle {
531    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
532        self.inner.shutdown_with_epitaph(status.into())
533    }
534}
535
536impl fidl::endpoints::ControlHandle for MouseSourceControlHandle {
537    fn shutdown(&self) {
538        self.inner.shutdown()
539    }
540
541    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
542        self.inner.shutdown_with_epitaph(status)
543    }
544
545    fn is_closed(&self) -> bool {
546        self.inner.channel().is_closed()
547    }
548    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
549        self.inner.channel().on_closed()
550    }
551
552    #[cfg(target_os = "fuchsia")]
553    fn signal_peer(
554        &self,
555        clear_mask: zx::Signals,
556        set_mask: zx::Signals,
557    ) -> Result<(), zx_status::Status> {
558        use fidl::Peered;
559        self.inner.channel().signal_peer(clear_mask, set_mask)
560    }
561}
562
563impl MouseSourceControlHandle {}
564
565#[must_use = "FIDL methods require a response to be sent"]
566#[derive(Debug)]
567pub struct MouseSourceWatchResponder {
568    control_handle: std::mem::ManuallyDrop<MouseSourceControlHandle>,
569    tx_id: u32,
570}
571
572/// Set the the channel to be shutdown (see [`MouseSourceControlHandle::shutdown`])
573/// if the responder is dropped without sending a response, so that the client
574/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
575impl std::ops::Drop for MouseSourceWatchResponder {
576    fn drop(&mut self) {
577        self.control_handle.shutdown();
578        // Safety: drops once, never accessed again
579        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
580    }
581}
582
583impl fidl::endpoints::Responder for MouseSourceWatchResponder {
584    type ControlHandle = MouseSourceControlHandle;
585
586    fn control_handle(&self) -> &MouseSourceControlHandle {
587        &self.control_handle
588    }
589
590    fn drop_without_shutdown(mut self) {
591        // Safety: drops once, never accessed again due to mem::forget
592        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
593        // Prevent Drop from running (which would shut down the channel)
594        std::mem::forget(self);
595    }
596}
597
598impl MouseSourceWatchResponder {
599    /// Sends a response to the FIDL transaction.
600    ///
601    /// Sets the channel to shutdown if an error occurs.
602    pub fn send(self, mut events: Vec<MouseEvent>) -> Result<(), fidl::Error> {
603        let _result = self.send_raw(events);
604        if _result.is_err() {
605            self.control_handle.shutdown();
606        }
607        self.drop_without_shutdown();
608        _result
609    }
610
611    /// Similar to "send" but does not shutdown the channel if an error occurs.
612    pub fn send_no_shutdown_on_err(self, mut events: Vec<MouseEvent>) -> Result<(), fidl::Error> {
613        let _result = self.send_raw(events);
614        self.drop_without_shutdown();
615        _result
616    }
617
618    fn send_raw(&self, mut events: Vec<MouseEvent>) -> Result<(), fidl::Error> {
619        self.control_handle.inner.send::<MouseSourceWatchResponse>(
620            (events.as_mut(),),
621            self.tx_id,
622            0x5b1f6e917ac1abb4,
623            fidl::encoding::DynamicFlags::empty(),
624        )
625    }
626}
627
628#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
629pub struct TouchSourceMarker;
630
631impl fidl::endpoints::ProtocolMarker for TouchSourceMarker {
632    type Proxy = TouchSourceProxy;
633    type RequestStream = TouchSourceRequestStream;
634    #[cfg(target_os = "fuchsia")]
635    type SynchronousProxy = TouchSourceSynchronousProxy;
636
637    const DEBUG_NAME: &'static str = "(anonymous) TouchSource";
638}
639
640pub trait TouchSourceProxyInterface: Send + Sync {
641    type WatchResponseFut: std::future::Future<Output = Result<Vec<TouchEvent>, fidl::Error>> + Send;
642    fn r#watch(&self, responses: &[TouchResponse]) -> Self::WatchResponseFut;
643    type UpdateResponseResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
644    fn r#update_response(
645        &self,
646        interaction: &TouchInteractionId,
647        response: &TouchResponse,
648    ) -> Self::UpdateResponseResponseFut;
649}
650#[derive(Debug)]
651#[cfg(target_os = "fuchsia")]
652pub struct TouchSourceSynchronousProxy {
653    client: fidl::client::sync::Client,
654}
655
656#[cfg(target_os = "fuchsia")]
657impl fidl::endpoints::SynchronousProxy for TouchSourceSynchronousProxy {
658    type Proxy = TouchSourceProxy;
659    type Protocol = TouchSourceMarker;
660
661    fn from_channel(inner: fidl::Channel) -> Self {
662        Self::new(inner)
663    }
664
665    fn into_channel(self) -> fidl::Channel {
666        self.client.into_channel()
667    }
668
669    fn as_channel(&self) -> &fidl::Channel {
670        self.client.as_channel()
671    }
672}
673
674#[cfg(target_os = "fuchsia")]
675impl TouchSourceSynchronousProxy {
676    pub fn new(channel: fidl::Channel) -> Self {
677        Self { client: fidl::client::sync::Client::new(channel) }
678    }
679
680    pub fn into_channel(self) -> fidl::Channel {
681        self.client.into_channel()
682    }
683
684    /// Waits until an event arrives and returns it. It is safe for other
685    /// threads to make concurrent requests while waiting for an event.
686    pub fn wait_for_event(
687        &self,
688        deadline: zx::MonotonicInstant,
689    ) -> Result<TouchSourceEvent, fidl::Error> {
690        TouchSourceEvent::decode(self.client.wait_for_event::<TouchSourceMarker>(deadline)?)
691    }
692
693    /// A method for a client to receive touch pointer events.
694    ///
695    /// This call is formulated as a "hanging get" pattern: the client asks for
696    /// a set of recent events, and receives them via the callback. This
697    /// pull-based approach ensures that clients consume events at their own
698    /// pace; events don't clog up the channel in an unbounded manner.
699    ///
700    /// Flow control. The caller is allowed at most one in-flight |Watch| call
701    /// at a time; it is a logical error to have concurrent calls to |Watch|.
702    /// Non-compliance results in channel closure.
703    ///
704    /// Client pacing. The server will dispatch events to the caller on a FIFO,
705    /// lossless, best-effort basis, but the caller must allocate enough time to
706    /// keep up with new events. An unresponsive client may be categorized as
707    /// "App Not Responding" and targeted for channel closure.
708    ///
709    /// Responses. The gesture disambiguation scheme relies on the server
710    /// receiving a |TouchResponse| for each |TouchEvent|.|TouchPointerSample|;
711    /// non-sample events should return an empty |TouchResponse| table to the
712    /// server. Responses for *previous* events are fed to the server on the
713    /// *next* call of |Watch| [1]. Each element in the |responses| vector is
714    /// interpreted as the pairwise response to the event in the previous
715    /// |events| vector; the vector lengths must match. Note that the client's
716    /// contract to respond to events starts as soon as it registers its
717    /// endpoint with scenic, NOT when it first calls `Watch()`.
718    ///
719    /// Initial response. The first call to |Watch| must be an empty vector.
720    ///
721    /// Event times. The timestamps on each event in the event vector are *not*
722    /// guaranteed monotonic; touch events from different devices may be
723    /// injected into Scenic at different times. Generally, events from a single
724    /// device are expected to have monotonically increasing timestamps.
725    ///
726    /// View parameters. Occasionally, changes in view or viewport require
727    /// notifying the client. If a |TouchEvent| carries |ViewParameters|, these
728    /// parameters apply to successive |TouchPointerSample|s until the next
729    /// |ViewParameters|.
730    ///
731    /// [1] The hanging get pattern enables straightforward API evolution, but
732    /// unfortunately does not admit an idiomatic matching of response to event.
733    pub fn r#watch(
734        &self,
735        mut responses: &[TouchResponse],
736        ___deadline: zx::MonotonicInstant,
737    ) -> Result<Vec<TouchEvent>, fidl::Error> {
738        let _response = self
739            .client
740            .send_query::<TouchSourceWatchRequest, TouchSourceWatchResponse, TouchSourceMarker>(
741                (responses,),
742                0x38453127dd0fc7d,
743                fidl::encoding::DynamicFlags::empty(),
744                ___deadline,
745            )?;
746        Ok(_response.events)
747    }
748
749    /// The gesture protocol allows a client to enact a "hold" on an open
750    /// interaction of touch events; it prevents resolution of interaction
751    /// ownership, even after the interaction closes. This method updates the
752    /// client's previous "hold" by replacing it with a response that allows
753    /// ownership resolution to proceed.
754    ///
755    /// See |TouchInteractionId| for how a stream is structured into
756    /// interactions.
757    ///
758    /// Flow control. The caller is allowed at most one |UpdateResponse| call
759    /// per interaction, and it must be on a closed interaction. It is a logical
760    /// error to call |UpdateResponse| when a normal response is possible with
761    /// the |Watch| call.
762    ///
763    /// Validity. This TouchResponse must not be another "hold" response, and
764    /// the overwritten response is expected to be a "hold" response.
765    pub fn r#update_response(
766        &self,
767        mut interaction: &TouchInteractionId,
768        mut response: &TouchResponse,
769        ___deadline: zx::MonotonicInstant,
770    ) -> Result<(), fidl::Error> {
771        let _response = self.client.send_query::<
772            TouchSourceUpdateResponseRequest,
773            fidl::encoding::EmptyPayload,
774            TouchSourceMarker,
775        >(
776            (interaction, response,),
777            0x6c746a313b39898a,
778            fidl::encoding::DynamicFlags::empty(),
779            ___deadline,
780        )?;
781        Ok(_response)
782    }
783}
784
785#[cfg(target_os = "fuchsia")]
786impl From<TouchSourceSynchronousProxy> for zx::NullableHandle {
787    fn from(value: TouchSourceSynchronousProxy) -> Self {
788        value.into_channel().into()
789    }
790}
791
792#[cfg(target_os = "fuchsia")]
793impl From<fidl::Channel> for TouchSourceSynchronousProxy {
794    fn from(value: fidl::Channel) -> Self {
795        Self::new(value)
796    }
797}
798
799#[cfg(target_os = "fuchsia")]
800impl fidl::endpoints::FromClient for TouchSourceSynchronousProxy {
801    type Protocol = TouchSourceMarker;
802
803    fn from_client(value: fidl::endpoints::ClientEnd<TouchSourceMarker>) -> Self {
804        Self::new(value.into_channel())
805    }
806}
807
808#[derive(Debug, Clone)]
809pub struct TouchSourceProxy {
810    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
811}
812
813impl fidl::endpoints::Proxy for TouchSourceProxy {
814    type Protocol = TouchSourceMarker;
815
816    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
817        Self::new(inner)
818    }
819
820    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
821        self.client.into_channel().map_err(|client| Self { client })
822    }
823
824    fn as_channel(&self) -> &::fidl::AsyncChannel {
825        self.client.as_channel()
826    }
827}
828
829impl TouchSourceProxy {
830    /// Create a new Proxy for fuchsia.ui.pointer/TouchSource.
831    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
832        let protocol_name = <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
833        Self { client: fidl::client::Client::new(channel, protocol_name) }
834    }
835
836    /// Get a Stream of events from the remote end of the protocol.
837    ///
838    /// # Panics
839    ///
840    /// Panics if the event stream was already taken.
841    pub fn take_event_stream(&self) -> TouchSourceEventStream {
842        TouchSourceEventStream { event_receiver: self.client.take_event_receiver() }
843    }
844
845    /// A method for a client to receive touch pointer events.
846    ///
847    /// This call is formulated as a "hanging get" pattern: the client asks for
848    /// a set of recent events, and receives them via the callback. This
849    /// pull-based approach ensures that clients consume events at their own
850    /// pace; events don't clog up the channel in an unbounded manner.
851    ///
852    /// Flow control. The caller is allowed at most one in-flight |Watch| call
853    /// at a time; it is a logical error to have concurrent calls to |Watch|.
854    /// Non-compliance results in channel closure.
855    ///
856    /// Client pacing. The server will dispatch events to the caller on a FIFO,
857    /// lossless, best-effort basis, but the caller must allocate enough time to
858    /// keep up with new events. An unresponsive client may be categorized as
859    /// "App Not Responding" and targeted for channel closure.
860    ///
861    /// Responses. The gesture disambiguation scheme relies on the server
862    /// receiving a |TouchResponse| for each |TouchEvent|.|TouchPointerSample|;
863    /// non-sample events should return an empty |TouchResponse| table to the
864    /// server. Responses for *previous* events are fed to the server on the
865    /// *next* call of |Watch| [1]. Each element in the |responses| vector is
866    /// interpreted as the pairwise response to the event in the previous
867    /// |events| vector; the vector lengths must match. Note that the client's
868    /// contract to respond to events starts as soon as it registers its
869    /// endpoint with scenic, NOT when it first calls `Watch()`.
870    ///
871    /// Initial response. The first call to |Watch| must be an empty vector.
872    ///
873    /// Event times. The timestamps on each event in the event vector are *not*
874    /// guaranteed monotonic; touch events from different devices may be
875    /// injected into Scenic at different times. Generally, events from a single
876    /// device are expected to have monotonically increasing timestamps.
877    ///
878    /// View parameters. Occasionally, changes in view or viewport require
879    /// notifying the client. If a |TouchEvent| carries |ViewParameters|, these
880    /// parameters apply to successive |TouchPointerSample|s until the next
881    /// |ViewParameters|.
882    ///
883    /// [1] The hanging get pattern enables straightforward API evolution, but
884    /// unfortunately does not admit an idiomatic matching of response to event.
885    pub fn r#watch(
886        &self,
887        mut responses: &[TouchResponse],
888    ) -> fidl::client::QueryResponseFut<
889        Vec<TouchEvent>,
890        fidl::encoding::DefaultFuchsiaResourceDialect,
891    > {
892        TouchSourceProxyInterface::r#watch(self, responses)
893    }
894
895    /// The gesture protocol allows a client to enact a "hold" on an open
896    /// interaction of touch events; it prevents resolution of interaction
897    /// ownership, even after the interaction closes. This method updates the
898    /// client's previous "hold" by replacing it with a response that allows
899    /// ownership resolution to proceed.
900    ///
901    /// See |TouchInteractionId| for how a stream is structured into
902    /// interactions.
903    ///
904    /// Flow control. The caller is allowed at most one |UpdateResponse| call
905    /// per interaction, and it must be on a closed interaction. It is a logical
906    /// error to call |UpdateResponse| when a normal response is possible with
907    /// the |Watch| call.
908    ///
909    /// Validity. This TouchResponse must not be another "hold" response, and
910    /// the overwritten response is expected to be a "hold" response.
911    pub fn r#update_response(
912        &self,
913        mut interaction: &TouchInteractionId,
914        mut response: &TouchResponse,
915    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
916        TouchSourceProxyInterface::r#update_response(self, interaction, response)
917    }
918}
919
920impl TouchSourceProxyInterface for TouchSourceProxy {
921    type WatchResponseFut = fidl::client::QueryResponseFut<
922        Vec<TouchEvent>,
923        fidl::encoding::DefaultFuchsiaResourceDialect,
924    >;
925    fn r#watch(&self, mut responses: &[TouchResponse]) -> Self::WatchResponseFut {
926        fn _decode(
927            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
928        ) -> Result<Vec<TouchEvent>, fidl::Error> {
929            let _response = fidl::client::decode_transaction_body::<
930                TouchSourceWatchResponse,
931                fidl::encoding::DefaultFuchsiaResourceDialect,
932                0x38453127dd0fc7d,
933            >(_buf?)?;
934            Ok(_response.events)
935        }
936        self.client.send_query_and_decode::<TouchSourceWatchRequest, Vec<TouchEvent>>(
937            (responses,),
938            0x38453127dd0fc7d,
939            fidl::encoding::DynamicFlags::empty(),
940            _decode,
941        )
942    }
943
944    type UpdateResponseResponseFut =
945        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
946    fn r#update_response(
947        &self,
948        mut interaction: &TouchInteractionId,
949        mut response: &TouchResponse,
950    ) -> Self::UpdateResponseResponseFut {
951        fn _decode(
952            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
953        ) -> Result<(), fidl::Error> {
954            let _response = fidl::client::decode_transaction_body::<
955                fidl::encoding::EmptyPayload,
956                fidl::encoding::DefaultFuchsiaResourceDialect,
957                0x6c746a313b39898a,
958            >(_buf?)?;
959            Ok(_response)
960        }
961        self.client.send_query_and_decode::<TouchSourceUpdateResponseRequest, ()>(
962            (interaction, response),
963            0x6c746a313b39898a,
964            fidl::encoding::DynamicFlags::empty(),
965            _decode,
966        )
967    }
968}
969
970pub struct TouchSourceEventStream {
971    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
972}
973
974impl std::marker::Unpin for TouchSourceEventStream {}
975
976impl futures::stream::FusedStream for TouchSourceEventStream {
977    fn is_terminated(&self) -> bool {
978        self.event_receiver.is_terminated()
979    }
980}
981
982impl futures::Stream for TouchSourceEventStream {
983    type Item = Result<TouchSourceEvent, fidl::Error>;
984
985    fn poll_next(
986        mut self: std::pin::Pin<&mut Self>,
987        cx: &mut std::task::Context<'_>,
988    ) -> std::task::Poll<Option<Self::Item>> {
989        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
990            &mut self.event_receiver,
991            cx
992        )?) {
993            Some(buf) => std::task::Poll::Ready(Some(TouchSourceEvent::decode(buf))),
994            None => std::task::Poll::Ready(None),
995        }
996    }
997}
998
999#[derive(Debug)]
1000pub enum TouchSourceEvent {}
1001
1002impl TouchSourceEvent {
1003    /// Decodes a message buffer as a [`TouchSourceEvent`].
1004    fn decode(
1005        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1006    ) -> Result<TouchSourceEvent, fidl::Error> {
1007        let (bytes, _handles) = buf.split_mut();
1008        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1009        debug_assert_eq!(tx_header.tx_id, 0);
1010        match tx_header.ordinal {
1011            _ => Err(fidl::Error::UnknownOrdinal {
1012                ordinal: tx_header.ordinal,
1013                protocol_name: <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1014            }),
1015        }
1016    }
1017}
1018
1019/// A Stream of incoming requests for fuchsia.ui.pointer/TouchSource.
1020pub struct TouchSourceRequestStream {
1021    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1022    is_terminated: bool,
1023}
1024
1025impl std::marker::Unpin for TouchSourceRequestStream {}
1026
1027impl futures::stream::FusedStream for TouchSourceRequestStream {
1028    fn is_terminated(&self) -> bool {
1029        self.is_terminated
1030    }
1031}
1032
1033impl fidl::endpoints::RequestStream for TouchSourceRequestStream {
1034    type Protocol = TouchSourceMarker;
1035    type ControlHandle = TouchSourceControlHandle;
1036
1037    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1038        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1039    }
1040
1041    fn control_handle(&self) -> Self::ControlHandle {
1042        TouchSourceControlHandle { inner: self.inner.clone() }
1043    }
1044
1045    fn into_inner(
1046        self,
1047    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1048    {
1049        (self.inner, self.is_terminated)
1050    }
1051
1052    fn from_inner(
1053        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1054        is_terminated: bool,
1055    ) -> Self {
1056        Self { inner, is_terminated }
1057    }
1058}
1059
1060impl futures::Stream for TouchSourceRequestStream {
1061    type Item = Result<TouchSourceRequest, fidl::Error>;
1062
1063    fn poll_next(
1064        mut self: std::pin::Pin<&mut Self>,
1065        cx: &mut std::task::Context<'_>,
1066    ) -> std::task::Poll<Option<Self::Item>> {
1067        let this = &mut *self;
1068        if this.inner.check_shutdown(cx) {
1069            this.is_terminated = true;
1070            return std::task::Poll::Ready(None);
1071        }
1072        if this.is_terminated {
1073            panic!("polled TouchSourceRequestStream after completion");
1074        }
1075        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1076            |bytes, handles| {
1077                match this.inner.channel().read_etc(cx, bytes, handles) {
1078                    std::task::Poll::Ready(Ok(())) => {}
1079                    std::task::Poll::Pending => return std::task::Poll::Pending,
1080                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1081                        this.is_terminated = true;
1082                        return std::task::Poll::Ready(None);
1083                    }
1084                    std::task::Poll::Ready(Err(e)) => {
1085                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1086                            e.into(),
1087                        ))));
1088                    }
1089                }
1090
1091                // A message has been received from the channel
1092                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1093
1094                std::task::Poll::Ready(Some(match header.ordinal {
1095                    0x38453127dd0fc7d => {
1096                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1097                        let mut req = fidl::new_empty!(
1098                            TouchSourceWatchRequest,
1099                            fidl::encoding::DefaultFuchsiaResourceDialect
1100                        );
1101                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TouchSourceWatchRequest>(&header, _body_bytes, handles, &mut req)?;
1102                        let control_handle = TouchSourceControlHandle { inner: this.inner.clone() };
1103                        Ok(TouchSourceRequest::Watch {
1104                            responses: req.responses,
1105
1106                            responder: TouchSourceWatchResponder {
1107                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1108                                tx_id: header.tx_id,
1109                            },
1110                        })
1111                    }
1112                    0x6c746a313b39898a => {
1113                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1114                        let mut req = fidl::new_empty!(
1115                            TouchSourceUpdateResponseRequest,
1116                            fidl::encoding::DefaultFuchsiaResourceDialect
1117                        );
1118                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TouchSourceUpdateResponseRequest>(&header, _body_bytes, handles, &mut req)?;
1119                        let control_handle = TouchSourceControlHandle { inner: this.inner.clone() };
1120                        Ok(TouchSourceRequest::UpdateResponse {
1121                            interaction: req.interaction,
1122                            response: req.response,
1123
1124                            responder: TouchSourceUpdateResponseResponder {
1125                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1126                                tx_id: header.tx_id,
1127                            },
1128                        })
1129                    }
1130                    _ => Err(fidl::Error::UnknownOrdinal {
1131                        ordinal: header.ordinal,
1132                        protocol_name:
1133                            <TouchSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1134                    }),
1135                }))
1136            },
1137        )
1138    }
1139}
1140
1141/// A method for a client to receive touch events and respond in a global
1142/// gesture disambiguation protocol.
1143///
1144/// The position of a touch event is defined in the context of a viewport,
1145/// situated in the view. The dimensions of the view and viewport, and their
1146/// spatial relationship (defined with a transform matrix), are supplied
1147/// synchronously in a |ViewParameter| table. A view may retrieve a pointer's
1148/// position in its local coordinate system by applying the viewport-to-view
1149/// transform matrix.
1150///
1151/// The viewport is embedded in an independent and stable coordinate system,
1152/// suitable for interpreting touch events in a scale-independent manner; a
1153/// swipe will be observed at a constant scale, even under effects such as
1154/// magnification or panning. However, other effects, such as enlargening the
1155/// view's clip bounds, may trigger a change in the viewport extents.
1156#[derive(Debug)]
1157pub enum TouchSourceRequest {
1158    /// A method for a client to receive touch pointer events.
1159    ///
1160    /// This call is formulated as a "hanging get" pattern: the client asks for
1161    /// a set of recent events, and receives them via the callback. This
1162    /// pull-based approach ensures that clients consume events at their own
1163    /// pace; events don't clog up the channel in an unbounded manner.
1164    ///
1165    /// Flow control. The caller is allowed at most one in-flight |Watch| call
1166    /// at a time; it is a logical error to have concurrent calls to |Watch|.
1167    /// Non-compliance results in channel closure.
1168    ///
1169    /// Client pacing. The server will dispatch events to the caller on a FIFO,
1170    /// lossless, best-effort basis, but the caller must allocate enough time to
1171    /// keep up with new events. An unresponsive client may be categorized as
1172    /// "App Not Responding" and targeted for channel closure.
1173    ///
1174    /// Responses. The gesture disambiguation scheme relies on the server
1175    /// receiving a |TouchResponse| for each |TouchEvent|.|TouchPointerSample|;
1176    /// non-sample events should return an empty |TouchResponse| table to the
1177    /// server. Responses for *previous* events are fed to the server on the
1178    /// *next* call of |Watch| [1]. Each element in the |responses| vector is
1179    /// interpreted as the pairwise response to the event in the previous
1180    /// |events| vector; the vector lengths must match. Note that the client's
1181    /// contract to respond to events starts as soon as it registers its
1182    /// endpoint with scenic, NOT when it first calls `Watch()`.
1183    ///
1184    /// Initial response. The first call to |Watch| must be an empty vector.
1185    ///
1186    /// Event times. The timestamps on each event in the event vector are *not*
1187    /// guaranteed monotonic; touch events from different devices may be
1188    /// injected into Scenic at different times. Generally, events from a single
1189    /// device are expected to have monotonically increasing timestamps.
1190    ///
1191    /// View parameters. Occasionally, changes in view or viewport require
1192    /// notifying the client. If a |TouchEvent| carries |ViewParameters|, these
1193    /// parameters apply to successive |TouchPointerSample|s until the next
1194    /// |ViewParameters|.
1195    ///
1196    /// [1] The hanging get pattern enables straightforward API evolution, but
1197    /// unfortunately does not admit an idiomatic matching of response to event.
1198    Watch { responses: Vec<TouchResponse>, responder: TouchSourceWatchResponder },
1199    /// The gesture protocol allows a client to enact a "hold" on an open
1200    /// interaction of touch events; it prevents resolution of interaction
1201    /// ownership, even after the interaction closes. This method updates the
1202    /// client's previous "hold" by replacing it with a response that allows
1203    /// ownership resolution to proceed.
1204    ///
1205    /// See |TouchInteractionId| for how a stream is structured into
1206    /// interactions.
1207    ///
1208    /// Flow control. The caller is allowed at most one |UpdateResponse| call
1209    /// per interaction, and it must be on a closed interaction. It is a logical
1210    /// error to call |UpdateResponse| when a normal response is possible with
1211    /// the |Watch| call.
1212    ///
1213    /// Validity. This TouchResponse must not be another "hold" response, and
1214    /// the overwritten response is expected to be a "hold" response.
1215    UpdateResponse {
1216        interaction: TouchInteractionId,
1217        response: TouchResponse,
1218        responder: TouchSourceUpdateResponseResponder,
1219    },
1220}
1221
1222impl TouchSourceRequest {
1223    #[allow(irrefutable_let_patterns)]
1224    pub fn into_watch(self) -> Option<(Vec<TouchResponse>, TouchSourceWatchResponder)> {
1225        if let TouchSourceRequest::Watch { responses, responder } = self {
1226            Some((responses, responder))
1227        } else {
1228            None
1229        }
1230    }
1231
1232    #[allow(irrefutable_let_patterns)]
1233    pub fn into_update_response(
1234        self,
1235    ) -> Option<(TouchInteractionId, TouchResponse, TouchSourceUpdateResponseResponder)> {
1236        if let TouchSourceRequest::UpdateResponse { interaction, response, responder } = self {
1237            Some((interaction, response, responder))
1238        } else {
1239            None
1240        }
1241    }
1242
1243    /// Name of the method defined in FIDL
1244    pub fn method_name(&self) -> &'static str {
1245        match *self {
1246            TouchSourceRequest::Watch { .. } => "watch",
1247            TouchSourceRequest::UpdateResponse { .. } => "update_response",
1248        }
1249    }
1250}
1251
1252#[derive(Debug, Clone)]
1253pub struct TouchSourceControlHandle {
1254    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1255}
1256
1257impl TouchSourceControlHandle {
1258    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1259        self.inner.shutdown_with_epitaph(status.into())
1260    }
1261}
1262
1263impl fidl::endpoints::ControlHandle for TouchSourceControlHandle {
1264    fn shutdown(&self) {
1265        self.inner.shutdown()
1266    }
1267
1268    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1269        self.inner.shutdown_with_epitaph(status)
1270    }
1271
1272    fn is_closed(&self) -> bool {
1273        self.inner.channel().is_closed()
1274    }
1275    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1276        self.inner.channel().on_closed()
1277    }
1278
1279    #[cfg(target_os = "fuchsia")]
1280    fn signal_peer(
1281        &self,
1282        clear_mask: zx::Signals,
1283        set_mask: zx::Signals,
1284    ) -> Result<(), zx_status::Status> {
1285        use fidl::Peered;
1286        self.inner.channel().signal_peer(clear_mask, set_mask)
1287    }
1288}
1289
1290impl TouchSourceControlHandle {}
1291
1292#[must_use = "FIDL methods require a response to be sent"]
1293#[derive(Debug)]
1294pub struct TouchSourceWatchResponder {
1295    control_handle: std::mem::ManuallyDrop<TouchSourceControlHandle>,
1296    tx_id: u32,
1297}
1298
1299/// Set the the channel to be shutdown (see [`TouchSourceControlHandle::shutdown`])
1300/// if the responder is dropped without sending a response, so that the client
1301/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1302impl std::ops::Drop for TouchSourceWatchResponder {
1303    fn drop(&mut self) {
1304        self.control_handle.shutdown();
1305        // Safety: drops once, never accessed again
1306        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1307    }
1308}
1309
1310impl fidl::endpoints::Responder for TouchSourceWatchResponder {
1311    type ControlHandle = TouchSourceControlHandle;
1312
1313    fn control_handle(&self) -> &TouchSourceControlHandle {
1314        &self.control_handle
1315    }
1316
1317    fn drop_without_shutdown(mut self) {
1318        // Safety: drops once, never accessed again due to mem::forget
1319        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1320        // Prevent Drop from running (which would shut down the channel)
1321        std::mem::forget(self);
1322    }
1323}
1324
1325impl TouchSourceWatchResponder {
1326    /// Sends a response to the FIDL transaction.
1327    ///
1328    /// Sets the channel to shutdown if an error occurs.
1329    pub fn send(self, mut events: Vec<TouchEvent>) -> Result<(), fidl::Error> {
1330        let _result = self.send_raw(events);
1331        if _result.is_err() {
1332            self.control_handle.shutdown();
1333        }
1334        self.drop_without_shutdown();
1335        _result
1336    }
1337
1338    /// Similar to "send" but does not shutdown the channel if an error occurs.
1339    pub fn send_no_shutdown_on_err(self, mut events: Vec<TouchEvent>) -> Result<(), fidl::Error> {
1340        let _result = self.send_raw(events);
1341        self.drop_without_shutdown();
1342        _result
1343    }
1344
1345    fn send_raw(&self, mut events: Vec<TouchEvent>) -> Result<(), fidl::Error> {
1346        self.control_handle.inner.send::<TouchSourceWatchResponse>(
1347            (events.as_mut(),),
1348            self.tx_id,
1349            0x38453127dd0fc7d,
1350            fidl::encoding::DynamicFlags::empty(),
1351        )
1352    }
1353}
1354
1355#[must_use = "FIDL methods require a response to be sent"]
1356#[derive(Debug)]
1357pub struct TouchSourceUpdateResponseResponder {
1358    control_handle: std::mem::ManuallyDrop<TouchSourceControlHandle>,
1359    tx_id: u32,
1360}
1361
1362/// Set the the channel to be shutdown (see [`TouchSourceControlHandle::shutdown`])
1363/// if the responder is dropped without sending a response, so that the client
1364/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1365impl std::ops::Drop for TouchSourceUpdateResponseResponder {
1366    fn drop(&mut self) {
1367        self.control_handle.shutdown();
1368        // Safety: drops once, never accessed again
1369        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1370    }
1371}
1372
1373impl fidl::endpoints::Responder for TouchSourceUpdateResponseResponder {
1374    type ControlHandle = TouchSourceControlHandle;
1375
1376    fn control_handle(&self) -> &TouchSourceControlHandle {
1377        &self.control_handle
1378    }
1379
1380    fn drop_without_shutdown(mut self) {
1381        // Safety: drops once, never accessed again due to mem::forget
1382        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1383        // Prevent Drop from running (which would shut down the channel)
1384        std::mem::forget(self);
1385    }
1386}
1387
1388impl TouchSourceUpdateResponseResponder {
1389    /// Sends a response to the FIDL transaction.
1390    ///
1391    /// Sets the channel to shutdown if an error occurs.
1392    pub fn send(self) -> Result<(), fidl::Error> {
1393        let _result = self.send_raw();
1394        if _result.is_err() {
1395            self.control_handle.shutdown();
1396        }
1397        self.drop_without_shutdown();
1398        _result
1399    }
1400
1401    /// Similar to "send" but does not shutdown the channel if an error occurs.
1402    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1403        let _result = self.send_raw();
1404        self.drop_without_shutdown();
1405        _result
1406    }
1407
1408    fn send_raw(&self) -> Result<(), fidl::Error> {
1409        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1410            (),
1411            self.tx_id,
1412            0x6c746a313b39898a,
1413            fidl::encoding::DynamicFlags::empty(),
1414        )
1415    }
1416}
1417
1418mod internal {
1419    use super::*;
1420
1421    impl fidl::encoding::ResourceTypeMarker for MouseSourceWatchResponse {
1422        type Borrowed<'a> = &'a mut Self;
1423        fn take_or_borrow<'a>(
1424            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1425        ) -> Self::Borrowed<'a> {
1426            value
1427        }
1428    }
1429
1430    unsafe impl fidl::encoding::TypeMarker for MouseSourceWatchResponse {
1431        type Owned = Self;
1432
1433        #[inline(always)]
1434        fn inline_align(_context: fidl::encoding::Context) -> usize {
1435            8
1436        }
1437
1438        #[inline(always)]
1439        fn inline_size(_context: fidl::encoding::Context) -> usize {
1440            16
1441        }
1442    }
1443
1444    unsafe impl
1445        fidl::encoding::Encode<
1446            MouseSourceWatchResponse,
1447            fidl::encoding::DefaultFuchsiaResourceDialect,
1448        > for &mut MouseSourceWatchResponse
1449    {
1450        #[inline]
1451        unsafe fn encode(
1452            self,
1453            encoder: &mut fidl::encoding::Encoder<
1454                '_,
1455                fidl::encoding::DefaultFuchsiaResourceDialect,
1456            >,
1457            offset: usize,
1458            _depth: fidl::encoding::Depth,
1459        ) -> fidl::Result<()> {
1460            encoder.debug_check_bounds::<MouseSourceWatchResponse>(offset);
1461            // Delegate to tuple encoding.
1462            fidl::encoding::Encode::<MouseSourceWatchResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1463                (
1464                    <fidl::encoding::Vector<MouseEvent, 128> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.events),
1465                ),
1466                encoder, offset, _depth
1467            )
1468        }
1469    }
1470    unsafe impl<
1471        T0: fidl::encoding::Encode<
1472                fidl::encoding::Vector<MouseEvent, 128>,
1473                fidl::encoding::DefaultFuchsiaResourceDialect,
1474            >,
1475    >
1476        fidl::encoding::Encode<
1477            MouseSourceWatchResponse,
1478            fidl::encoding::DefaultFuchsiaResourceDialect,
1479        > for (T0,)
1480    {
1481        #[inline]
1482        unsafe fn encode(
1483            self,
1484            encoder: &mut fidl::encoding::Encoder<
1485                '_,
1486                fidl::encoding::DefaultFuchsiaResourceDialect,
1487            >,
1488            offset: usize,
1489            depth: fidl::encoding::Depth,
1490        ) -> fidl::Result<()> {
1491            encoder.debug_check_bounds::<MouseSourceWatchResponse>(offset);
1492            // Zero out padding regions. There's no need to apply masks
1493            // because the unmasked parts will be overwritten by fields.
1494            // Write the fields.
1495            self.0.encode(encoder, offset + 0, depth)?;
1496            Ok(())
1497        }
1498    }
1499
1500    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1501        for MouseSourceWatchResponse
1502    {
1503        #[inline(always)]
1504        fn new_empty() -> Self {
1505            Self {
1506                events: fidl::new_empty!(fidl::encoding::Vector<MouseEvent, 128>, fidl::encoding::DefaultFuchsiaResourceDialect),
1507            }
1508        }
1509
1510        #[inline]
1511        unsafe fn decode(
1512            &mut self,
1513            decoder: &mut fidl::encoding::Decoder<
1514                '_,
1515                fidl::encoding::DefaultFuchsiaResourceDialect,
1516            >,
1517            offset: usize,
1518            _depth: fidl::encoding::Depth,
1519        ) -> fidl::Result<()> {
1520            decoder.debug_check_bounds::<Self>(offset);
1521            // Verify that padding bytes are zero.
1522            fidl::decode!(fidl::encoding::Vector<MouseEvent, 128>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.events, decoder, offset + 0, _depth)?;
1523            Ok(())
1524        }
1525    }
1526
1527    impl fidl::encoding::ResourceTypeMarker for TouchSourceWatchResponse {
1528        type Borrowed<'a> = &'a mut Self;
1529        fn take_or_borrow<'a>(
1530            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1531        ) -> Self::Borrowed<'a> {
1532            value
1533        }
1534    }
1535
1536    unsafe impl fidl::encoding::TypeMarker for TouchSourceWatchResponse {
1537        type Owned = Self;
1538
1539        #[inline(always)]
1540        fn inline_align(_context: fidl::encoding::Context) -> usize {
1541            8
1542        }
1543
1544        #[inline(always)]
1545        fn inline_size(_context: fidl::encoding::Context) -> usize {
1546            16
1547        }
1548    }
1549
1550    unsafe impl
1551        fidl::encoding::Encode<
1552            TouchSourceWatchResponse,
1553            fidl::encoding::DefaultFuchsiaResourceDialect,
1554        > for &mut TouchSourceWatchResponse
1555    {
1556        #[inline]
1557        unsafe fn encode(
1558            self,
1559            encoder: &mut fidl::encoding::Encoder<
1560                '_,
1561                fidl::encoding::DefaultFuchsiaResourceDialect,
1562            >,
1563            offset: usize,
1564            _depth: fidl::encoding::Depth,
1565        ) -> fidl::Result<()> {
1566            encoder.debug_check_bounds::<TouchSourceWatchResponse>(offset);
1567            // Delegate to tuple encoding.
1568            fidl::encoding::Encode::<TouchSourceWatchResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1569                (
1570                    <fidl::encoding::Vector<TouchEvent, 128> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.events),
1571                ),
1572                encoder, offset, _depth
1573            )
1574        }
1575    }
1576    unsafe impl<
1577        T0: fidl::encoding::Encode<
1578                fidl::encoding::Vector<TouchEvent, 128>,
1579                fidl::encoding::DefaultFuchsiaResourceDialect,
1580            >,
1581    >
1582        fidl::encoding::Encode<
1583            TouchSourceWatchResponse,
1584            fidl::encoding::DefaultFuchsiaResourceDialect,
1585        > for (T0,)
1586    {
1587        #[inline]
1588        unsafe fn encode(
1589            self,
1590            encoder: &mut fidl::encoding::Encoder<
1591                '_,
1592                fidl::encoding::DefaultFuchsiaResourceDialect,
1593            >,
1594            offset: usize,
1595            depth: fidl::encoding::Depth,
1596        ) -> fidl::Result<()> {
1597            encoder.debug_check_bounds::<TouchSourceWatchResponse>(offset);
1598            // Zero out padding regions. There's no need to apply masks
1599            // because the unmasked parts will be overwritten by fields.
1600            // Write the fields.
1601            self.0.encode(encoder, offset + 0, depth)?;
1602            Ok(())
1603        }
1604    }
1605
1606    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1607        for TouchSourceWatchResponse
1608    {
1609        #[inline(always)]
1610        fn new_empty() -> Self {
1611            Self {
1612                events: fidl::new_empty!(fidl::encoding::Vector<TouchEvent, 128>, fidl::encoding::DefaultFuchsiaResourceDialect),
1613            }
1614        }
1615
1616        #[inline]
1617        unsafe fn decode(
1618            &mut self,
1619            decoder: &mut fidl::encoding::Decoder<
1620                '_,
1621                fidl::encoding::DefaultFuchsiaResourceDialect,
1622            >,
1623            offset: usize,
1624            _depth: fidl::encoding::Depth,
1625        ) -> fidl::Result<()> {
1626            decoder.debug_check_bounds::<Self>(offset);
1627            // Verify that padding bytes are zero.
1628            fidl::decode!(fidl::encoding::Vector<TouchEvent, 128>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.events, decoder, offset + 0, _depth)?;
1629            Ok(())
1630        }
1631    }
1632
1633    impl MouseEvent {
1634        #[inline(always)]
1635        fn max_ordinal_present(&self) -> u64 {
1636            if let Some(_) = self.wake_lease {
1637                return 7;
1638            }
1639            if let Some(_) = self.trace_flow_id {
1640                return 6;
1641            }
1642            if let Some(_) = self.stream_info {
1643                return 5;
1644            }
1645            if let Some(_) = self.pointer_sample {
1646                return 4;
1647            }
1648            if let Some(_) = self.device_info {
1649                return 3;
1650            }
1651            if let Some(_) = self.view_parameters {
1652                return 2;
1653            }
1654            if let Some(_) = self.timestamp {
1655                return 1;
1656            }
1657            0
1658        }
1659    }
1660
1661    impl fidl::encoding::ResourceTypeMarker for MouseEvent {
1662        type Borrowed<'a> = &'a mut Self;
1663        fn take_or_borrow<'a>(
1664            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1665        ) -> Self::Borrowed<'a> {
1666            value
1667        }
1668    }
1669
1670    unsafe impl fidl::encoding::TypeMarker for MouseEvent {
1671        type Owned = Self;
1672
1673        #[inline(always)]
1674        fn inline_align(_context: fidl::encoding::Context) -> usize {
1675            8
1676        }
1677
1678        #[inline(always)]
1679        fn inline_size(_context: fidl::encoding::Context) -> usize {
1680            16
1681        }
1682    }
1683
1684    unsafe impl fidl::encoding::Encode<MouseEvent, fidl::encoding::DefaultFuchsiaResourceDialect>
1685        for &mut MouseEvent
1686    {
1687        unsafe fn encode(
1688            self,
1689            encoder: &mut fidl::encoding::Encoder<
1690                '_,
1691                fidl::encoding::DefaultFuchsiaResourceDialect,
1692            >,
1693            offset: usize,
1694            mut depth: fidl::encoding::Depth,
1695        ) -> fidl::Result<()> {
1696            encoder.debug_check_bounds::<MouseEvent>(offset);
1697            // Vector header
1698            let max_ordinal: u64 = self.max_ordinal_present();
1699            encoder.write_num(max_ordinal, offset);
1700            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1701            // Calling encoder.out_of_line_offset(0) is not allowed.
1702            if max_ordinal == 0 {
1703                return Ok(());
1704            }
1705            depth.increment()?;
1706            let envelope_size = 8;
1707            let bytes_len = max_ordinal as usize * envelope_size;
1708            #[allow(unused_variables)]
1709            let offset = encoder.out_of_line_offset(bytes_len);
1710            let mut _prev_end_offset: usize = 0;
1711            if 1 > max_ordinal {
1712                return Ok(());
1713            }
1714
1715            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1716            // are envelope_size bytes.
1717            let cur_offset: usize = (1 - 1) * envelope_size;
1718
1719            // Zero reserved fields.
1720            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1721
1722            // Safety:
1723            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1724            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1725            //   envelope_size bytes, there is always sufficient room.
1726            fidl::encoding::encode_in_envelope_optional::<
1727                i64,
1728                fidl::encoding::DefaultFuchsiaResourceDialect,
1729            >(
1730                self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1731                encoder,
1732                offset + cur_offset,
1733                depth,
1734            )?;
1735
1736            _prev_end_offset = cur_offset + envelope_size;
1737            if 2 > max_ordinal {
1738                return Ok(());
1739            }
1740
1741            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1742            // are envelope_size bytes.
1743            let cur_offset: usize = (2 - 1) * envelope_size;
1744
1745            // Zero reserved fields.
1746            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1747
1748            // Safety:
1749            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1750            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1751            //   envelope_size bytes, there is always sufficient room.
1752            fidl::encoding::encode_in_envelope_optional::<
1753                ViewParameters,
1754                fidl::encoding::DefaultFuchsiaResourceDialect,
1755            >(
1756                self.view_parameters
1757                    .as_ref()
1758                    .map(<ViewParameters as fidl::encoding::ValueTypeMarker>::borrow),
1759                encoder,
1760                offset + cur_offset,
1761                depth,
1762            )?;
1763
1764            _prev_end_offset = cur_offset + envelope_size;
1765            if 3 > max_ordinal {
1766                return Ok(());
1767            }
1768
1769            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1770            // are envelope_size bytes.
1771            let cur_offset: usize = (3 - 1) * envelope_size;
1772
1773            // Zero reserved fields.
1774            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1775
1776            // Safety:
1777            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1778            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1779            //   envelope_size bytes, there is always sufficient room.
1780            fidl::encoding::encode_in_envelope_optional::<
1781                MouseDeviceInfo,
1782                fidl::encoding::DefaultFuchsiaResourceDialect,
1783            >(
1784                self.device_info
1785                    .as_ref()
1786                    .map(<MouseDeviceInfo as fidl::encoding::ValueTypeMarker>::borrow),
1787                encoder,
1788                offset + cur_offset,
1789                depth,
1790            )?;
1791
1792            _prev_end_offset = cur_offset + envelope_size;
1793            if 4 > max_ordinal {
1794                return Ok(());
1795            }
1796
1797            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1798            // are envelope_size bytes.
1799            let cur_offset: usize = (4 - 1) * envelope_size;
1800
1801            // Zero reserved fields.
1802            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1803
1804            // Safety:
1805            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1806            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1807            //   envelope_size bytes, there is always sufficient room.
1808            fidl::encoding::encode_in_envelope_optional::<
1809                MousePointerSample,
1810                fidl::encoding::DefaultFuchsiaResourceDialect,
1811            >(
1812                self.pointer_sample
1813                    .as_ref()
1814                    .map(<MousePointerSample as fidl::encoding::ValueTypeMarker>::borrow),
1815                encoder,
1816                offset + cur_offset,
1817                depth,
1818            )?;
1819
1820            _prev_end_offset = cur_offset + envelope_size;
1821            if 5 > max_ordinal {
1822                return Ok(());
1823            }
1824
1825            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1826            // are envelope_size bytes.
1827            let cur_offset: usize = (5 - 1) * envelope_size;
1828
1829            // Zero reserved fields.
1830            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1831
1832            // Safety:
1833            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1834            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1835            //   envelope_size bytes, there is always sufficient room.
1836            fidl::encoding::encode_in_envelope_optional::<
1837                MouseEventStreamInfo,
1838                fidl::encoding::DefaultFuchsiaResourceDialect,
1839            >(
1840                self.stream_info
1841                    .as_ref()
1842                    .map(<MouseEventStreamInfo as fidl::encoding::ValueTypeMarker>::borrow),
1843                encoder,
1844                offset + cur_offset,
1845                depth,
1846            )?;
1847
1848            _prev_end_offset = cur_offset + envelope_size;
1849            if 6 > max_ordinal {
1850                return Ok(());
1851            }
1852
1853            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1854            // are envelope_size bytes.
1855            let cur_offset: usize = (6 - 1) * envelope_size;
1856
1857            // Zero reserved fields.
1858            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1859
1860            // Safety:
1861            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1862            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1863            //   envelope_size bytes, there is always sufficient room.
1864            fidl::encoding::encode_in_envelope_optional::<
1865                u64,
1866                fidl::encoding::DefaultFuchsiaResourceDialect,
1867            >(
1868                self.trace_flow_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1869                encoder,
1870                offset + cur_offset,
1871                depth,
1872            )?;
1873
1874            _prev_end_offset = cur_offset + envelope_size;
1875            if 7 > max_ordinal {
1876                return Ok(());
1877            }
1878
1879            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1880            // are envelope_size bytes.
1881            let cur_offset: usize = (7 - 1) * envelope_size;
1882
1883            // Zero reserved fields.
1884            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1885
1886            // Safety:
1887            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1888            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1889            //   envelope_size bytes, there is always sufficient room.
1890            fidl::encoding::encode_in_envelope_optional::<
1891                fidl::encoding::HandleType<
1892                    fidl::EventPair,
1893                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1894                    2147483648,
1895                >,
1896                fidl::encoding::DefaultFuchsiaResourceDialect,
1897            >(
1898                self.wake_lease.as_mut().map(
1899                    <fidl::encoding::HandleType<
1900                        fidl::EventPair,
1901                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1902                        2147483648,
1903                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1904                ),
1905                encoder,
1906                offset + cur_offset,
1907                depth,
1908            )?;
1909
1910            _prev_end_offset = cur_offset + envelope_size;
1911
1912            Ok(())
1913        }
1914    }
1915
1916    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for MouseEvent {
1917        #[inline(always)]
1918        fn new_empty() -> Self {
1919            Self::default()
1920        }
1921
1922        unsafe fn decode(
1923            &mut self,
1924            decoder: &mut fidl::encoding::Decoder<
1925                '_,
1926                fidl::encoding::DefaultFuchsiaResourceDialect,
1927            >,
1928            offset: usize,
1929            mut depth: fidl::encoding::Depth,
1930        ) -> fidl::Result<()> {
1931            decoder.debug_check_bounds::<Self>(offset);
1932            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1933                None => return Err(fidl::Error::NotNullable),
1934                Some(len) => len,
1935            };
1936            // Calling decoder.out_of_line_offset(0) is not allowed.
1937            if len == 0 {
1938                return Ok(());
1939            };
1940            depth.increment()?;
1941            let envelope_size = 8;
1942            let bytes_len = len * envelope_size;
1943            let offset = decoder.out_of_line_offset(bytes_len)?;
1944            // Decode the envelope for each type.
1945            let mut _next_ordinal_to_read = 0;
1946            let mut next_offset = offset;
1947            let end_offset = offset + bytes_len;
1948            _next_ordinal_to_read += 1;
1949            if next_offset >= end_offset {
1950                return Ok(());
1951            }
1952
1953            // Decode unknown envelopes for gaps in ordinals.
1954            while _next_ordinal_to_read < 1 {
1955                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1956                _next_ordinal_to_read += 1;
1957                next_offset += envelope_size;
1958            }
1959
1960            let next_out_of_line = decoder.next_out_of_line();
1961            let handles_before = decoder.remaining_handles();
1962            if let Some((inlined, num_bytes, num_handles)) =
1963                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1964            {
1965                let member_inline_size =
1966                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1967                if inlined != (member_inline_size <= 4) {
1968                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1969                }
1970                let inner_offset;
1971                let mut inner_depth = depth.clone();
1972                if inlined {
1973                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1974                    inner_offset = next_offset;
1975                } else {
1976                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1977                    inner_depth.increment()?;
1978                }
1979                let val_ref = self.timestamp.get_or_insert_with(|| {
1980                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
1981                });
1982                fidl::decode!(
1983                    i64,
1984                    fidl::encoding::DefaultFuchsiaResourceDialect,
1985                    val_ref,
1986                    decoder,
1987                    inner_offset,
1988                    inner_depth
1989                )?;
1990                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1991                {
1992                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1993                }
1994                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1995                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1996                }
1997            }
1998
1999            next_offset += envelope_size;
2000            _next_ordinal_to_read += 1;
2001            if next_offset >= end_offset {
2002                return Ok(());
2003            }
2004
2005            // Decode unknown envelopes for gaps in ordinals.
2006            while _next_ordinal_to_read < 2 {
2007                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2008                _next_ordinal_to_read += 1;
2009                next_offset += envelope_size;
2010            }
2011
2012            let next_out_of_line = decoder.next_out_of_line();
2013            let handles_before = decoder.remaining_handles();
2014            if let Some((inlined, num_bytes, num_handles)) =
2015                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2016            {
2017                let member_inline_size =
2018                    <ViewParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2019                if inlined != (member_inline_size <= 4) {
2020                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2021                }
2022                let inner_offset;
2023                let mut inner_depth = depth.clone();
2024                if inlined {
2025                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2026                    inner_offset = next_offset;
2027                } else {
2028                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2029                    inner_depth.increment()?;
2030                }
2031                let val_ref = self.view_parameters.get_or_insert_with(|| {
2032                    fidl::new_empty!(ViewParameters, fidl::encoding::DefaultFuchsiaResourceDialect)
2033                });
2034                fidl::decode!(
2035                    ViewParameters,
2036                    fidl::encoding::DefaultFuchsiaResourceDialect,
2037                    val_ref,
2038                    decoder,
2039                    inner_offset,
2040                    inner_depth
2041                )?;
2042                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2043                {
2044                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2045                }
2046                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2047                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2048                }
2049            }
2050
2051            next_offset += envelope_size;
2052            _next_ordinal_to_read += 1;
2053            if next_offset >= end_offset {
2054                return Ok(());
2055            }
2056
2057            // Decode unknown envelopes for gaps in ordinals.
2058            while _next_ordinal_to_read < 3 {
2059                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2060                _next_ordinal_to_read += 1;
2061                next_offset += envelope_size;
2062            }
2063
2064            let next_out_of_line = decoder.next_out_of_line();
2065            let handles_before = decoder.remaining_handles();
2066            if let Some((inlined, num_bytes, num_handles)) =
2067                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2068            {
2069                let member_inline_size =
2070                    <MouseDeviceInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2071                if inlined != (member_inline_size <= 4) {
2072                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2073                }
2074                let inner_offset;
2075                let mut inner_depth = depth.clone();
2076                if inlined {
2077                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2078                    inner_offset = next_offset;
2079                } else {
2080                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2081                    inner_depth.increment()?;
2082                }
2083                let val_ref = self.device_info.get_or_insert_with(|| {
2084                    fidl::new_empty!(MouseDeviceInfo, fidl::encoding::DefaultFuchsiaResourceDialect)
2085                });
2086                fidl::decode!(
2087                    MouseDeviceInfo,
2088                    fidl::encoding::DefaultFuchsiaResourceDialect,
2089                    val_ref,
2090                    decoder,
2091                    inner_offset,
2092                    inner_depth
2093                )?;
2094                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2095                {
2096                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2097                }
2098                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2099                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2100                }
2101            }
2102
2103            next_offset += envelope_size;
2104            _next_ordinal_to_read += 1;
2105            if next_offset >= end_offset {
2106                return Ok(());
2107            }
2108
2109            // Decode unknown envelopes for gaps in ordinals.
2110            while _next_ordinal_to_read < 4 {
2111                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2112                _next_ordinal_to_read += 1;
2113                next_offset += envelope_size;
2114            }
2115
2116            let next_out_of_line = decoder.next_out_of_line();
2117            let handles_before = decoder.remaining_handles();
2118            if let Some((inlined, num_bytes, num_handles)) =
2119                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2120            {
2121                let member_inline_size =
2122                    <MousePointerSample as fidl::encoding::TypeMarker>::inline_size(
2123                        decoder.context,
2124                    );
2125                if inlined != (member_inline_size <= 4) {
2126                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2127                }
2128                let inner_offset;
2129                let mut inner_depth = depth.clone();
2130                if inlined {
2131                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2132                    inner_offset = next_offset;
2133                } else {
2134                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2135                    inner_depth.increment()?;
2136                }
2137                let val_ref = self.pointer_sample.get_or_insert_with(|| {
2138                    fidl::new_empty!(
2139                        MousePointerSample,
2140                        fidl::encoding::DefaultFuchsiaResourceDialect
2141                    )
2142                });
2143                fidl::decode!(
2144                    MousePointerSample,
2145                    fidl::encoding::DefaultFuchsiaResourceDialect,
2146                    val_ref,
2147                    decoder,
2148                    inner_offset,
2149                    inner_depth
2150                )?;
2151                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2152                {
2153                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2154                }
2155                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2156                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2157                }
2158            }
2159
2160            next_offset += envelope_size;
2161            _next_ordinal_to_read += 1;
2162            if next_offset >= end_offset {
2163                return Ok(());
2164            }
2165
2166            // Decode unknown envelopes for gaps in ordinals.
2167            while _next_ordinal_to_read < 5 {
2168                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2169                _next_ordinal_to_read += 1;
2170                next_offset += envelope_size;
2171            }
2172
2173            let next_out_of_line = decoder.next_out_of_line();
2174            let handles_before = decoder.remaining_handles();
2175            if let Some((inlined, num_bytes, num_handles)) =
2176                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2177            {
2178                let member_inline_size =
2179                    <MouseEventStreamInfo as fidl::encoding::TypeMarker>::inline_size(
2180                        decoder.context,
2181                    );
2182                if inlined != (member_inline_size <= 4) {
2183                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2184                }
2185                let inner_offset;
2186                let mut inner_depth = depth.clone();
2187                if inlined {
2188                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2189                    inner_offset = next_offset;
2190                } else {
2191                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2192                    inner_depth.increment()?;
2193                }
2194                let val_ref = self.stream_info.get_or_insert_with(|| {
2195                    fidl::new_empty!(
2196                        MouseEventStreamInfo,
2197                        fidl::encoding::DefaultFuchsiaResourceDialect
2198                    )
2199                });
2200                fidl::decode!(
2201                    MouseEventStreamInfo,
2202                    fidl::encoding::DefaultFuchsiaResourceDialect,
2203                    val_ref,
2204                    decoder,
2205                    inner_offset,
2206                    inner_depth
2207                )?;
2208                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2209                {
2210                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2211                }
2212                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2213                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2214                }
2215            }
2216
2217            next_offset += envelope_size;
2218            _next_ordinal_to_read += 1;
2219            if next_offset >= end_offset {
2220                return Ok(());
2221            }
2222
2223            // Decode unknown envelopes for gaps in ordinals.
2224            while _next_ordinal_to_read < 6 {
2225                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2226                _next_ordinal_to_read += 1;
2227                next_offset += envelope_size;
2228            }
2229
2230            let next_out_of_line = decoder.next_out_of_line();
2231            let handles_before = decoder.remaining_handles();
2232            if let Some((inlined, num_bytes, num_handles)) =
2233                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2234            {
2235                let member_inline_size =
2236                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2237                if inlined != (member_inline_size <= 4) {
2238                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2239                }
2240                let inner_offset;
2241                let mut inner_depth = depth.clone();
2242                if inlined {
2243                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2244                    inner_offset = next_offset;
2245                } else {
2246                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2247                    inner_depth.increment()?;
2248                }
2249                let val_ref = self.trace_flow_id.get_or_insert_with(|| {
2250                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2251                });
2252                fidl::decode!(
2253                    u64,
2254                    fidl::encoding::DefaultFuchsiaResourceDialect,
2255                    val_ref,
2256                    decoder,
2257                    inner_offset,
2258                    inner_depth
2259                )?;
2260                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2261                {
2262                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2263                }
2264                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2265                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2266                }
2267            }
2268
2269            next_offset += envelope_size;
2270            _next_ordinal_to_read += 1;
2271            if next_offset >= end_offset {
2272                return Ok(());
2273            }
2274
2275            // Decode unknown envelopes for gaps in ordinals.
2276            while _next_ordinal_to_read < 7 {
2277                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2278                _next_ordinal_to_read += 1;
2279                next_offset += envelope_size;
2280            }
2281
2282            let next_out_of_line = decoder.next_out_of_line();
2283            let handles_before = decoder.remaining_handles();
2284            if let Some((inlined, num_bytes, num_handles)) =
2285                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2286            {
2287                let member_inline_size = <fidl::encoding::HandleType<
2288                    fidl::EventPair,
2289                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2290                    2147483648,
2291                > as fidl::encoding::TypeMarker>::inline_size(
2292                    decoder.context
2293                );
2294                if inlined != (member_inline_size <= 4) {
2295                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2296                }
2297                let inner_offset;
2298                let mut inner_depth = depth.clone();
2299                if inlined {
2300                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2301                    inner_offset = next_offset;
2302                } else {
2303                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2304                    inner_depth.increment()?;
2305                }
2306                let val_ref =
2307                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2308                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2309                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2310                {
2311                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2312                }
2313                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2314                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2315                }
2316            }
2317
2318            next_offset += envelope_size;
2319
2320            // Decode the remaining unknown envelopes.
2321            while next_offset < end_offset {
2322                _next_ordinal_to_read += 1;
2323                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2324                next_offset += envelope_size;
2325            }
2326
2327            Ok(())
2328        }
2329    }
2330
2331    impl TouchEvent {
2332        #[inline(always)]
2333        fn max_ordinal_present(&self) -> u64 {
2334            if let Some(_) = self.wake_lease {
2335                return 7;
2336            }
2337            if let Some(_) = self.trace_flow_id {
2338                return 6;
2339            }
2340            if let Some(_) = self.interaction_result {
2341                return 5;
2342            }
2343            if let Some(_) = self.pointer_sample {
2344                return 4;
2345            }
2346            if let Some(_) = self.device_info {
2347                return 3;
2348            }
2349            if let Some(_) = self.view_parameters {
2350                return 2;
2351            }
2352            if let Some(_) = self.timestamp {
2353                return 1;
2354            }
2355            0
2356        }
2357    }
2358
2359    impl fidl::encoding::ResourceTypeMarker for TouchEvent {
2360        type Borrowed<'a> = &'a mut Self;
2361        fn take_or_borrow<'a>(
2362            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2363        ) -> Self::Borrowed<'a> {
2364            value
2365        }
2366    }
2367
2368    unsafe impl fidl::encoding::TypeMarker for TouchEvent {
2369        type Owned = Self;
2370
2371        #[inline(always)]
2372        fn inline_align(_context: fidl::encoding::Context) -> usize {
2373            8
2374        }
2375
2376        #[inline(always)]
2377        fn inline_size(_context: fidl::encoding::Context) -> usize {
2378            16
2379        }
2380    }
2381
2382    unsafe impl fidl::encoding::Encode<TouchEvent, fidl::encoding::DefaultFuchsiaResourceDialect>
2383        for &mut TouchEvent
2384    {
2385        unsafe fn encode(
2386            self,
2387            encoder: &mut fidl::encoding::Encoder<
2388                '_,
2389                fidl::encoding::DefaultFuchsiaResourceDialect,
2390            >,
2391            offset: usize,
2392            mut depth: fidl::encoding::Depth,
2393        ) -> fidl::Result<()> {
2394            encoder.debug_check_bounds::<TouchEvent>(offset);
2395            // Vector header
2396            let max_ordinal: u64 = self.max_ordinal_present();
2397            encoder.write_num(max_ordinal, offset);
2398            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2399            // Calling encoder.out_of_line_offset(0) is not allowed.
2400            if max_ordinal == 0 {
2401                return Ok(());
2402            }
2403            depth.increment()?;
2404            let envelope_size = 8;
2405            let bytes_len = max_ordinal as usize * envelope_size;
2406            #[allow(unused_variables)]
2407            let offset = encoder.out_of_line_offset(bytes_len);
2408            let mut _prev_end_offset: usize = 0;
2409            if 1 > max_ordinal {
2410                return Ok(());
2411            }
2412
2413            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2414            // are envelope_size bytes.
2415            let cur_offset: usize = (1 - 1) * envelope_size;
2416
2417            // Zero reserved fields.
2418            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2419
2420            // Safety:
2421            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2422            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2423            //   envelope_size bytes, there is always sufficient room.
2424            fidl::encoding::encode_in_envelope_optional::<
2425                i64,
2426                fidl::encoding::DefaultFuchsiaResourceDialect,
2427            >(
2428                self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
2429                encoder,
2430                offset + cur_offset,
2431                depth,
2432            )?;
2433
2434            _prev_end_offset = cur_offset + envelope_size;
2435            if 2 > max_ordinal {
2436                return Ok(());
2437            }
2438
2439            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2440            // are envelope_size bytes.
2441            let cur_offset: usize = (2 - 1) * envelope_size;
2442
2443            // Zero reserved fields.
2444            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2445
2446            // Safety:
2447            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2448            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2449            //   envelope_size bytes, there is always sufficient room.
2450            fidl::encoding::encode_in_envelope_optional::<
2451                ViewParameters,
2452                fidl::encoding::DefaultFuchsiaResourceDialect,
2453            >(
2454                self.view_parameters
2455                    .as_ref()
2456                    .map(<ViewParameters as fidl::encoding::ValueTypeMarker>::borrow),
2457                encoder,
2458                offset + cur_offset,
2459                depth,
2460            )?;
2461
2462            _prev_end_offset = cur_offset + envelope_size;
2463            if 3 > max_ordinal {
2464                return Ok(());
2465            }
2466
2467            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2468            // are envelope_size bytes.
2469            let cur_offset: usize = (3 - 1) * envelope_size;
2470
2471            // Zero reserved fields.
2472            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2473
2474            // Safety:
2475            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2476            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2477            //   envelope_size bytes, there is always sufficient room.
2478            fidl::encoding::encode_in_envelope_optional::<
2479                TouchDeviceInfo,
2480                fidl::encoding::DefaultFuchsiaResourceDialect,
2481            >(
2482                self.device_info
2483                    .as_ref()
2484                    .map(<TouchDeviceInfo as fidl::encoding::ValueTypeMarker>::borrow),
2485                encoder,
2486                offset + cur_offset,
2487                depth,
2488            )?;
2489
2490            _prev_end_offset = cur_offset + envelope_size;
2491            if 4 > max_ordinal {
2492                return Ok(());
2493            }
2494
2495            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2496            // are envelope_size bytes.
2497            let cur_offset: usize = (4 - 1) * envelope_size;
2498
2499            // Zero reserved fields.
2500            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2501
2502            // Safety:
2503            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2504            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2505            //   envelope_size bytes, there is always sufficient room.
2506            fidl::encoding::encode_in_envelope_optional::<
2507                TouchPointerSample,
2508                fidl::encoding::DefaultFuchsiaResourceDialect,
2509            >(
2510                self.pointer_sample
2511                    .as_ref()
2512                    .map(<TouchPointerSample as fidl::encoding::ValueTypeMarker>::borrow),
2513                encoder,
2514                offset + cur_offset,
2515                depth,
2516            )?;
2517
2518            _prev_end_offset = cur_offset + envelope_size;
2519            if 5 > max_ordinal {
2520                return Ok(());
2521            }
2522
2523            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2524            // are envelope_size bytes.
2525            let cur_offset: usize = (5 - 1) * envelope_size;
2526
2527            // Zero reserved fields.
2528            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2529
2530            // Safety:
2531            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2532            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2533            //   envelope_size bytes, there is always sufficient room.
2534            fidl::encoding::encode_in_envelope_optional::<
2535                TouchInteractionResult,
2536                fidl::encoding::DefaultFuchsiaResourceDialect,
2537            >(
2538                self.interaction_result
2539                    .as_ref()
2540                    .map(<TouchInteractionResult as fidl::encoding::ValueTypeMarker>::borrow),
2541                encoder,
2542                offset + cur_offset,
2543                depth,
2544            )?;
2545
2546            _prev_end_offset = cur_offset + envelope_size;
2547            if 6 > max_ordinal {
2548                return Ok(());
2549            }
2550
2551            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2552            // are envelope_size bytes.
2553            let cur_offset: usize = (6 - 1) * envelope_size;
2554
2555            // Zero reserved fields.
2556            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2557
2558            // Safety:
2559            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2560            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2561            //   envelope_size bytes, there is always sufficient room.
2562            fidl::encoding::encode_in_envelope_optional::<
2563                u64,
2564                fidl::encoding::DefaultFuchsiaResourceDialect,
2565            >(
2566                self.trace_flow_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2567                encoder,
2568                offset + cur_offset,
2569                depth,
2570            )?;
2571
2572            _prev_end_offset = cur_offset + envelope_size;
2573            if 7 > max_ordinal {
2574                return Ok(());
2575            }
2576
2577            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2578            // are envelope_size bytes.
2579            let cur_offset: usize = (7 - 1) * envelope_size;
2580
2581            // Zero reserved fields.
2582            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2583
2584            // Safety:
2585            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2586            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2587            //   envelope_size bytes, there is always sufficient room.
2588            fidl::encoding::encode_in_envelope_optional::<
2589                fidl::encoding::HandleType<
2590                    fidl::EventPair,
2591                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2592                    2147483648,
2593                >,
2594                fidl::encoding::DefaultFuchsiaResourceDialect,
2595            >(
2596                self.wake_lease.as_mut().map(
2597                    <fidl::encoding::HandleType<
2598                        fidl::EventPair,
2599                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2600                        2147483648,
2601                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2602                ),
2603                encoder,
2604                offset + cur_offset,
2605                depth,
2606            )?;
2607
2608            _prev_end_offset = cur_offset + envelope_size;
2609
2610            Ok(())
2611        }
2612    }
2613
2614    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for TouchEvent {
2615        #[inline(always)]
2616        fn new_empty() -> Self {
2617            Self::default()
2618        }
2619
2620        unsafe fn decode(
2621            &mut self,
2622            decoder: &mut fidl::encoding::Decoder<
2623                '_,
2624                fidl::encoding::DefaultFuchsiaResourceDialect,
2625            >,
2626            offset: usize,
2627            mut depth: fidl::encoding::Depth,
2628        ) -> fidl::Result<()> {
2629            decoder.debug_check_bounds::<Self>(offset);
2630            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2631                None => return Err(fidl::Error::NotNullable),
2632                Some(len) => len,
2633            };
2634            // Calling decoder.out_of_line_offset(0) is not allowed.
2635            if len == 0 {
2636                return Ok(());
2637            };
2638            depth.increment()?;
2639            let envelope_size = 8;
2640            let bytes_len = len * envelope_size;
2641            let offset = decoder.out_of_line_offset(bytes_len)?;
2642            // Decode the envelope for each type.
2643            let mut _next_ordinal_to_read = 0;
2644            let mut next_offset = offset;
2645            let end_offset = offset + bytes_len;
2646            _next_ordinal_to_read += 1;
2647            if next_offset >= end_offset {
2648                return Ok(());
2649            }
2650
2651            // Decode unknown envelopes for gaps in ordinals.
2652            while _next_ordinal_to_read < 1 {
2653                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2654                _next_ordinal_to_read += 1;
2655                next_offset += envelope_size;
2656            }
2657
2658            let next_out_of_line = decoder.next_out_of_line();
2659            let handles_before = decoder.remaining_handles();
2660            if let Some((inlined, num_bytes, num_handles)) =
2661                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2662            {
2663                let member_inline_size =
2664                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2665                if inlined != (member_inline_size <= 4) {
2666                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2667                }
2668                let inner_offset;
2669                let mut inner_depth = depth.clone();
2670                if inlined {
2671                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2672                    inner_offset = next_offset;
2673                } else {
2674                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2675                    inner_depth.increment()?;
2676                }
2677                let val_ref = self.timestamp.get_or_insert_with(|| {
2678                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
2679                });
2680                fidl::decode!(
2681                    i64,
2682                    fidl::encoding::DefaultFuchsiaResourceDialect,
2683                    val_ref,
2684                    decoder,
2685                    inner_offset,
2686                    inner_depth
2687                )?;
2688                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2689                {
2690                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2691                }
2692                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2693                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2694                }
2695            }
2696
2697            next_offset += envelope_size;
2698            _next_ordinal_to_read += 1;
2699            if next_offset >= end_offset {
2700                return Ok(());
2701            }
2702
2703            // Decode unknown envelopes for gaps in ordinals.
2704            while _next_ordinal_to_read < 2 {
2705                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2706                _next_ordinal_to_read += 1;
2707                next_offset += envelope_size;
2708            }
2709
2710            let next_out_of_line = decoder.next_out_of_line();
2711            let handles_before = decoder.remaining_handles();
2712            if let Some((inlined, num_bytes, num_handles)) =
2713                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2714            {
2715                let member_inline_size =
2716                    <ViewParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2717                if inlined != (member_inline_size <= 4) {
2718                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2719                }
2720                let inner_offset;
2721                let mut inner_depth = depth.clone();
2722                if inlined {
2723                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2724                    inner_offset = next_offset;
2725                } else {
2726                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2727                    inner_depth.increment()?;
2728                }
2729                let val_ref = self.view_parameters.get_or_insert_with(|| {
2730                    fidl::new_empty!(ViewParameters, fidl::encoding::DefaultFuchsiaResourceDialect)
2731                });
2732                fidl::decode!(
2733                    ViewParameters,
2734                    fidl::encoding::DefaultFuchsiaResourceDialect,
2735                    val_ref,
2736                    decoder,
2737                    inner_offset,
2738                    inner_depth
2739                )?;
2740                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2741                {
2742                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2743                }
2744                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2745                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2746                }
2747            }
2748
2749            next_offset += envelope_size;
2750            _next_ordinal_to_read += 1;
2751            if next_offset >= end_offset {
2752                return Ok(());
2753            }
2754
2755            // Decode unknown envelopes for gaps in ordinals.
2756            while _next_ordinal_to_read < 3 {
2757                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2758                _next_ordinal_to_read += 1;
2759                next_offset += envelope_size;
2760            }
2761
2762            let next_out_of_line = decoder.next_out_of_line();
2763            let handles_before = decoder.remaining_handles();
2764            if let Some((inlined, num_bytes, num_handles)) =
2765                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2766            {
2767                let member_inline_size =
2768                    <TouchDeviceInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2769                if inlined != (member_inline_size <= 4) {
2770                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2771                }
2772                let inner_offset;
2773                let mut inner_depth = depth.clone();
2774                if inlined {
2775                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2776                    inner_offset = next_offset;
2777                } else {
2778                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2779                    inner_depth.increment()?;
2780                }
2781                let val_ref = self.device_info.get_or_insert_with(|| {
2782                    fidl::new_empty!(TouchDeviceInfo, fidl::encoding::DefaultFuchsiaResourceDialect)
2783                });
2784                fidl::decode!(
2785                    TouchDeviceInfo,
2786                    fidl::encoding::DefaultFuchsiaResourceDialect,
2787                    val_ref,
2788                    decoder,
2789                    inner_offset,
2790                    inner_depth
2791                )?;
2792                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2793                {
2794                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2795                }
2796                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2797                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2798                }
2799            }
2800
2801            next_offset += envelope_size;
2802            _next_ordinal_to_read += 1;
2803            if next_offset >= end_offset {
2804                return Ok(());
2805            }
2806
2807            // Decode unknown envelopes for gaps in ordinals.
2808            while _next_ordinal_to_read < 4 {
2809                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2810                _next_ordinal_to_read += 1;
2811                next_offset += envelope_size;
2812            }
2813
2814            let next_out_of_line = decoder.next_out_of_line();
2815            let handles_before = decoder.remaining_handles();
2816            if let Some((inlined, num_bytes, num_handles)) =
2817                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2818            {
2819                let member_inline_size =
2820                    <TouchPointerSample as fidl::encoding::TypeMarker>::inline_size(
2821                        decoder.context,
2822                    );
2823                if inlined != (member_inline_size <= 4) {
2824                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2825                }
2826                let inner_offset;
2827                let mut inner_depth = depth.clone();
2828                if inlined {
2829                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2830                    inner_offset = next_offset;
2831                } else {
2832                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2833                    inner_depth.increment()?;
2834                }
2835                let val_ref = self.pointer_sample.get_or_insert_with(|| {
2836                    fidl::new_empty!(
2837                        TouchPointerSample,
2838                        fidl::encoding::DefaultFuchsiaResourceDialect
2839                    )
2840                });
2841                fidl::decode!(
2842                    TouchPointerSample,
2843                    fidl::encoding::DefaultFuchsiaResourceDialect,
2844                    val_ref,
2845                    decoder,
2846                    inner_offset,
2847                    inner_depth
2848                )?;
2849                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2850                {
2851                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2852                }
2853                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2854                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2855                }
2856            }
2857
2858            next_offset += envelope_size;
2859            _next_ordinal_to_read += 1;
2860            if next_offset >= end_offset {
2861                return Ok(());
2862            }
2863
2864            // Decode unknown envelopes for gaps in ordinals.
2865            while _next_ordinal_to_read < 5 {
2866                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2867                _next_ordinal_to_read += 1;
2868                next_offset += envelope_size;
2869            }
2870
2871            let next_out_of_line = decoder.next_out_of_line();
2872            let handles_before = decoder.remaining_handles();
2873            if let Some((inlined, num_bytes, num_handles)) =
2874                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2875            {
2876                let member_inline_size =
2877                    <TouchInteractionResult as fidl::encoding::TypeMarker>::inline_size(
2878                        decoder.context,
2879                    );
2880                if inlined != (member_inline_size <= 4) {
2881                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2882                }
2883                let inner_offset;
2884                let mut inner_depth = depth.clone();
2885                if inlined {
2886                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2887                    inner_offset = next_offset;
2888                } else {
2889                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2890                    inner_depth.increment()?;
2891                }
2892                let val_ref = self.interaction_result.get_or_insert_with(|| {
2893                    fidl::new_empty!(
2894                        TouchInteractionResult,
2895                        fidl::encoding::DefaultFuchsiaResourceDialect
2896                    )
2897                });
2898                fidl::decode!(
2899                    TouchInteractionResult,
2900                    fidl::encoding::DefaultFuchsiaResourceDialect,
2901                    val_ref,
2902                    decoder,
2903                    inner_offset,
2904                    inner_depth
2905                )?;
2906                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2907                {
2908                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2909                }
2910                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2911                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2912                }
2913            }
2914
2915            next_offset += envelope_size;
2916            _next_ordinal_to_read += 1;
2917            if next_offset >= end_offset {
2918                return Ok(());
2919            }
2920
2921            // Decode unknown envelopes for gaps in ordinals.
2922            while _next_ordinal_to_read < 6 {
2923                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2924                _next_ordinal_to_read += 1;
2925                next_offset += envelope_size;
2926            }
2927
2928            let next_out_of_line = decoder.next_out_of_line();
2929            let handles_before = decoder.remaining_handles();
2930            if let Some((inlined, num_bytes, num_handles)) =
2931                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2932            {
2933                let member_inline_size =
2934                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2935                if inlined != (member_inline_size <= 4) {
2936                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2937                }
2938                let inner_offset;
2939                let mut inner_depth = depth.clone();
2940                if inlined {
2941                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2942                    inner_offset = next_offset;
2943                } else {
2944                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2945                    inner_depth.increment()?;
2946                }
2947                let val_ref = self.trace_flow_id.get_or_insert_with(|| {
2948                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2949                });
2950                fidl::decode!(
2951                    u64,
2952                    fidl::encoding::DefaultFuchsiaResourceDialect,
2953                    val_ref,
2954                    decoder,
2955                    inner_offset,
2956                    inner_depth
2957                )?;
2958                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2959                {
2960                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2961                }
2962                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2963                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2964                }
2965            }
2966
2967            next_offset += envelope_size;
2968            _next_ordinal_to_read += 1;
2969            if next_offset >= end_offset {
2970                return Ok(());
2971            }
2972
2973            // Decode unknown envelopes for gaps in ordinals.
2974            while _next_ordinal_to_read < 7 {
2975                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2976                _next_ordinal_to_read += 1;
2977                next_offset += envelope_size;
2978            }
2979
2980            let next_out_of_line = decoder.next_out_of_line();
2981            let handles_before = decoder.remaining_handles();
2982            if let Some((inlined, num_bytes, num_handles)) =
2983                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2984            {
2985                let member_inline_size = <fidl::encoding::HandleType<
2986                    fidl::EventPair,
2987                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2988                    2147483648,
2989                > as fidl::encoding::TypeMarker>::inline_size(
2990                    decoder.context
2991                );
2992                if inlined != (member_inline_size <= 4) {
2993                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2994                }
2995                let inner_offset;
2996                let mut inner_depth = depth.clone();
2997                if inlined {
2998                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2999                    inner_offset = next_offset;
3000                } else {
3001                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3002                    inner_depth.increment()?;
3003                }
3004                let val_ref =
3005                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3006                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3007                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3008                {
3009                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3010                }
3011                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3012                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3013                }
3014            }
3015
3016            next_offset += envelope_size;
3017
3018            // Decode the remaining unknown envelopes.
3019            while next_offset < end_offset {
3020                _next_ordinal_to_read += 1;
3021                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3022                next_offset += envelope_size;
3023            }
3024
3025            Ok(())
3026        }
3027    }
3028}