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