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_input_injection__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct InputDeviceRegistryRegisterAndGetDeviceInfoRequest {
16 pub device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20 for InputDeviceRegistryRegisterAndGetDeviceInfoRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct InputDeviceRegistryRegisterRequest {
26 pub device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30 for InputDeviceRegistryRegisterRequest
31{
32}
33
34#[derive(Debug, Default, PartialEq)]
35pub struct InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
36 pub device_id: Option<u32>,
37 #[doc(hidden)]
38 pub __source_breaking: fidl::marker::SourceBreaking,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
42 for InputDeviceRegistryRegisterAndGetDeviceInfoResponse
43{
44}
45
46#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
47pub struct InputDeviceRegistryMarker;
48
49impl fidl::endpoints::ProtocolMarker for InputDeviceRegistryMarker {
50 type Proxy = InputDeviceRegistryProxy;
51 type RequestStream = InputDeviceRegistryRequestStream;
52 #[cfg(target_os = "fuchsia")]
53 type SynchronousProxy = InputDeviceRegistrySynchronousProxy;
54
55 const DEBUG_NAME: &'static str = "fuchsia.input.injection.InputDeviceRegistry";
56}
57impl fidl::endpoints::DiscoverableProtocolMarker for InputDeviceRegistryMarker {}
58
59pub trait InputDeviceRegistryProxyInterface: Send + Sync {
60 fn r#register(
61 &self,
62 device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
63 ) -> Result<(), fidl::Error>;
64 type RegisterAndGetDeviceInfoResponseFut: std::future::Future<
65 Output = Result<InputDeviceRegistryRegisterAndGetDeviceInfoResponse, fidl::Error>,
66 > + Send;
67 fn r#register_and_get_device_info(
68 &self,
69 device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
70 ) -> Self::RegisterAndGetDeviceInfoResponseFut;
71}
72#[derive(Debug)]
73#[cfg(target_os = "fuchsia")]
74pub struct InputDeviceRegistrySynchronousProxy {
75 client: fidl::client::sync::Client,
76}
77
78#[cfg(target_os = "fuchsia")]
79impl fidl::endpoints::SynchronousProxy for InputDeviceRegistrySynchronousProxy {
80 type Proxy = InputDeviceRegistryProxy;
81 type Protocol = InputDeviceRegistryMarker;
82
83 fn from_channel(inner: fidl::Channel) -> Self {
84 Self::new(inner)
85 }
86
87 fn into_channel(self) -> fidl::Channel {
88 self.client.into_channel()
89 }
90
91 fn as_channel(&self) -> &fidl::Channel {
92 self.client.as_channel()
93 }
94}
95
96#[cfg(target_os = "fuchsia")]
97impl InputDeviceRegistrySynchronousProxy {
98 pub fn new(channel: fidl::Channel) -> Self {
99 Self { client: fidl::client::sync::Client::new(channel) }
100 }
101
102 pub fn into_channel(self) -> fidl::Channel {
103 self.client.into_channel()
104 }
105
106 pub fn wait_for_event(
109 &self,
110 deadline: zx::MonotonicInstant,
111 ) -> Result<InputDeviceRegistryEvent, fidl::Error> {
112 InputDeviceRegistryEvent::decode(
113 self.client.wait_for_event::<InputDeviceRegistryMarker>(deadline)?,
114 )
115 }
116
117 pub fn r#register(
121 &self,
122 mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
123 ) -> Result<(), fidl::Error> {
124 self.client.send::<InputDeviceRegistryRegisterRequest>(
125 (device,),
126 0x523ec9804a4d8d45,
127 fidl::encoding::DynamicFlags::empty(),
128 )
129 }
130
131 pub fn r#register_and_get_device_info(
136 &self,
137 mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
138 ___deadline: zx::MonotonicInstant,
139 ) -> Result<InputDeviceRegistryRegisterAndGetDeviceInfoResponse, fidl::Error> {
140 let _response = self.client.send_query::<
141 InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
142 InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
143 InputDeviceRegistryMarker,
144 >(
145 (device,),
146 0x41db5035990763bc,
147 fidl::encoding::DynamicFlags::empty(),
148 ___deadline,
149 )?;
150 Ok(_response)
151 }
152}
153
154#[cfg(target_os = "fuchsia")]
155impl From<InputDeviceRegistrySynchronousProxy> for zx::NullableHandle {
156 fn from(value: InputDeviceRegistrySynchronousProxy) -> Self {
157 value.into_channel().into()
158 }
159}
160
161#[cfg(target_os = "fuchsia")]
162impl From<fidl::Channel> for InputDeviceRegistrySynchronousProxy {
163 fn from(value: fidl::Channel) -> Self {
164 Self::new(value)
165 }
166}
167
168#[cfg(target_os = "fuchsia")]
169impl fidl::endpoints::FromClient for InputDeviceRegistrySynchronousProxy {
170 type Protocol = InputDeviceRegistryMarker;
171
172 fn from_client(value: fidl::endpoints::ClientEnd<InputDeviceRegistryMarker>) -> Self {
173 Self::new(value.into_channel())
174 }
175}
176
177#[derive(Debug, Clone)]
178pub struct InputDeviceRegistryProxy {
179 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
180}
181
182impl fidl::endpoints::Proxy for InputDeviceRegistryProxy {
183 type Protocol = InputDeviceRegistryMarker;
184
185 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
186 Self::new(inner)
187 }
188
189 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
190 self.client.into_channel().map_err(|client| Self { client })
191 }
192
193 fn as_channel(&self) -> &::fidl::AsyncChannel {
194 self.client.as_channel()
195 }
196}
197
198impl InputDeviceRegistryProxy {
199 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
201 let protocol_name =
202 <InputDeviceRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
203 Self { client: fidl::client::Client::new(channel, protocol_name) }
204 }
205
206 pub fn take_event_stream(&self) -> InputDeviceRegistryEventStream {
212 InputDeviceRegistryEventStream { event_receiver: self.client.take_event_receiver() }
213 }
214
215 pub fn r#register(
219 &self,
220 mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
221 ) -> Result<(), fidl::Error> {
222 InputDeviceRegistryProxyInterface::r#register(self, device)
223 }
224
225 pub fn r#register_and_get_device_info(
230 &self,
231 mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
232 ) -> fidl::client::QueryResponseFut<
233 InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
234 fidl::encoding::DefaultFuchsiaResourceDialect,
235 > {
236 InputDeviceRegistryProxyInterface::r#register_and_get_device_info(self, device)
237 }
238}
239
240impl InputDeviceRegistryProxyInterface for InputDeviceRegistryProxy {
241 fn r#register(
242 &self,
243 mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
244 ) -> Result<(), fidl::Error> {
245 self.client.send::<InputDeviceRegistryRegisterRequest>(
246 (device,),
247 0x523ec9804a4d8d45,
248 fidl::encoding::DynamicFlags::empty(),
249 )
250 }
251
252 type RegisterAndGetDeviceInfoResponseFut = fidl::client::QueryResponseFut<
253 InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
254 fidl::encoding::DefaultFuchsiaResourceDialect,
255 >;
256 fn r#register_and_get_device_info(
257 &self,
258 mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
259 ) -> Self::RegisterAndGetDeviceInfoResponseFut {
260 fn _decode(
261 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
262 ) -> Result<InputDeviceRegistryRegisterAndGetDeviceInfoResponse, fidl::Error> {
263 let _response = fidl::client::decode_transaction_body::<
264 InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
265 fidl::encoding::DefaultFuchsiaResourceDialect,
266 0x41db5035990763bc,
267 >(_buf?)?;
268 Ok(_response)
269 }
270 self.client.send_query_and_decode::<
271 InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
272 InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
273 >(
274 (device,),
275 0x41db5035990763bc,
276 fidl::encoding::DynamicFlags::empty(),
277 _decode,
278 )
279 }
280}
281
282pub struct InputDeviceRegistryEventStream {
283 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
284}
285
286impl std::marker::Unpin for InputDeviceRegistryEventStream {}
287
288impl futures::stream::FusedStream for InputDeviceRegistryEventStream {
289 fn is_terminated(&self) -> bool {
290 self.event_receiver.is_terminated()
291 }
292}
293
294impl futures::Stream for InputDeviceRegistryEventStream {
295 type Item = Result<InputDeviceRegistryEvent, fidl::Error>;
296
297 fn poll_next(
298 mut self: std::pin::Pin<&mut Self>,
299 cx: &mut std::task::Context<'_>,
300 ) -> std::task::Poll<Option<Self::Item>> {
301 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
302 &mut self.event_receiver,
303 cx
304 )?) {
305 Some(buf) => std::task::Poll::Ready(Some(InputDeviceRegistryEvent::decode(buf))),
306 None => std::task::Poll::Ready(None),
307 }
308 }
309}
310
311#[derive(Debug)]
312pub enum InputDeviceRegistryEvent {}
313
314impl InputDeviceRegistryEvent {
315 fn decode(
317 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
318 ) -> Result<InputDeviceRegistryEvent, fidl::Error> {
319 let (bytes, _handles) = buf.split_mut();
320 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
321 debug_assert_eq!(tx_header.tx_id, 0);
322 match tx_header.ordinal {
323 _ => Err(fidl::Error::UnknownOrdinal {
324 ordinal: tx_header.ordinal,
325 protocol_name:
326 <InputDeviceRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
327 }),
328 }
329 }
330}
331
332pub struct InputDeviceRegistryRequestStream {
334 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
335 is_terminated: bool,
336}
337
338impl std::marker::Unpin for InputDeviceRegistryRequestStream {}
339
340impl futures::stream::FusedStream for InputDeviceRegistryRequestStream {
341 fn is_terminated(&self) -> bool {
342 self.is_terminated
343 }
344}
345
346impl fidl::endpoints::RequestStream for InputDeviceRegistryRequestStream {
347 type Protocol = InputDeviceRegistryMarker;
348 type ControlHandle = InputDeviceRegistryControlHandle;
349
350 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
351 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
352 }
353
354 fn control_handle(&self) -> Self::ControlHandle {
355 InputDeviceRegistryControlHandle { inner: self.inner.clone() }
356 }
357
358 fn into_inner(
359 self,
360 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
361 {
362 (self.inner, self.is_terminated)
363 }
364
365 fn from_inner(
366 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
367 is_terminated: bool,
368 ) -> Self {
369 Self { inner, is_terminated }
370 }
371}
372
373impl futures::Stream for InputDeviceRegistryRequestStream {
374 type Item = Result<InputDeviceRegistryRequest, fidl::Error>;
375
376 fn poll_next(
377 mut self: std::pin::Pin<&mut Self>,
378 cx: &mut std::task::Context<'_>,
379 ) -> std::task::Poll<Option<Self::Item>> {
380 let this = &mut *self;
381 if this.inner.check_shutdown(cx) {
382 this.is_terminated = true;
383 return std::task::Poll::Ready(None);
384 }
385 if this.is_terminated {
386 panic!("polled InputDeviceRegistryRequestStream after completion");
387 }
388 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
389 |bytes, handles| {
390 match this.inner.channel().read_etc(cx, bytes, handles) {
391 std::task::Poll::Ready(Ok(())) => {}
392 std::task::Poll::Pending => return std::task::Poll::Pending,
393 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
394 this.is_terminated = true;
395 return std::task::Poll::Ready(None);
396 }
397 std::task::Poll::Ready(Err(e)) => {
398 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
399 e.into(),
400 ))));
401 }
402 }
403
404 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
406
407 std::task::Poll::Ready(Some(match header.ordinal {
408 0x523ec9804a4d8d45 => {
409 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
410 let mut req = fidl::new_empty!(InputDeviceRegistryRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
411 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputDeviceRegistryRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
412 let control_handle = InputDeviceRegistryControlHandle {
413 inner: this.inner.clone(),
414 };
415 Ok(InputDeviceRegistryRequest::Register {device: req.device,
416
417 control_handle,
418 })
419 }
420 0x41db5035990763bc => {
421 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
422 let mut req = fidl::new_empty!(InputDeviceRegistryRegisterAndGetDeviceInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
423 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputDeviceRegistryRegisterAndGetDeviceInfoRequest>(&header, _body_bytes, handles, &mut req)?;
424 let control_handle = InputDeviceRegistryControlHandle {
425 inner: this.inner.clone(),
426 };
427 Ok(InputDeviceRegistryRequest::RegisterAndGetDeviceInfo {device: req.device,
428
429 responder: InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
430 control_handle: std::mem::ManuallyDrop::new(control_handle),
431 tx_id: header.tx_id,
432 },
433 })
434 }
435 _ => Err(fidl::Error::UnknownOrdinal {
436 ordinal: header.ordinal,
437 protocol_name: <InputDeviceRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
438 }),
439 }))
440 },
441 )
442 }
443}
444
445#[derive(Debug)]
452pub enum InputDeviceRegistryRequest {
453 Register {
457 device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
458 control_handle: InputDeviceRegistryControlHandle,
459 },
460 RegisterAndGetDeviceInfo {
465 device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
466 responder: InputDeviceRegistryRegisterAndGetDeviceInfoResponder,
467 },
468}
469
470impl InputDeviceRegistryRequest {
471 #[allow(irrefutable_let_patterns)]
472 pub fn into_register(
473 self,
474 ) -> Option<(
475 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
476 InputDeviceRegistryControlHandle,
477 )> {
478 if let InputDeviceRegistryRequest::Register { device, control_handle } = self {
479 Some((device, control_handle))
480 } else {
481 None
482 }
483 }
484
485 #[allow(irrefutable_let_patterns)]
486 pub fn into_register_and_get_device_info(
487 self,
488 ) -> Option<(
489 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
490 InputDeviceRegistryRegisterAndGetDeviceInfoResponder,
491 )> {
492 if let InputDeviceRegistryRequest::RegisterAndGetDeviceInfo { device, responder } = self {
493 Some((device, responder))
494 } else {
495 None
496 }
497 }
498
499 pub fn method_name(&self) -> &'static str {
501 match *self {
502 InputDeviceRegistryRequest::Register { .. } => "register",
503 InputDeviceRegistryRequest::RegisterAndGetDeviceInfo { .. } => {
504 "register_and_get_device_info"
505 }
506 }
507 }
508}
509
510#[derive(Debug, Clone)]
511pub struct InputDeviceRegistryControlHandle {
512 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
513}
514
515impl fidl::endpoints::ControlHandle for InputDeviceRegistryControlHandle {
516 fn shutdown(&self) {
517 self.inner.shutdown()
518 }
519
520 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
521 self.inner.shutdown_with_epitaph(status)
522 }
523
524 fn is_closed(&self) -> bool {
525 self.inner.channel().is_closed()
526 }
527 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
528 self.inner.channel().on_closed()
529 }
530
531 #[cfg(target_os = "fuchsia")]
532 fn signal_peer(
533 &self,
534 clear_mask: zx::Signals,
535 set_mask: zx::Signals,
536 ) -> Result<(), zx_status::Status> {
537 use fidl::Peered;
538 self.inner.channel().signal_peer(clear_mask, set_mask)
539 }
540}
541
542impl InputDeviceRegistryControlHandle {}
543
544#[must_use = "FIDL methods require a response to be sent"]
545#[derive(Debug)]
546pub struct InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
547 control_handle: std::mem::ManuallyDrop<InputDeviceRegistryControlHandle>,
548 tx_id: u32,
549}
550
551impl std::ops::Drop for InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
555 fn drop(&mut self) {
556 self.control_handle.shutdown();
557 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
559 }
560}
561
562impl fidl::endpoints::Responder for InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
563 type ControlHandle = InputDeviceRegistryControlHandle;
564
565 fn control_handle(&self) -> &InputDeviceRegistryControlHandle {
566 &self.control_handle
567 }
568
569 fn drop_without_shutdown(mut self) {
570 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
572 std::mem::forget(self);
574 }
575}
576
577impl InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
578 pub fn send(
582 self,
583 mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
584 ) -> Result<(), fidl::Error> {
585 let _result = self.send_raw(payload);
586 if _result.is_err() {
587 self.control_handle.shutdown();
588 }
589 self.drop_without_shutdown();
590 _result
591 }
592
593 pub fn send_no_shutdown_on_err(
595 self,
596 mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
597 ) -> Result<(), fidl::Error> {
598 let _result = self.send_raw(payload);
599 self.drop_without_shutdown();
600 _result
601 }
602
603 fn send_raw(
604 &self,
605 mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
606 ) -> Result<(), fidl::Error> {
607 self.control_handle.inner.send::<InputDeviceRegistryRegisterAndGetDeviceInfoResponse>(
608 &mut payload,
609 self.tx_id,
610 0x41db5035990763bc,
611 fidl::encoding::DynamicFlags::empty(),
612 )
613 }
614}
615
616mod internal {
617 use super::*;
618
619 impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoRequest {
620 type Borrowed<'a> = &'a mut Self;
621 fn take_or_borrow<'a>(
622 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
623 ) -> Self::Borrowed<'a> {
624 value
625 }
626 }
627
628 unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoRequest {
629 type Owned = Self;
630
631 #[inline(always)]
632 fn inline_align(_context: fidl::encoding::Context) -> usize {
633 4
634 }
635
636 #[inline(always)]
637 fn inline_size(_context: fidl::encoding::Context) -> usize {
638 4
639 }
640 }
641
642 unsafe impl
643 fidl::encoding::Encode<
644 InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
645 fidl::encoding::DefaultFuchsiaResourceDialect,
646 > for &mut InputDeviceRegistryRegisterAndGetDeviceInfoRequest
647 {
648 #[inline]
649 unsafe fn encode(
650 self,
651 encoder: &mut fidl::encoding::Encoder<
652 '_,
653 fidl::encoding::DefaultFuchsiaResourceDialect,
654 >,
655 offset: usize,
656 _depth: fidl::encoding::Depth,
657 ) -> fidl::Result<()> {
658 encoder
659 .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoRequest>(offset);
660 fidl::encoding::Encode::<
662 InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
663 fidl::encoding::DefaultFuchsiaResourceDialect,
664 >::encode(
665 (<fidl::encoding::Endpoint<
666 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
667 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
668 &mut self.device
669 ),),
670 encoder,
671 offset,
672 _depth,
673 )
674 }
675 }
676 unsafe impl<
677 T0: fidl::encoding::Encode<
678 fidl::encoding::Endpoint<
679 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
680 >,
681 fidl::encoding::DefaultFuchsiaResourceDialect,
682 >,
683 >
684 fidl::encoding::Encode<
685 InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
686 fidl::encoding::DefaultFuchsiaResourceDialect,
687 > for (T0,)
688 {
689 #[inline]
690 unsafe fn encode(
691 self,
692 encoder: &mut fidl::encoding::Encoder<
693 '_,
694 fidl::encoding::DefaultFuchsiaResourceDialect,
695 >,
696 offset: usize,
697 depth: fidl::encoding::Depth,
698 ) -> fidl::Result<()> {
699 encoder
700 .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoRequest>(offset);
701 self.0.encode(encoder, offset + 0, depth)?;
705 Ok(())
706 }
707 }
708
709 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
710 for InputDeviceRegistryRegisterAndGetDeviceInfoRequest
711 {
712 #[inline(always)]
713 fn new_empty() -> Self {
714 Self {
715 device: fidl::new_empty!(
716 fidl::encoding::Endpoint<
717 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
718 >,
719 fidl::encoding::DefaultFuchsiaResourceDialect
720 ),
721 }
722 }
723
724 #[inline]
725 unsafe fn decode(
726 &mut self,
727 decoder: &mut fidl::encoding::Decoder<
728 '_,
729 fidl::encoding::DefaultFuchsiaResourceDialect,
730 >,
731 offset: usize,
732 _depth: fidl::encoding::Depth,
733 ) -> fidl::Result<()> {
734 decoder.debug_check_bounds::<Self>(offset);
735 fidl::decode!(
737 fidl::encoding::Endpoint<
738 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
739 >,
740 fidl::encoding::DefaultFuchsiaResourceDialect,
741 &mut self.device,
742 decoder,
743 offset + 0,
744 _depth
745 )?;
746 Ok(())
747 }
748 }
749
750 impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterRequest {
751 type Borrowed<'a> = &'a mut Self;
752 fn take_or_borrow<'a>(
753 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
754 ) -> Self::Borrowed<'a> {
755 value
756 }
757 }
758
759 unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterRequest {
760 type Owned = Self;
761
762 #[inline(always)]
763 fn inline_align(_context: fidl::encoding::Context) -> usize {
764 4
765 }
766
767 #[inline(always)]
768 fn inline_size(_context: fidl::encoding::Context) -> usize {
769 4
770 }
771 }
772
773 unsafe impl
774 fidl::encoding::Encode<
775 InputDeviceRegistryRegisterRequest,
776 fidl::encoding::DefaultFuchsiaResourceDialect,
777 > for &mut InputDeviceRegistryRegisterRequest
778 {
779 #[inline]
780 unsafe fn encode(
781 self,
782 encoder: &mut fidl::encoding::Encoder<
783 '_,
784 fidl::encoding::DefaultFuchsiaResourceDialect,
785 >,
786 offset: usize,
787 _depth: fidl::encoding::Depth,
788 ) -> fidl::Result<()> {
789 encoder.debug_check_bounds::<InputDeviceRegistryRegisterRequest>(offset);
790 fidl::encoding::Encode::<
792 InputDeviceRegistryRegisterRequest,
793 fidl::encoding::DefaultFuchsiaResourceDialect,
794 >::encode(
795 (<fidl::encoding::Endpoint<
796 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
797 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
798 &mut self.device
799 ),),
800 encoder,
801 offset,
802 _depth,
803 )
804 }
805 }
806 unsafe impl<
807 T0: fidl::encoding::Encode<
808 fidl::encoding::Endpoint<
809 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
810 >,
811 fidl::encoding::DefaultFuchsiaResourceDialect,
812 >,
813 >
814 fidl::encoding::Encode<
815 InputDeviceRegistryRegisterRequest,
816 fidl::encoding::DefaultFuchsiaResourceDialect,
817 > for (T0,)
818 {
819 #[inline]
820 unsafe fn encode(
821 self,
822 encoder: &mut fidl::encoding::Encoder<
823 '_,
824 fidl::encoding::DefaultFuchsiaResourceDialect,
825 >,
826 offset: usize,
827 depth: fidl::encoding::Depth,
828 ) -> fidl::Result<()> {
829 encoder.debug_check_bounds::<InputDeviceRegistryRegisterRequest>(offset);
830 self.0.encode(encoder, offset + 0, depth)?;
834 Ok(())
835 }
836 }
837
838 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
839 for InputDeviceRegistryRegisterRequest
840 {
841 #[inline(always)]
842 fn new_empty() -> Self {
843 Self {
844 device: fidl::new_empty!(
845 fidl::encoding::Endpoint<
846 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
847 >,
848 fidl::encoding::DefaultFuchsiaResourceDialect
849 ),
850 }
851 }
852
853 #[inline]
854 unsafe fn decode(
855 &mut self,
856 decoder: &mut fidl::encoding::Decoder<
857 '_,
858 fidl::encoding::DefaultFuchsiaResourceDialect,
859 >,
860 offset: usize,
861 _depth: fidl::encoding::Depth,
862 ) -> fidl::Result<()> {
863 decoder.debug_check_bounds::<Self>(offset);
864 fidl::decode!(
866 fidl::encoding::Endpoint<
867 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
868 >,
869 fidl::encoding::DefaultFuchsiaResourceDialect,
870 &mut self.device,
871 decoder,
872 offset + 0,
873 _depth
874 )?;
875 Ok(())
876 }
877 }
878
879 impl InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
880 #[inline(always)]
881 fn max_ordinal_present(&self) -> u64 {
882 if let Some(_) = self.device_id {
883 return 1;
884 }
885 0
886 }
887 }
888
889 impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
890 type Borrowed<'a> = &'a mut Self;
891 fn take_or_borrow<'a>(
892 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
893 ) -> Self::Borrowed<'a> {
894 value
895 }
896 }
897
898 unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
899 type Owned = Self;
900
901 #[inline(always)]
902 fn inline_align(_context: fidl::encoding::Context) -> usize {
903 8
904 }
905
906 #[inline(always)]
907 fn inline_size(_context: fidl::encoding::Context) -> usize {
908 16
909 }
910 }
911
912 unsafe impl
913 fidl::encoding::Encode<
914 InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
915 fidl::encoding::DefaultFuchsiaResourceDialect,
916 > for &mut InputDeviceRegistryRegisterAndGetDeviceInfoResponse
917 {
918 unsafe fn encode(
919 self,
920 encoder: &mut fidl::encoding::Encoder<
921 '_,
922 fidl::encoding::DefaultFuchsiaResourceDialect,
923 >,
924 offset: usize,
925 mut depth: fidl::encoding::Depth,
926 ) -> fidl::Result<()> {
927 encoder
928 .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoResponse>(offset);
929 let max_ordinal: u64 = self.max_ordinal_present();
931 encoder.write_num(max_ordinal, offset);
932 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
933 if max_ordinal == 0 {
935 return Ok(());
936 }
937 depth.increment()?;
938 let envelope_size = 8;
939 let bytes_len = max_ordinal as usize * envelope_size;
940 #[allow(unused_variables)]
941 let offset = encoder.out_of_line_offset(bytes_len);
942 let mut _prev_end_offset: usize = 0;
943 if 1 > max_ordinal {
944 return Ok(());
945 }
946
947 let cur_offset: usize = (1 - 1) * envelope_size;
950
951 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
953
954 fidl::encoding::encode_in_envelope_optional::<
959 u32,
960 fidl::encoding::DefaultFuchsiaResourceDialect,
961 >(
962 self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
963 encoder,
964 offset + cur_offset,
965 depth,
966 )?;
967
968 _prev_end_offset = cur_offset + envelope_size;
969
970 Ok(())
971 }
972 }
973
974 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
975 for InputDeviceRegistryRegisterAndGetDeviceInfoResponse
976 {
977 #[inline(always)]
978 fn new_empty() -> Self {
979 Self::default()
980 }
981
982 unsafe fn decode(
983 &mut self,
984 decoder: &mut fidl::encoding::Decoder<
985 '_,
986 fidl::encoding::DefaultFuchsiaResourceDialect,
987 >,
988 offset: usize,
989 mut depth: fidl::encoding::Depth,
990 ) -> fidl::Result<()> {
991 decoder.debug_check_bounds::<Self>(offset);
992 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
993 None => return Err(fidl::Error::NotNullable),
994 Some(len) => len,
995 };
996 if len == 0 {
998 return Ok(());
999 };
1000 depth.increment()?;
1001 let envelope_size = 8;
1002 let bytes_len = len * envelope_size;
1003 let offset = decoder.out_of_line_offset(bytes_len)?;
1004 let mut _next_ordinal_to_read = 0;
1006 let mut next_offset = offset;
1007 let end_offset = offset + bytes_len;
1008 _next_ordinal_to_read += 1;
1009 if next_offset >= end_offset {
1010 return Ok(());
1011 }
1012
1013 while _next_ordinal_to_read < 1 {
1015 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1016 _next_ordinal_to_read += 1;
1017 next_offset += envelope_size;
1018 }
1019
1020 let next_out_of_line = decoder.next_out_of_line();
1021 let handles_before = decoder.remaining_handles();
1022 if let Some((inlined, num_bytes, num_handles)) =
1023 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1024 {
1025 let member_inline_size =
1026 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1027 if inlined != (member_inline_size <= 4) {
1028 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1029 }
1030 let inner_offset;
1031 let mut inner_depth = depth.clone();
1032 if inlined {
1033 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1034 inner_offset = next_offset;
1035 } else {
1036 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1037 inner_depth.increment()?;
1038 }
1039 let val_ref = self.device_id.get_or_insert_with(|| {
1040 fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1041 });
1042 fidl::decode!(
1043 u32,
1044 fidl::encoding::DefaultFuchsiaResourceDialect,
1045 val_ref,
1046 decoder,
1047 inner_offset,
1048 inner_depth
1049 )?;
1050 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1051 {
1052 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1053 }
1054 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1055 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1056 }
1057 }
1058
1059 next_offset += envelope_size;
1060
1061 while next_offset < end_offset {
1063 _next_ordinal_to_read += 1;
1064 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1065 next_offset += envelope_size;
1066 }
1067
1068 Ok(())
1069 }
1070 }
1071}