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