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