1#![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 RegistryRegisterRequest {
16 pub config: Config,
17 pub injector: fidl::endpoints::ServerEnd<DeviceMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RegistryRegisterRequest {}
21
22#[derive(Debug, Default, PartialEq)]
26pub struct Config {
27 pub device_id: Option<u32>,
29 pub device_type: Option<DeviceType>,
31 pub context: Option<Context>,
36 pub target: Option<Target>,
41 pub viewport: Option<Viewport>,
44 pub dispatch_policy: Option<DispatchPolicy>,
51 pub scroll_v_range: Option<fidl_fuchsia_input_report::Axis>,
53 pub scroll_h_range: Option<fidl_fuchsia_input_report::Axis>,
55 pub buttons: Option<Vec<u8>>,
69 pub relative_motion_range: Option<[fidl_fuchsia_input_report::Axis; 2]>,
71 #[doc(hidden)]
72 pub __source_breaking: fidl::marker::SourceBreaking,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Config {}
76
77#[derive(Debug, PartialEq)]
85pub enum Context {
86 View(fidl_fuchsia_ui_views::ViewRef),
90}
91
92impl Context {
93 #[inline]
94 pub fn ordinal(&self) -> u64 {
95 match *self {
96 Self::View(_) => 1,
97 }
98 }
99
100 #[deprecated = "Strict unions should not use `is_unknown`"]
101 #[inline]
102 pub fn is_unknown(&self) -> bool {
103 false
104 }
105}
106
107impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Context {}
108
109#[derive(Debug, PartialEq)]
112pub enum Target {
113 View(fidl_fuchsia_ui_views::ViewRef),
117}
118
119impl Target {
120 #[inline]
121 pub fn ordinal(&self) -> u64 {
122 match *self {
123 Self::View(_) => 1,
124 }
125 }
126
127 #[deprecated = "Strict unions should not use `is_unknown`"]
128 #[inline]
129 pub fn is_unknown(&self) -> bool {
130 false
131 }
132}
133
134impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Target {}
135
136#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
137pub struct DeviceMarker;
138
139impl fidl::endpoints::ProtocolMarker for DeviceMarker {
140 type Proxy = DeviceProxy;
141 type RequestStream = DeviceRequestStream;
142 #[cfg(target_os = "fuchsia")]
143 type SynchronousProxy = DeviceSynchronousProxy;
144
145 const DEBUG_NAME: &'static str = "(anonymous) Device";
146}
147
148pub trait DeviceProxyInterface: Send + Sync {
149 type InjectResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
150 fn r#inject(&self, events: &[Event]) -> Self::InjectResponseFut;
151}
152#[derive(Debug)]
153#[cfg(target_os = "fuchsia")]
154pub struct DeviceSynchronousProxy {
155 client: fidl::client::sync::Client,
156}
157
158#[cfg(target_os = "fuchsia")]
159impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
160 type Proxy = DeviceProxy;
161 type Protocol = DeviceMarker;
162
163 fn from_channel(inner: fidl::Channel) -> Self {
164 Self::new(inner)
165 }
166
167 fn into_channel(self) -> fidl::Channel {
168 self.client.into_channel()
169 }
170
171 fn as_channel(&self) -> &fidl::Channel {
172 self.client.as_channel()
173 }
174}
175
176#[cfg(target_os = "fuchsia")]
177impl DeviceSynchronousProxy {
178 pub fn new(channel: fidl::Channel) -> Self {
179 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
180 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
181 }
182
183 pub fn into_channel(self) -> fidl::Channel {
184 self.client.into_channel()
185 }
186
187 pub fn wait_for_event(
190 &self,
191 deadline: zx::MonotonicInstant,
192 ) -> Result<DeviceEvent, fidl::Error> {
193 DeviceEvent::decode(self.client.wait_for_event(deadline)?)
194 }
195
196 pub fn r#inject(
206 &self,
207 mut events: &[Event],
208 ___deadline: zx::MonotonicInstant,
209 ) -> Result<(), fidl::Error> {
210 let _response =
211 self.client.send_query::<DeviceInjectRequest, fidl::encoding::EmptyPayload>(
212 (events,),
213 0x123882bb65bff40,
214 fidl::encoding::DynamicFlags::empty(),
215 ___deadline,
216 )?;
217 Ok(_response)
218 }
219}
220
221#[cfg(target_os = "fuchsia")]
222impl From<DeviceSynchronousProxy> for zx::Handle {
223 fn from(value: DeviceSynchronousProxy) -> Self {
224 value.into_channel().into()
225 }
226}
227
228#[cfg(target_os = "fuchsia")]
229impl From<fidl::Channel> for DeviceSynchronousProxy {
230 fn from(value: fidl::Channel) -> Self {
231 Self::new(value)
232 }
233}
234
235#[derive(Debug, Clone)]
236pub struct DeviceProxy {
237 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
238}
239
240impl fidl::endpoints::Proxy for DeviceProxy {
241 type Protocol = DeviceMarker;
242
243 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
244 Self::new(inner)
245 }
246
247 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
248 self.client.into_channel().map_err(|client| Self { client })
249 }
250
251 fn as_channel(&self) -> &::fidl::AsyncChannel {
252 self.client.as_channel()
253 }
254}
255
256impl DeviceProxy {
257 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
259 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
260 Self { client: fidl::client::Client::new(channel, protocol_name) }
261 }
262
263 pub fn take_event_stream(&self) -> DeviceEventStream {
269 DeviceEventStream { event_receiver: self.client.take_event_receiver() }
270 }
271
272 pub fn r#inject(
282 &self,
283 mut events: &[Event],
284 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
285 DeviceProxyInterface::r#inject(self, events)
286 }
287}
288
289impl DeviceProxyInterface for DeviceProxy {
290 type InjectResponseFut =
291 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
292 fn r#inject(&self, mut events: &[Event]) -> Self::InjectResponseFut {
293 fn _decode(
294 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
295 ) -> Result<(), fidl::Error> {
296 let _response = fidl::client::decode_transaction_body::<
297 fidl::encoding::EmptyPayload,
298 fidl::encoding::DefaultFuchsiaResourceDialect,
299 0x123882bb65bff40,
300 >(_buf?)?;
301 Ok(_response)
302 }
303 self.client.send_query_and_decode::<DeviceInjectRequest, ()>(
304 (events,),
305 0x123882bb65bff40,
306 fidl::encoding::DynamicFlags::empty(),
307 _decode,
308 )
309 }
310}
311
312pub struct DeviceEventStream {
313 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
314}
315
316impl std::marker::Unpin for DeviceEventStream {}
317
318impl futures::stream::FusedStream for DeviceEventStream {
319 fn is_terminated(&self) -> bool {
320 self.event_receiver.is_terminated()
321 }
322}
323
324impl futures::Stream for DeviceEventStream {
325 type Item = Result<DeviceEvent, fidl::Error>;
326
327 fn poll_next(
328 mut self: std::pin::Pin<&mut Self>,
329 cx: &mut std::task::Context<'_>,
330 ) -> std::task::Poll<Option<Self::Item>> {
331 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
332 &mut self.event_receiver,
333 cx
334 )?) {
335 Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
336 None => std::task::Poll::Ready(None),
337 }
338 }
339}
340
341#[derive(Debug)]
342pub enum DeviceEvent {}
343
344impl DeviceEvent {
345 fn decode(
347 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
348 ) -> Result<DeviceEvent, fidl::Error> {
349 let (bytes, _handles) = buf.split_mut();
350 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
351 debug_assert_eq!(tx_header.tx_id, 0);
352 match tx_header.ordinal {
353 _ => Err(fidl::Error::UnknownOrdinal {
354 ordinal: tx_header.ordinal,
355 protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
356 }),
357 }
358 }
359}
360
361pub struct DeviceRequestStream {
363 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
364 is_terminated: bool,
365}
366
367impl std::marker::Unpin for DeviceRequestStream {}
368
369impl futures::stream::FusedStream for DeviceRequestStream {
370 fn is_terminated(&self) -> bool {
371 self.is_terminated
372 }
373}
374
375impl fidl::endpoints::RequestStream for DeviceRequestStream {
376 type Protocol = DeviceMarker;
377 type ControlHandle = DeviceControlHandle;
378
379 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
380 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
381 }
382
383 fn control_handle(&self) -> Self::ControlHandle {
384 DeviceControlHandle { inner: self.inner.clone() }
385 }
386
387 fn into_inner(
388 self,
389 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
390 {
391 (self.inner, self.is_terminated)
392 }
393
394 fn from_inner(
395 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
396 is_terminated: bool,
397 ) -> Self {
398 Self { inner, is_terminated }
399 }
400}
401
402impl futures::Stream for DeviceRequestStream {
403 type Item = Result<DeviceRequest, fidl::Error>;
404
405 fn poll_next(
406 mut self: std::pin::Pin<&mut Self>,
407 cx: &mut std::task::Context<'_>,
408 ) -> std::task::Poll<Option<Self::Item>> {
409 let this = &mut *self;
410 if this.inner.check_shutdown(cx) {
411 this.is_terminated = true;
412 return std::task::Poll::Ready(None);
413 }
414 if this.is_terminated {
415 panic!("polled DeviceRequestStream after completion");
416 }
417 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
418 |bytes, handles| {
419 match this.inner.channel().read_etc(cx, bytes, handles) {
420 std::task::Poll::Ready(Ok(())) => {}
421 std::task::Poll::Pending => return std::task::Poll::Pending,
422 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
423 this.is_terminated = true;
424 return std::task::Poll::Ready(None);
425 }
426 std::task::Poll::Ready(Err(e)) => {
427 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
428 e.into(),
429 ))))
430 }
431 }
432
433 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
435
436 std::task::Poll::Ready(Some(match header.ordinal {
437 0x123882bb65bff40 => {
438 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
439 let mut req = fidl::new_empty!(
440 DeviceInjectRequest,
441 fidl::encoding::DefaultFuchsiaResourceDialect
442 );
443 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceInjectRequest>(&header, _body_bytes, handles, &mut req)?;
444 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
445 Ok(DeviceRequest::Inject {
446 events: req.events,
447
448 responder: DeviceInjectResponder {
449 control_handle: std::mem::ManuallyDrop::new(control_handle),
450 tx_id: header.tx_id,
451 },
452 })
453 }
454 _ => Err(fidl::Error::UnknownOrdinal {
455 ordinal: header.ordinal,
456 protocol_name:
457 <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
458 }),
459 }))
460 },
461 )
462 }
463}
464
465#[derive(Debug)]
472pub enum DeviceRequest {
473 Inject { events: Vec<Event>, responder: DeviceInjectResponder },
483}
484
485impl DeviceRequest {
486 #[allow(irrefutable_let_patterns)]
487 pub fn into_inject(self) -> Option<(Vec<Event>, DeviceInjectResponder)> {
488 if let DeviceRequest::Inject { events, responder } = self {
489 Some((events, responder))
490 } else {
491 None
492 }
493 }
494
495 pub fn method_name(&self) -> &'static str {
497 match *self {
498 DeviceRequest::Inject { .. } => "inject",
499 }
500 }
501}
502
503#[derive(Debug, Clone)]
504pub struct DeviceControlHandle {
505 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
506}
507
508impl fidl::endpoints::ControlHandle for DeviceControlHandle {
509 fn shutdown(&self) {
510 self.inner.shutdown()
511 }
512 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
513 self.inner.shutdown_with_epitaph(status)
514 }
515
516 fn is_closed(&self) -> bool {
517 self.inner.channel().is_closed()
518 }
519 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
520 self.inner.channel().on_closed()
521 }
522
523 #[cfg(target_os = "fuchsia")]
524 fn signal_peer(
525 &self,
526 clear_mask: zx::Signals,
527 set_mask: zx::Signals,
528 ) -> Result<(), zx_status::Status> {
529 use fidl::Peered;
530 self.inner.channel().signal_peer(clear_mask, set_mask)
531 }
532}
533
534impl DeviceControlHandle {}
535
536#[must_use = "FIDL methods require a response to be sent"]
537#[derive(Debug)]
538pub struct DeviceInjectResponder {
539 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
540 tx_id: u32,
541}
542
543impl std::ops::Drop for DeviceInjectResponder {
547 fn drop(&mut self) {
548 self.control_handle.shutdown();
549 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
551 }
552}
553
554impl fidl::endpoints::Responder for DeviceInjectResponder {
555 type ControlHandle = DeviceControlHandle;
556
557 fn control_handle(&self) -> &DeviceControlHandle {
558 &self.control_handle
559 }
560
561 fn drop_without_shutdown(mut self) {
562 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
564 std::mem::forget(self);
566 }
567}
568
569impl DeviceInjectResponder {
570 pub fn send(self) -> Result<(), fidl::Error> {
574 let _result = self.send_raw();
575 if _result.is_err() {
576 self.control_handle.shutdown();
577 }
578 self.drop_without_shutdown();
579 _result
580 }
581
582 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
584 let _result = self.send_raw();
585 self.drop_without_shutdown();
586 _result
587 }
588
589 fn send_raw(&self) -> Result<(), fidl::Error> {
590 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
591 (),
592 self.tx_id,
593 0x123882bb65bff40,
594 fidl::encoding::DynamicFlags::empty(),
595 )
596 }
597}
598
599#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
600pub struct RegistryMarker;
601
602impl fidl::endpoints::ProtocolMarker for RegistryMarker {
603 type Proxy = RegistryProxy;
604 type RequestStream = RegistryRequestStream;
605 #[cfg(target_os = "fuchsia")]
606 type SynchronousProxy = RegistrySynchronousProxy;
607
608 const DEBUG_NAME: &'static str = "fuchsia.ui.pointerinjector.Registry";
609}
610impl fidl::endpoints::DiscoverableProtocolMarker for RegistryMarker {}
611
612pub trait RegistryProxyInterface: Send + Sync {
613 type RegisterResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
614 fn r#register(
615 &self,
616 config: Config,
617 injector: fidl::endpoints::ServerEnd<DeviceMarker>,
618 ) -> Self::RegisterResponseFut;
619}
620#[derive(Debug)]
621#[cfg(target_os = "fuchsia")]
622pub struct RegistrySynchronousProxy {
623 client: fidl::client::sync::Client,
624}
625
626#[cfg(target_os = "fuchsia")]
627impl fidl::endpoints::SynchronousProxy for RegistrySynchronousProxy {
628 type Proxy = RegistryProxy;
629 type Protocol = RegistryMarker;
630
631 fn from_channel(inner: fidl::Channel) -> Self {
632 Self::new(inner)
633 }
634
635 fn into_channel(self) -> fidl::Channel {
636 self.client.into_channel()
637 }
638
639 fn as_channel(&self) -> &fidl::Channel {
640 self.client.as_channel()
641 }
642}
643
644#[cfg(target_os = "fuchsia")]
645impl RegistrySynchronousProxy {
646 pub fn new(channel: fidl::Channel) -> Self {
647 let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
648 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
649 }
650
651 pub fn into_channel(self) -> fidl::Channel {
652 self.client.into_channel()
653 }
654
655 pub fn wait_for_event(
658 &self,
659 deadline: zx::MonotonicInstant,
660 ) -> Result<RegistryEvent, fidl::Error> {
661 RegistryEvent::decode(self.client.wait_for_event(deadline)?)
662 }
663
664 pub fn r#register(
674 &self,
675 mut config: Config,
676 mut injector: fidl::endpoints::ServerEnd<DeviceMarker>,
677 ___deadline: zx::MonotonicInstant,
678 ) -> Result<(), fidl::Error> {
679 let _response =
680 self.client.send_query::<RegistryRegisterRequest, fidl::encoding::EmptyPayload>(
681 (&mut config, injector),
682 0x9f8410fe7326a00,
683 fidl::encoding::DynamicFlags::empty(),
684 ___deadline,
685 )?;
686 Ok(_response)
687 }
688}
689
690#[cfg(target_os = "fuchsia")]
691impl From<RegistrySynchronousProxy> for zx::Handle {
692 fn from(value: RegistrySynchronousProxy) -> Self {
693 value.into_channel().into()
694 }
695}
696
697#[cfg(target_os = "fuchsia")]
698impl From<fidl::Channel> for RegistrySynchronousProxy {
699 fn from(value: fidl::Channel) -> Self {
700 Self::new(value)
701 }
702}
703
704#[derive(Debug, Clone)]
705pub struct RegistryProxy {
706 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
707}
708
709impl fidl::endpoints::Proxy for RegistryProxy {
710 type Protocol = RegistryMarker;
711
712 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
713 Self::new(inner)
714 }
715
716 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
717 self.client.into_channel().map_err(|client| Self { client })
718 }
719
720 fn as_channel(&self) -> &::fidl::AsyncChannel {
721 self.client.as_channel()
722 }
723}
724
725impl RegistryProxy {
726 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
728 let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
729 Self { client: fidl::client::Client::new(channel, protocol_name) }
730 }
731
732 pub fn take_event_stream(&self) -> RegistryEventStream {
738 RegistryEventStream { event_receiver: self.client.take_event_receiver() }
739 }
740
741 pub fn r#register(
751 &self,
752 mut config: Config,
753 mut injector: fidl::endpoints::ServerEnd<DeviceMarker>,
754 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
755 RegistryProxyInterface::r#register(self, config, injector)
756 }
757}
758
759impl RegistryProxyInterface for RegistryProxy {
760 type RegisterResponseFut =
761 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
762 fn r#register(
763 &self,
764 mut config: Config,
765 mut injector: fidl::endpoints::ServerEnd<DeviceMarker>,
766 ) -> Self::RegisterResponseFut {
767 fn _decode(
768 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
769 ) -> Result<(), fidl::Error> {
770 let _response = fidl::client::decode_transaction_body::<
771 fidl::encoding::EmptyPayload,
772 fidl::encoding::DefaultFuchsiaResourceDialect,
773 0x9f8410fe7326a00,
774 >(_buf?)?;
775 Ok(_response)
776 }
777 self.client.send_query_and_decode::<RegistryRegisterRequest, ()>(
778 (&mut config, injector),
779 0x9f8410fe7326a00,
780 fidl::encoding::DynamicFlags::empty(),
781 _decode,
782 )
783 }
784}
785
786pub struct RegistryEventStream {
787 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
788}
789
790impl std::marker::Unpin for RegistryEventStream {}
791
792impl futures::stream::FusedStream for RegistryEventStream {
793 fn is_terminated(&self) -> bool {
794 self.event_receiver.is_terminated()
795 }
796}
797
798impl futures::Stream for RegistryEventStream {
799 type Item = Result<RegistryEvent, fidl::Error>;
800
801 fn poll_next(
802 mut self: std::pin::Pin<&mut Self>,
803 cx: &mut std::task::Context<'_>,
804 ) -> std::task::Poll<Option<Self::Item>> {
805 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
806 &mut self.event_receiver,
807 cx
808 )?) {
809 Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
810 None => std::task::Poll::Ready(None),
811 }
812 }
813}
814
815#[derive(Debug)]
816pub enum RegistryEvent {}
817
818impl RegistryEvent {
819 fn decode(
821 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
822 ) -> Result<RegistryEvent, fidl::Error> {
823 let (bytes, _handles) = buf.split_mut();
824 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
825 debug_assert_eq!(tx_header.tx_id, 0);
826 match tx_header.ordinal {
827 _ => Err(fidl::Error::UnknownOrdinal {
828 ordinal: tx_header.ordinal,
829 protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
830 }),
831 }
832 }
833}
834
835pub struct RegistryRequestStream {
837 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
838 is_terminated: bool,
839}
840
841impl std::marker::Unpin for RegistryRequestStream {}
842
843impl futures::stream::FusedStream for RegistryRequestStream {
844 fn is_terminated(&self) -> bool {
845 self.is_terminated
846 }
847}
848
849impl fidl::endpoints::RequestStream for RegistryRequestStream {
850 type Protocol = RegistryMarker;
851 type ControlHandle = RegistryControlHandle;
852
853 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
854 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
855 }
856
857 fn control_handle(&self) -> Self::ControlHandle {
858 RegistryControlHandle { inner: self.inner.clone() }
859 }
860
861 fn into_inner(
862 self,
863 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
864 {
865 (self.inner, self.is_terminated)
866 }
867
868 fn from_inner(
869 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
870 is_terminated: bool,
871 ) -> Self {
872 Self { inner, is_terminated }
873 }
874}
875
876impl futures::Stream for RegistryRequestStream {
877 type Item = Result<RegistryRequest, fidl::Error>;
878
879 fn poll_next(
880 mut self: std::pin::Pin<&mut Self>,
881 cx: &mut std::task::Context<'_>,
882 ) -> std::task::Poll<Option<Self::Item>> {
883 let this = &mut *self;
884 if this.inner.check_shutdown(cx) {
885 this.is_terminated = true;
886 return std::task::Poll::Ready(None);
887 }
888 if this.is_terminated {
889 panic!("polled RegistryRequestStream after completion");
890 }
891 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
892 |bytes, handles| {
893 match this.inner.channel().read_etc(cx, bytes, handles) {
894 std::task::Poll::Ready(Ok(())) => {}
895 std::task::Poll::Pending => return std::task::Poll::Pending,
896 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
897 this.is_terminated = true;
898 return std::task::Poll::Ready(None);
899 }
900 std::task::Poll::Ready(Err(e)) => {
901 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
902 e.into(),
903 ))))
904 }
905 }
906
907 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
909
910 std::task::Poll::Ready(Some(match header.ordinal {
911 0x9f8410fe7326a00 => {
912 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
913 let mut req = fidl::new_empty!(
914 RegistryRegisterRequest,
915 fidl::encoding::DefaultFuchsiaResourceDialect
916 );
917 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
918 let control_handle = RegistryControlHandle { inner: this.inner.clone() };
919 Ok(RegistryRequest::Register {
920 config: req.config,
921 injector: req.injector,
922
923 responder: RegistryRegisterResponder {
924 control_handle: std::mem::ManuallyDrop::new(control_handle),
925 tx_id: header.tx_id,
926 },
927 })
928 }
929 _ => Err(fidl::Error::UnknownOrdinal {
930 ordinal: header.ordinal,
931 protocol_name:
932 <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
933 }),
934 }))
935 },
936 )
937 }
938}
939
940#[derive(Debug)]
989pub enum RegistryRequest {
990 Register {
1000 config: Config,
1001 injector: fidl::endpoints::ServerEnd<DeviceMarker>,
1002 responder: RegistryRegisterResponder,
1003 },
1004}
1005
1006impl RegistryRequest {
1007 #[allow(irrefutable_let_patterns)]
1008 pub fn into_register(
1009 self,
1010 ) -> Option<(Config, fidl::endpoints::ServerEnd<DeviceMarker>, RegistryRegisterResponder)> {
1011 if let RegistryRequest::Register { config, injector, responder } = self {
1012 Some((config, injector, responder))
1013 } else {
1014 None
1015 }
1016 }
1017
1018 pub fn method_name(&self) -> &'static str {
1020 match *self {
1021 RegistryRequest::Register { .. } => "register",
1022 }
1023 }
1024}
1025
1026#[derive(Debug, Clone)]
1027pub struct RegistryControlHandle {
1028 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1029}
1030
1031impl fidl::endpoints::ControlHandle for RegistryControlHandle {
1032 fn shutdown(&self) {
1033 self.inner.shutdown()
1034 }
1035 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1036 self.inner.shutdown_with_epitaph(status)
1037 }
1038
1039 fn is_closed(&self) -> bool {
1040 self.inner.channel().is_closed()
1041 }
1042 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1043 self.inner.channel().on_closed()
1044 }
1045
1046 #[cfg(target_os = "fuchsia")]
1047 fn signal_peer(
1048 &self,
1049 clear_mask: zx::Signals,
1050 set_mask: zx::Signals,
1051 ) -> Result<(), zx_status::Status> {
1052 use fidl::Peered;
1053 self.inner.channel().signal_peer(clear_mask, set_mask)
1054 }
1055}
1056
1057impl RegistryControlHandle {}
1058
1059#[must_use = "FIDL methods require a response to be sent"]
1060#[derive(Debug)]
1061pub struct RegistryRegisterResponder {
1062 control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
1063 tx_id: u32,
1064}
1065
1066impl std::ops::Drop for RegistryRegisterResponder {
1070 fn drop(&mut self) {
1071 self.control_handle.shutdown();
1072 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1074 }
1075}
1076
1077impl fidl::endpoints::Responder for RegistryRegisterResponder {
1078 type ControlHandle = RegistryControlHandle;
1079
1080 fn control_handle(&self) -> &RegistryControlHandle {
1081 &self.control_handle
1082 }
1083
1084 fn drop_without_shutdown(mut self) {
1085 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1087 std::mem::forget(self);
1089 }
1090}
1091
1092impl RegistryRegisterResponder {
1093 pub fn send(self) -> Result<(), fidl::Error> {
1097 let _result = self.send_raw();
1098 if _result.is_err() {
1099 self.control_handle.shutdown();
1100 }
1101 self.drop_without_shutdown();
1102 _result
1103 }
1104
1105 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1107 let _result = self.send_raw();
1108 self.drop_without_shutdown();
1109 _result
1110 }
1111
1112 fn send_raw(&self) -> Result<(), fidl::Error> {
1113 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1114 (),
1115 self.tx_id,
1116 0x9f8410fe7326a00,
1117 fidl::encoding::DynamicFlags::empty(),
1118 )
1119 }
1120}
1121
1122mod internal {
1123 use super::*;
1124
1125 impl fidl::encoding::ResourceTypeMarker for RegistryRegisterRequest {
1126 type Borrowed<'a> = &'a mut Self;
1127 fn take_or_borrow<'a>(
1128 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1129 ) -> Self::Borrowed<'a> {
1130 value
1131 }
1132 }
1133
1134 unsafe impl fidl::encoding::TypeMarker for RegistryRegisterRequest {
1135 type Owned = Self;
1136
1137 #[inline(always)]
1138 fn inline_align(_context: fidl::encoding::Context) -> usize {
1139 8
1140 }
1141
1142 #[inline(always)]
1143 fn inline_size(_context: fidl::encoding::Context) -> usize {
1144 24
1145 }
1146 }
1147
1148 unsafe impl
1149 fidl::encoding::Encode<
1150 RegistryRegisterRequest,
1151 fidl::encoding::DefaultFuchsiaResourceDialect,
1152 > for &mut RegistryRegisterRequest
1153 {
1154 #[inline]
1155 unsafe fn encode(
1156 self,
1157 encoder: &mut fidl::encoding::Encoder<
1158 '_,
1159 fidl::encoding::DefaultFuchsiaResourceDialect,
1160 >,
1161 offset: usize,
1162 _depth: fidl::encoding::Depth,
1163 ) -> fidl::Result<()> {
1164 encoder.debug_check_bounds::<RegistryRegisterRequest>(offset);
1165 fidl::encoding::Encode::<RegistryRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1167 (
1168 <Config as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.config),
1169 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.injector),
1170 ),
1171 encoder, offset, _depth
1172 )
1173 }
1174 }
1175 unsafe impl<
1176 T0: fidl::encoding::Encode<Config, fidl::encoding::DefaultFuchsiaResourceDialect>,
1177 T1: fidl::encoding::Encode<
1178 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1179 fidl::encoding::DefaultFuchsiaResourceDialect,
1180 >,
1181 >
1182 fidl::encoding::Encode<
1183 RegistryRegisterRequest,
1184 fidl::encoding::DefaultFuchsiaResourceDialect,
1185 > for (T0, T1)
1186 {
1187 #[inline]
1188 unsafe fn encode(
1189 self,
1190 encoder: &mut fidl::encoding::Encoder<
1191 '_,
1192 fidl::encoding::DefaultFuchsiaResourceDialect,
1193 >,
1194 offset: usize,
1195 depth: fidl::encoding::Depth,
1196 ) -> fidl::Result<()> {
1197 encoder.debug_check_bounds::<RegistryRegisterRequest>(offset);
1198 unsafe {
1201 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1202 (ptr as *mut u64).write_unaligned(0);
1203 }
1204 self.0.encode(encoder, offset + 0, depth)?;
1206 self.1.encode(encoder, offset + 16, depth)?;
1207 Ok(())
1208 }
1209 }
1210
1211 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1212 for RegistryRegisterRequest
1213 {
1214 #[inline(always)]
1215 fn new_empty() -> Self {
1216 Self {
1217 config: fidl::new_empty!(Config, fidl::encoding::DefaultFuchsiaResourceDialect),
1218 injector: fidl::new_empty!(
1219 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1220 fidl::encoding::DefaultFuchsiaResourceDialect
1221 ),
1222 }
1223 }
1224
1225 #[inline]
1226 unsafe fn decode(
1227 &mut self,
1228 decoder: &mut fidl::encoding::Decoder<
1229 '_,
1230 fidl::encoding::DefaultFuchsiaResourceDialect,
1231 >,
1232 offset: usize,
1233 _depth: fidl::encoding::Depth,
1234 ) -> fidl::Result<()> {
1235 decoder.debug_check_bounds::<Self>(offset);
1236 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1238 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1239 let mask = 0xffffffff00000000u64;
1240 let maskedval = padval & mask;
1241 if maskedval != 0 {
1242 return Err(fidl::Error::NonZeroPadding {
1243 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1244 });
1245 }
1246 fidl::decode!(
1247 Config,
1248 fidl::encoding::DefaultFuchsiaResourceDialect,
1249 &mut self.config,
1250 decoder,
1251 offset + 0,
1252 _depth
1253 )?;
1254 fidl::decode!(
1255 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1256 fidl::encoding::DefaultFuchsiaResourceDialect,
1257 &mut self.injector,
1258 decoder,
1259 offset + 16,
1260 _depth
1261 )?;
1262 Ok(())
1263 }
1264 }
1265
1266 impl Config {
1267 #[inline(always)]
1268 fn max_ordinal_present(&self) -> u64 {
1269 if let Some(_) = self.relative_motion_range {
1270 return 10;
1271 }
1272 if let Some(_) = self.buttons {
1273 return 9;
1274 }
1275 if let Some(_) = self.scroll_h_range {
1276 return 8;
1277 }
1278 if let Some(_) = self.scroll_v_range {
1279 return 7;
1280 }
1281 if let Some(_) = self.dispatch_policy {
1282 return 6;
1283 }
1284 if let Some(_) = self.viewport {
1285 return 5;
1286 }
1287 if let Some(_) = self.target {
1288 return 4;
1289 }
1290 if let Some(_) = self.context {
1291 return 3;
1292 }
1293 if let Some(_) = self.device_type {
1294 return 2;
1295 }
1296 if let Some(_) = self.device_id {
1297 return 1;
1298 }
1299 0
1300 }
1301 }
1302
1303 impl fidl::encoding::ResourceTypeMarker for Config {
1304 type Borrowed<'a> = &'a mut Self;
1305 fn take_or_borrow<'a>(
1306 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1307 ) -> Self::Borrowed<'a> {
1308 value
1309 }
1310 }
1311
1312 unsafe impl fidl::encoding::TypeMarker for Config {
1313 type Owned = Self;
1314
1315 #[inline(always)]
1316 fn inline_align(_context: fidl::encoding::Context) -> usize {
1317 8
1318 }
1319
1320 #[inline(always)]
1321 fn inline_size(_context: fidl::encoding::Context) -> usize {
1322 16
1323 }
1324 }
1325
1326 unsafe impl fidl::encoding::Encode<Config, fidl::encoding::DefaultFuchsiaResourceDialect>
1327 for &mut Config
1328 {
1329 unsafe fn encode(
1330 self,
1331 encoder: &mut fidl::encoding::Encoder<
1332 '_,
1333 fidl::encoding::DefaultFuchsiaResourceDialect,
1334 >,
1335 offset: usize,
1336 mut depth: fidl::encoding::Depth,
1337 ) -> fidl::Result<()> {
1338 encoder.debug_check_bounds::<Config>(offset);
1339 let max_ordinal: u64 = self.max_ordinal_present();
1341 encoder.write_num(max_ordinal, offset);
1342 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1343 if max_ordinal == 0 {
1345 return Ok(());
1346 }
1347 depth.increment()?;
1348 let envelope_size = 8;
1349 let bytes_len = max_ordinal as usize * envelope_size;
1350 #[allow(unused_variables)]
1351 let offset = encoder.out_of_line_offset(bytes_len);
1352 let mut _prev_end_offset: usize = 0;
1353 if 1 > max_ordinal {
1354 return Ok(());
1355 }
1356
1357 let cur_offset: usize = (1 - 1) * envelope_size;
1360
1361 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1363
1364 fidl::encoding::encode_in_envelope_optional::<
1369 u32,
1370 fidl::encoding::DefaultFuchsiaResourceDialect,
1371 >(
1372 self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1373 encoder,
1374 offset + cur_offset,
1375 depth,
1376 )?;
1377
1378 _prev_end_offset = cur_offset + envelope_size;
1379 if 2 > max_ordinal {
1380 return Ok(());
1381 }
1382
1383 let cur_offset: usize = (2 - 1) * envelope_size;
1386
1387 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1389
1390 fidl::encoding::encode_in_envelope_optional::<
1395 DeviceType,
1396 fidl::encoding::DefaultFuchsiaResourceDialect,
1397 >(
1398 self.device_type
1399 .as_ref()
1400 .map(<DeviceType as fidl::encoding::ValueTypeMarker>::borrow),
1401 encoder,
1402 offset + cur_offset,
1403 depth,
1404 )?;
1405
1406 _prev_end_offset = cur_offset + envelope_size;
1407 if 3 > max_ordinal {
1408 return Ok(());
1409 }
1410
1411 let cur_offset: usize = (3 - 1) * envelope_size;
1414
1415 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1417
1418 fidl::encoding::encode_in_envelope_optional::<
1423 Context,
1424 fidl::encoding::DefaultFuchsiaResourceDialect,
1425 >(
1426 self.context
1427 .as_mut()
1428 .map(<Context as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1429 encoder,
1430 offset + cur_offset,
1431 depth,
1432 )?;
1433
1434 _prev_end_offset = cur_offset + envelope_size;
1435 if 4 > max_ordinal {
1436 return Ok(());
1437 }
1438
1439 let cur_offset: usize = (4 - 1) * envelope_size;
1442
1443 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1445
1446 fidl::encoding::encode_in_envelope_optional::<
1451 Target,
1452 fidl::encoding::DefaultFuchsiaResourceDialect,
1453 >(
1454 self.target
1455 .as_mut()
1456 .map(<Target as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1457 encoder,
1458 offset + cur_offset,
1459 depth,
1460 )?;
1461
1462 _prev_end_offset = cur_offset + envelope_size;
1463 if 5 > max_ordinal {
1464 return Ok(());
1465 }
1466
1467 let cur_offset: usize = (5 - 1) * envelope_size;
1470
1471 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1473
1474 fidl::encoding::encode_in_envelope_optional::<
1479 Viewport,
1480 fidl::encoding::DefaultFuchsiaResourceDialect,
1481 >(
1482 self.viewport.as_ref().map(<Viewport as fidl::encoding::ValueTypeMarker>::borrow),
1483 encoder,
1484 offset + cur_offset,
1485 depth,
1486 )?;
1487
1488 _prev_end_offset = cur_offset + envelope_size;
1489 if 6 > max_ordinal {
1490 return Ok(());
1491 }
1492
1493 let cur_offset: usize = (6 - 1) * envelope_size;
1496
1497 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1499
1500 fidl::encoding::encode_in_envelope_optional::<
1505 DispatchPolicy,
1506 fidl::encoding::DefaultFuchsiaResourceDialect,
1507 >(
1508 self.dispatch_policy
1509 .as_ref()
1510 .map(<DispatchPolicy as fidl::encoding::ValueTypeMarker>::borrow),
1511 encoder,
1512 offset + cur_offset,
1513 depth,
1514 )?;
1515
1516 _prev_end_offset = cur_offset + envelope_size;
1517 if 7 > max_ordinal {
1518 return Ok(());
1519 }
1520
1521 let cur_offset: usize = (7 - 1) * envelope_size;
1524
1525 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1527
1528 fidl::encoding::encode_in_envelope_optional::<
1533 fidl_fuchsia_input_report::Axis,
1534 fidl::encoding::DefaultFuchsiaResourceDialect,
1535 >(
1536 self.scroll_v_range.as_ref().map(
1537 <fidl_fuchsia_input_report::Axis as fidl::encoding::ValueTypeMarker>::borrow,
1538 ),
1539 encoder,
1540 offset + cur_offset,
1541 depth,
1542 )?;
1543
1544 _prev_end_offset = cur_offset + envelope_size;
1545 if 8 > max_ordinal {
1546 return Ok(());
1547 }
1548
1549 let cur_offset: usize = (8 - 1) * envelope_size;
1552
1553 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1555
1556 fidl::encoding::encode_in_envelope_optional::<
1561 fidl_fuchsia_input_report::Axis,
1562 fidl::encoding::DefaultFuchsiaResourceDialect,
1563 >(
1564 self.scroll_h_range.as_ref().map(
1565 <fidl_fuchsia_input_report::Axis as fidl::encoding::ValueTypeMarker>::borrow,
1566 ),
1567 encoder,
1568 offset + cur_offset,
1569 depth,
1570 )?;
1571
1572 _prev_end_offset = cur_offset + envelope_size;
1573 if 9 > max_ordinal {
1574 return Ok(());
1575 }
1576
1577 let cur_offset: usize = (9 - 1) * envelope_size;
1580
1581 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1583
1584 fidl::encoding::encode_in_envelope_optional::<
1589 fidl::encoding::Vector<u8, 32>,
1590 fidl::encoding::DefaultFuchsiaResourceDialect,
1591 >(
1592 self.buttons.as_ref().map(
1593 <fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow,
1594 ),
1595 encoder,
1596 offset + cur_offset,
1597 depth,
1598 )?;
1599
1600 _prev_end_offset = cur_offset + envelope_size;
1601 if 10 > max_ordinal {
1602 return Ok(());
1603 }
1604
1605 let cur_offset: usize = (10 - 1) * envelope_size;
1608
1609 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1611
1612 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Array<fidl_fuchsia_input_report::Axis, 2>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1617 self.relative_motion_range.as_ref().map(<fidl::encoding::Array<fidl_fuchsia_input_report::Axis, 2> as fidl::encoding::ValueTypeMarker>::borrow),
1618 encoder, offset + cur_offset, depth
1619 )?;
1620
1621 _prev_end_offset = cur_offset + envelope_size;
1622
1623 Ok(())
1624 }
1625 }
1626
1627 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Config {
1628 #[inline(always)]
1629 fn new_empty() -> Self {
1630 Self::default()
1631 }
1632
1633 unsafe fn decode(
1634 &mut self,
1635 decoder: &mut fidl::encoding::Decoder<
1636 '_,
1637 fidl::encoding::DefaultFuchsiaResourceDialect,
1638 >,
1639 offset: usize,
1640 mut depth: fidl::encoding::Depth,
1641 ) -> fidl::Result<()> {
1642 decoder.debug_check_bounds::<Self>(offset);
1643 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1644 None => return Err(fidl::Error::NotNullable),
1645 Some(len) => len,
1646 };
1647 if len == 0 {
1649 return Ok(());
1650 };
1651 depth.increment()?;
1652 let envelope_size = 8;
1653 let bytes_len = len * envelope_size;
1654 let offset = decoder.out_of_line_offset(bytes_len)?;
1655 let mut _next_ordinal_to_read = 0;
1657 let mut next_offset = offset;
1658 let end_offset = offset + bytes_len;
1659 _next_ordinal_to_read += 1;
1660 if next_offset >= end_offset {
1661 return Ok(());
1662 }
1663
1664 while _next_ordinal_to_read < 1 {
1666 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1667 _next_ordinal_to_read += 1;
1668 next_offset += envelope_size;
1669 }
1670
1671 let next_out_of_line = decoder.next_out_of_line();
1672 let handles_before = decoder.remaining_handles();
1673 if let Some((inlined, num_bytes, num_handles)) =
1674 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1675 {
1676 let member_inline_size =
1677 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1678 if inlined != (member_inline_size <= 4) {
1679 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1680 }
1681 let inner_offset;
1682 let mut inner_depth = depth.clone();
1683 if inlined {
1684 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1685 inner_offset = next_offset;
1686 } else {
1687 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1688 inner_depth.increment()?;
1689 }
1690 let val_ref = self.device_id.get_or_insert_with(|| {
1691 fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1692 });
1693 fidl::decode!(
1694 u32,
1695 fidl::encoding::DefaultFuchsiaResourceDialect,
1696 val_ref,
1697 decoder,
1698 inner_offset,
1699 inner_depth
1700 )?;
1701 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1702 {
1703 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1704 }
1705 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1706 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1707 }
1708 }
1709
1710 next_offset += envelope_size;
1711 _next_ordinal_to_read += 1;
1712 if next_offset >= end_offset {
1713 return Ok(());
1714 }
1715
1716 while _next_ordinal_to_read < 2 {
1718 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1719 _next_ordinal_to_read += 1;
1720 next_offset += envelope_size;
1721 }
1722
1723 let next_out_of_line = decoder.next_out_of_line();
1724 let handles_before = decoder.remaining_handles();
1725 if let Some((inlined, num_bytes, num_handles)) =
1726 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1727 {
1728 let member_inline_size =
1729 <DeviceType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1730 if inlined != (member_inline_size <= 4) {
1731 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1732 }
1733 let inner_offset;
1734 let mut inner_depth = depth.clone();
1735 if inlined {
1736 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1737 inner_offset = next_offset;
1738 } else {
1739 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1740 inner_depth.increment()?;
1741 }
1742 let val_ref = self.device_type.get_or_insert_with(|| {
1743 fidl::new_empty!(DeviceType, fidl::encoding::DefaultFuchsiaResourceDialect)
1744 });
1745 fidl::decode!(
1746 DeviceType,
1747 fidl::encoding::DefaultFuchsiaResourceDialect,
1748 val_ref,
1749 decoder,
1750 inner_offset,
1751 inner_depth
1752 )?;
1753 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1754 {
1755 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1756 }
1757 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1758 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1759 }
1760 }
1761
1762 next_offset += envelope_size;
1763 _next_ordinal_to_read += 1;
1764 if next_offset >= end_offset {
1765 return Ok(());
1766 }
1767
1768 while _next_ordinal_to_read < 3 {
1770 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1771 _next_ordinal_to_read += 1;
1772 next_offset += envelope_size;
1773 }
1774
1775 let next_out_of_line = decoder.next_out_of_line();
1776 let handles_before = decoder.remaining_handles();
1777 if let Some((inlined, num_bytes, num_handles)) =
1778 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1779 {
1780 let member_inline_size =
1781 <Context as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1782 if inlined != (member_inline_size <= 4) {
1783 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1784 }
1785 let inner_offset;
1786 let mut inner_depth = depth.clone();
1787 if inlined {
1788 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1789 inner_offset = next_offset;
1790 } else {
1791 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1792 inner_depth.increment()?;
1793 }
1794 let val_ref = self.context.get_or_insert_with(|| {
1795 fidl::new_empty!(Context, fidl::encoding::DefaultFuchsiaResourceDialect)
1796 });
1797 fidl::decode!(
1798 Context,
1799 fidl::encoding::DefaultFuchsiaResourceDialect,
1800 val_ref,
1801 decoder,
1802 inner_offset,
1803 inner_depth
1804 )?;
1805 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1806 {
1807 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1808 }
1809 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1810 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1811 }
1812 }
1813
1814 next_offset += envelope_size;
1815 _next_ordinal_to_read += 1;
1816 if next_offset >= end_offset {
1817 return Ok(());
1818 }
1819
1820 while _next_ordinal_to_read < 4 {
1822 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1823 _next_ordinal_to_read += 1;
1824 next_offset += envelope_size;
1825 }
1826
1827 let next_out_of_line = decoder.next_out_of_line();
1828 let handles_before = decoder.remaining_handles();
1829 if let Some((inlined, num_bytes, num_handles)) =
1830 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1831 {
1832 let member_inline_size =
1833 <Target as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1834 if inlined != (member_inline_size <= 4) {
1835 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1836 }
1837 let inner_offset;
1838 let mut inner_depth = depth.clone();
1839 if inlined {
1840 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1841 inner_offset = next_offset;
1842 } else {
1843 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1844 inner_depth.increment()?;
1845 }
1846 let val_ref = self.target.get_or_insert_with(|| {
1847 fidl::new_empty!(Target, fidl::encoding::DefaultFuchsiaResourceDialect)
1848 });
1849 fidl::decode!(
1850 Target,
1851 fidl::encoding::DefaultFuchsiaResourceDialect,
1852 val_ref,
1853 decoder,
1854 inner_offset,
1855 inner_depth
1856 )?;
1857 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1858 {
1859 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1860 }
1861 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1862 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1863 }
1864 }
1865
1866 next_offset += envelope_size;
1867 _next_ordinal_to_read += 1;
1868 if next_offset >= end_offset {
1869 return Ok(());
1870 }
1871
1872 while _next_ordinal_to_read < 5 {
1874 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1875 _next_ordinal_to_read += 1;
1876 next_offset += envelope_size;
1877 }
1878
1879 let next_out_of_line = decoder.next_out_of_line();
1880 let handles_before = decoder.remaining_handles();
1881 if let Some((inlined, num_bytes, num_handles)) =
1882 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1883 {
1884 let member_inline_size =
1885 <Viewport as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1886 if inlined != (member_inline_size <= 4) {
1887 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1888 }
1889 let inner_offset;
1890 let mut inner_depth = depth.clone();
1891 if inlined {
1892 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1893 inner_offset = next_offset;
1894 } else {
1895 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1896 inner_depth.increment()?;
1897 }
1898 let val_ref = self.viewport.get_or_insert_with(|| {
1899 fidl::new_empty!(Viewport, fidl::encoding::DefaultFuchsiaResourceDialect)
1900 });
1901 fidl::decode!(
1902 Viewport,
1903 fidl::encoding::DefaultFuchsiaResourceDialect,
1904 val_ref,
1905 decoder,
1906 inner_offset,
1907 inner_depth
1908 )?;
1909 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1910 {
1911 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1912 }
1913 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1914 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1915 }
1916 }
1917
1918 next_offset += envelope_size;
1919 _next_ordinal_to_read += 1;
1920 if next_offset >= end_offset {
1921 return Ok(());
1922 }
1923
1924 while _next_ordinal_to_read < 6 {
1926 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1927 _next_ordinal_to_read += 1;
1928 next_offset += envelope_size;
1929 }
1930
1931 let next_out_of_line = decoder.next_out_of_line();
1932 let handles_before = decoder.remaining_handles();
1933 if let Some((inlined, num_bytes, num_handles)) =
1934 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1935 {
1936 let member_inline_size =
1937 <DispatchPolicy as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1938 if inlined != (member_inline_size <= 4) {
1939 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1940 }
1941 let inner_offset;
1942 let mut inner_depth = depth.clone();
1943 if inlined {
1944 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1945 inner_offset = next_offset;
1946 } else {
1947 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1948 inner_depth.increment()?;
1949 }
1950 let val_ref = self.dispatch_policy.get_or_insert_with(|| {
1951 fidl::new_empty!(DispatchPolicy, fidl::encoding::DefaultFuchsiaResourceDialect)
1952 });
1953 fidl::decode!(
1954 DispatchPolicy,
1955 fidl::encoding::DefaultFuchsiaResourceDialect,
1956 val_ref,
1957 decoder,
1958 inner_offset,
1959 inner_depth
1960 )?;
1961 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1962 {
1963 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1964 }
1965 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1966 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1967 }
1968 }
1969
1970 next_offset += envelope_size;
1971 _next_ordinal_to_read += 1;
1972 if next_offset >= end_offset {
1973 return Ok(());
1974 }
1975
1976 while _next_ordinal_to_read < 7 {
1978 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1979 _next_ordinal_to_read += 1;
1980 next_offset += envelope_size;
1981 }
1982
1983 let next_out_of_line = decoder.next_out_of_line();
1984 let handles_before = decoder.remaining_handles();
1985 if let Some((inlined, num_bytes, num_handles)) =
1986 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1987 {
1988 let member_inline_size =
1989 <fidl_fuchsia_input_report::Axis as fidl::encoding::TypeMarker>::inline_size(
1990 decoder.context,
1991 );
1992 if inlined != (member_inline_size <= 4) {
1993 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1994 }
1995 let inner_offset;
1996 let mut inner_depth = depth.clone();
1997 if inlined {
1998 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1999 inner_offset = next_offset;
2000 } else {
2001 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2002 inner_depth.increment()?;
2003 }
2004 let val_ref = self.scroll_v_range.get_or_insert_with(|| {
2005 fidl::new_empty!(
2006 fidl_fuchsia_input_report::Axis,
2007 fidl::encoding::DefaultFuchsiaResourceDialect
2008 )
2009 });
2010 fidl::decode!(
2011 fidl_fuchsia_input_report::Axis,
2012 fidl::encoding::DefaultFuchsiaResourceDialect,
2013 val_ref,
2014 decoder,
2015 inner_offset,
2016 inner_depth
2017 )?;
2018 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2019 {
2020 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2021 }
2022 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2023 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2024 }
2025 }
2026
2027 next_offset += envelope_size;
2028 _next_ordinal_to_read += 1;
2029 if next_offset >= end_offset {
2030 return Ok(());
2031 }
2032
2033 while _next_ordinal_to_read < 8 {
2035 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2036 _next_ordinal_to_read += 1;
2037 next_offset += envelope_size;
2038 }
2039
2040 let next_out_of_line = decoder.next_out_of_line();
2041 let handles_before = decoder.remaining_handles();
2042 if let Some((inlined, num_bytes, num_handles)) =
2043 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2044 {
2045 let member_inline_size =
2046 <fidl_fuchsia_input_report::Axis as fidl::encoding::TypeMarker>::inline_size(
2047 decoder.context,
2048 );
2049 if inlined != (member_inline_size <= 4) {
2050 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2051 }
2052 let inner_offset;
2053 let mut inner_depth = depth.clone();
2054 if inlined {
2055 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2056 inner_offset = next_offset;
2057 } else {
2058 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2059 inner_depth.increment()?;
2060 }
2061 let val_ref = self.scroll_h_range.get_or_insert_with(|| {
2062 fidl::new_empty!(
2063 fidl_fuchsia_input_report::Axis,
2064 fidl::encoding::DefaultFuchsiaResourceDialect
2065 )
2066 });
2067 fidl::decode!(
2068 fidl_fuchsia_input_report::Axis,
2069 fidl::encoding::DefaultFuchsiaResourceDialect,
2070 val_ref,
2071 decoder,
2072 inner_offset,
2073 inner_depth
2074 )?;
2075 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2076 {
2077 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2078 }
2079 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2080 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2081 }
2082 }
2083
2084 next_offset += envelope_size;
2085 _next_ordinal_to_read += 1;
2086 if next_offset >= end_offset {
2087 return Ok(());
2088 }
2089
2090 while _next_ordinal_to_read < 9 {
2092 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2093 _next_ordinal_to_read += 1;
2094 next_offset += envelope_size;
2095 }
2096
2097 let next_out_of_line = decoder.next_out_of_line();
2098 let handles_before = decoder.remaining_handles();
2099 if let Some((inlined, num_bytes, num_handles)) =
2100 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2101 {
2102 let member_inline_size =
2103 <fidl::encoding::Vector<u8, 32> as fidl::encoding::TypeMarker>::inline_size(
2104 decoder.context,
2105 );
2106 if inlined != (member_inline_size <= 4) {
2107 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2108 }
2109 let inner_offset;
2110 let mut inner_depth = depth.clone();
2111 if inlined {
2112 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2113 inner_offset = next_offset;
2114 } else {
2115 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2116 inner_depth.increment()?;
2117 }
2118 let val_ref =
2119 self.buttons.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
2120 fidl::decode!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2121 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2122 {
2123 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2124 }
2125 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2126 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2127 }
2128 }
2129
2130 next_offset += envelope_size;
2131 _next_ordinal_to_read += 1;
2132 if next_offset >= end_offset {
2133 return Ok(());
2134 }
2135
2136 while _next_ordinal_to_read < 10 {
2138 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2139 _next_ordinal_to_read += 1;
2140 next_offset += envelope_size;
2141 }
2142
2143 let next_out_of_line = decoder.next_out_of_line();
2144 let handles_before = decoder.remaining_handles();
2145 if let Some((inlined, num_bytes, num_handles)) =
2146 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2147 {
2148 let member_inline_size = <fidl::encoding::Array<fidl_fuchsia_input_report::Axis, 2> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2149 if inlined != (member_inline_size <= 4) {
2150 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2151 }
2152 let inner_offset;
2153 let mut inner_depth = depth.clone();
2154 if inlined {
2155 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2156 inner_offset = next_offset;
2157 } else {
2158 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2159 inner_depth.increment()?;
2160 }
2161 let val_ref =
2162 self.relative_motion_range.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Array<fidl_fuchsia_input_report::Axis, 2>, fidl::encoding::DefaultFuchsiaResourceDialect));
2163 fidl::decode!(fidl::encoding::Array<fidl_fuchsia_input_report::Axis, 2>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2164 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2165 {
2166 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2167 }
2168 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2169 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2170 }
2171 }
2172
2173 next_offset += envelope_size;
2174
2175 while next_offset < end_offset {
2177 _next_ordinal_to_read += 1;
2178 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2179 next_offset += envelope_size;
2180 }
2181
2182 Ok(())
2183 }
2184 }
2185
2186 impl fidl::encoding::ResourceTypeMarker for Context {
2187 type Borrowed<'a> = &'a mut Self;
2188 fn take_or_borrow<'a>(
2189 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2190 ) -> Self::Borrowed<'a> {
2191 value
2192 }
2193 }
2194
2195 unsafe impl fidl::encoding::TypeMarker for Context {
2196 type Owned = Self;
2197
2198 #[inline(always)]
2199 fn inline_align(_context: fidl::encoding::Context) -> usize {
2200 8
2201 }
2202
2203 #[inline(always)]
2204 fn inline_size(_context: fidl::encoding::Context) -> usize {
2205 16
2206 }
2207 }
2208
2209 unsafe impl fidl::encoding::Encode<Context, fidl::encoding::DefaultFuchsiaResourceDialect>
2210 for &mut Context
2211 {
2212 #[inline]
2213 unsafe fn encode(
2214 self,
2215 encoder: &mut fidl::encoding::Encoder<
2216 '_,
2217 fidl::encoding::DefaultFuchsiaResourceDialect,
2218 >,
2219 offset: usize,
2220 _depth: fidl::encoding::Depth,
2221 ) -> fidl::Result<()> {
2222 encoder.debug_check_bounds::<Context>(offset);
2223 encoder.write_num::<u64>(self.ordinal(), offset);
2224 match self {
2225 Context::View(ref mut val) => {
2226 fidl::encoding::encode_in_envelope::<fidl_fuchsia_ui_views::ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>(
2227 <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2228 encoder, offset + 8, _depth
2229 )
2230 }
2231 }
2232 }
2233 }
2234
2235 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Context {
2236 #[inline(always)]
2237 fn new_empty() -> Self {
2238 Self::View(fidl::new_empty!(
2239 fidl_fuchsia_ui_views::ViewRef,
2240 fidl::encoding::DefaultFuchsiaResourceDialect
2241 ))
2242 }
2243
2244 #[inline]
2245 unsafe fn decode(
2246 &mut self,
2247 decoder: &mut fidl::encoding::Decoder<
2248 '_,
2249 fidl::encoding::DefaultFuchsiaResourceDialect,
2250 >,
2251 offset: usize,
2252 mut depth: fidl::encoding::Depth,
2253 ) -> fidl::Result<()> {
2254 decoder.debug_check_bounds::<Self>(offset);
2255 #[allow(unused_variables)]
2256 let next_out_of_line = decoder.next_out_of_line();
2257 let handles_before = decoder.remaining_handles();
2258 let (ordinal, inlined, num_bytes, num_handles) =
2259 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2260
2261 let member_inline_size = match ordinal {
2262 1 => <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::TypeMarker>::inline_size(
2263 decoder.context,
2264 ),
2265 _ => return Err(fidl::Error::UnknownUnionTag),
2266 };
2267
2268 if inlined != (member_inline_size <= 4) {
2269 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2270 }
2271 let _inner_offset;
2272 if inlined {
2273 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2274 _inner_offset = offset + 8;
2275 } else {
2276 depth.increment()?;
2277 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2278 }
2279 match ordinal {
2280 1 => {
2281 #[allow(irrefutable_let_patterns)]
2282 if let Context::View(_) = self {
2283 } else {
2285 *self = Context::View(fidl::new_empty!(
2287 fidl_fuchsia_ui_views::ViewRef,
2288 fidl::encoding::DefaultFuchsiaResourceDialect
2289 ));
2290 }
2291 #[allow(irrefutable_let_patterns)]
2292 if let Context::View(ref mut val) = self {
2293 fidl::decode!(
2294 fidl_fuchsia_ui_views::ViewRef,
2295 fidl::encoding::DefaultFuchsiaResourceDialect,
2296 val,
2297 decoder,
2298 _inner_offset,
2299 depth
2300 )?;
2301 } else {
2302 unreachable!()
2303 }
2304 }
2305 ordinal => panic!("unexpected ordinal {:?}", ordinal),
2306 }
2307 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2308 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2309 }
2310 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2311 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2312 }
2313 Ok(())
2314 }
2315 }
2316
2317 impl fidl::encoding::ResourceTypeMarker for Target {
2318 type Borrowed<'a> = &'a mut Self;
2319 fn take_or_borrow<'a>(
2320 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2321 ) -> Self::Borrowed<'a> {
2322 value
2323 }
2324 }
2325
2326 unsafe impl fidl::encoding::TypeMarker for Target {
2327 type Owned = Self;
2328
2329 #[inline(always)]
2330 fn inline_align(_context: fidl::encoding::Context) -> usize {
2331 8
2332 }
2333
2334 #[inline(always)]
2335 fn inline_size(_context: fidl::encoding::Context) -> usize {
2336 16
2337 }
2338 }
2339
2340 unsafe impl fidl::encoding::Encode<Target, fidl::encoding::DefaultFuchsiaResourceDialect>
2341 for &mut Target
2342 {
2343 #[inline]
2344 unsafe fn encode(
2345 self,
2346 encoder: &mut fidl::encoding::Encoder<
2347 '_,
2348 fidl::encoding::DefaultFuchsiaResourceDialect,
2349 >,
2350 offset: usize,
2351 _depth: fidl::encoding::Depth,
2352 ) -> fidl::Result<()> {
2353 encoder.debug_check_bounds::<Target>(offset);
2354 encoder.write_num::<u64>(self.ordinal(), offset);
2355 match self {
2356 Target::View(ref mut val) => {
2357 fidl::encoding::encode_in_envelope::<fidl_fuchsia_ui_views::ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>(
2358 <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2359 encoder, offset + 8, _depth
2360 )
2361 }
2362 }
2363 }
2364 }
2365
2366 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Target {
2367 #[inline(always)]
2368 fn new_empty() -> Self {
2369 Self::View(fidl::new_empty!(
2370 fidl_fuchsia_ui_views::ViewRef,
2371 fidl::encoding::DefaultFuchsiaResourceDialect
2372 ))
2373 }
2374
2375 #[inline]
2376 unsafe fn decode(
2377 &mut self,
2378 decoder: &mut fidl::encoding::Decoder<
2379 '_,
2380 fidl::encoding::DefaultFuchsiaResourceDialect,
2381 >,
2382 offset: usize,
2383 mut depth: fidl::encoding::Depth,
2384 ) -> fidl::Result<()> {
2385 decoder.debug_check_bounds::<Self>(offset);
2386 #[allow(unused_variables)]
2387 let next_out_of_line = decoder.next_out_of_line();
2388 let handles_before = decoder.remaining_handles();
2389 let (ordinal, inlined, num_bytes, num_handles) =
2390 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2391
2392 let member_inline_size = match ordinal {
2393 1 => <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::TypeMarker>::inline_size(
2394 decoder.context,
2395 ),
2396 _ => return Err(fidl::Error::UnknownUnionTag),
2397 };
2398
2399 if inlined != (member_inline_size <= 4) {
2400 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2401 }
2402 let _inner_offset;
2403 if inlined {
2404 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2405 _inner_offset = offset + 8;
2406 } else {
2407 depth.increment()?;
2408 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2409 }
2410 match ordinal {
2411 1 => {
2412 #[allow(irrefutable_let_patterns)]
2413 if let Target::View(_) = self {
2414 } else {
2416 *self = Target::View(fidl::new_empty!(
2418 fidl_fuchsia_ui_views::ViewRef,
2419 fidl::encoding::DefaultFuchsiaResourceDialect
2420 ));
2421 }
2422 #[allow(irrefutable_let_patterns)]
2423 if let Target::View(ref mut val) = self {
2424 fidl::decode!(
2425 fidl_fuchsia_ui_views::ViewRef,
2426 fidl::encoding::DefaultFuchsiaResourceDialect,
2427 val,
2428 decoder,
2429 _inner_offset,
2430 depth
2431 )?;
2432 } else {
2433 unreachable!()
2434 }
2435 }
2436 ordinal => panic!("unexpected ordinal {:?}", ordinal),
2437 }
2438 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2439 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2440 }
2441 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2442 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2443 }
2444 Ok(())
2445 }
2446 }
2447}