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