Skip to main content

fidl_fuchsia_ui_pointer/
fidl_fuchsia_ui_pointer.rs

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