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 let protocol_name =
100 <InputDeviceRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
101 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
102 }
103
104 pub fn into_channel(self) -> fidl::Channel {
105 self.client.into_channel()
106 }
107
108 pub fn wait_for_event(
111 &self,
112 deadline: zx::MonotonicInstant,
113 ) -> Result<InputDeviceRegistryEvent, fidl::Error> {
114 InputDeviceRegistryEvent::decode(self.client.wait_for_event(deadline)?)
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 >(
144 (device,),
145 0x41db5035990763bc,
146 fidl::encoding::DynamicFlags::empty(),
147 ___deadline,
148 )?;
149 Ok(_response)
150 }
151}
152
153#[derive(Debug, Clone)]
154pub struct InputDeviceRegistryProxy {
155 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
156}
157
158impl fidl::endpoints::Proxy for InputDeviceRegistryProxy {
159 type Protocol = InputDeviceRegistryMarker;
160
161 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
162 Self::new(inner)
163 }
164
165 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
166 self.client.into_channel().map_err(|client| Self { client })
167 }
168
169 fn as_channel(&self) -> &::fidl::AsyncChannel {
170 self.client.as_channel()
171 }
172}
173
174impl InputDeviceRegistryProxy {
175 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
177 let protocol_name =
178 <InputDeviceRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
179 Self { client: fidl::client::Client::new(channel, protocol_name) }
180 }
181
182 pub fn take_event_stream(&self) -> InputDeviceRegistryEventStream {
188 InputDeviceRegistryEventStream { event_receiver: self.client.take_event_receiver() }
189 }
190
191 pub fn r#register(
195 &self,
196 mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
197 ) -> Result<(), fidl::Error> {
198 InputDeviceRegistryProxyInterface::r#register(self, device)
199 }
200
201 pub fn r#register_and_get_device_info(
206 &self,
207 mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
208 ) -> fidl::client::QueryResponseFut<
209 InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
210 fidl::encoding::DefaultFuchsiaResourceDialect,
211 > {
212 InputDeviceRegistryProxyInterface::r#register_and_get_device_info(self, device)
213 }
214}
215
216impl InputDeviceRegistryProxyInterface for InputDeviceRegistryProxy {
217 fn r#register(
218 &self,
219 mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
220 ) -> Result<(), fidl::Error> {
221 self.client.send::<InputDeviceRegistryRegisterRequest>(
222 (device,),
223 0x523ec9804a4d8d45,
224 fidl::encoding::DynamicFlags::empty(),
225 )
226 }
227
228 type RegisterAndGetDeviceInfoResponseFut = fidl::client::QueryResponseFut<
229 InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
230 fidl::encoding::DefaultFuchsiaResourceDialect,
231 >;
232 fn r#register_and_get_device_info(
233 &self,
234 mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
235 ) -> Self::RegisterAndGetDeviceInfoResponseFut {
236 fn _decode(
237 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
238 ) -> Result<InputDeviceRegistryRegisterAndGetDeviceInfoResponse, fidl::Error> {
239 let _response = fidl::client::decode_transaction_body::<
240 InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
241 fidl::encoding::DefaultFuchsiaResourceDialect,
242 0x41db5035990763bc,
243 >(_buf?)?;
244 Ok(_response)
245 }
246 self.client.send_query_and_decode::<
247 InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
248 InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
249 >(
250 (device,),
251 0x41db5035990763bc,
252 fidl::encoding::DynamicFlags::empty(),
253 _decode,
254 )
255 }
256}
257
258pub struct InputDeviceRegistryEventStream {
259 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
260}
261
262impl std::marker::Unpin for InputDeviceRegistryEventStream {}
263
264impl futures::stream::FusedStream for InputDeviceRegistryEventStream {
265 fn is_terminated(&self) -> bool {
266 self.event_receiver.is_terminated()
267 }
268}
269
270impl futures::Stream for InputDeviceRegistryEventStream {
271 type Item = Result<InputDeviceRegistryEvent, fidl::Error>;
272
273 fn poll_next(
274 mut self: std::pin::Pin<&mut Self>,
275 cx: &mut std::task::Context<'_>,
276 ) -> std::task::Poll<Option<Self::Item>> {
277 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
278 &mut self.event_receiver,
279 cx
280 )?) {
281 Some(buf) => std::task::Poll::Ready(Some(InputDeviceRegistryEvent::decode(buf))),
282 None => std::task::Poll::Ready(None),
283 }
284 }
285}
286
287#[derive(Debug)]
288pub enum InputDeviceRegistryEvent {}
289
290impl InputDeviceRegistryEvent {
291 fn decode(
293 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
294 ) -> Result<InputDeviceRegistryEvent, fidl::Error> {
295 let (bytes, _handles) = buf.split_mut();
296 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
297 debug_assert_eq!(tx_header.tx_id, 0);
298 match tx_header.ordinal {
299 _ => Err(fidl::Error::UnknownOrdinal {
300 ordinal: tx_header.ordinal,
301 protocol_name:
302 <InputDeviceRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
303 }),
304 }
305 }
306}
307
308pub struct InputDeviceRegistryRequestStream {
310 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
311 is_terminated: bool,
312}
313
314impl std::marker::Unpin for InputDeviceRegistryRequestStream {}
315
316impl futures::stream::FusedStream for InputDeviceRegistryRequestStream {
317 fn is_terminated(&self) -> bool {
318 self.is_terminated
319 }
320}
321
322impl fidl::endpoints::RequestStream for InputDeviceRegistryRequestStream {
323 type Protocol = InputDeviceRegistryMarker;
324 type ControlHandle = InputDeviceRegistryControlHandle;
325
326 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
327 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
328 }
329
330 fn control_handle(&self) -> Self::ControlHandle {
331 InputDeviceRegistryControlHandle { inner: self.inner.clone() }
332 }
333
334 fn into_inner(
335 self,
336 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
337 {
338 (self.inner, self.is_terminated)
339 }
340
341 fn from_inner(
342 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
343 is_terminated: bool,
344 ) -> Self {
345 Self { inner, is_terminated }
346 }
347}
348
349impl futures::Stream for InputDeviceRegistryRequestStream {
350 type Item = Result<InputDeviceRegistryRequest, fidl::Error>;
351
352 fn poll_next(
353 mut self: std::pin::Pin<&mut Self>,
354 cx: &mut std::task::Context<'_>,
355 ) -> std::task::Poll<Option<Self::Item>> {
356 let this = &mut *self;
357 if this.inner.check_shutdown(cx) {
358 this.is_terminated = true;
359 return std::task::Poll::Ready(None);
360 }
361 if this.is_terminated {
362 panic!("polled InputDeviceRegistryRequestStream after completion");
363 }
364 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
365 |bytes, handles| {
366 match this.inner.channel().read_etc(cx, bytes, handles) {
367 std::task::Poll::Ready(Ok(())) => {}
368 std::task::Poll::Pending => return std::task::Poll::Pending,
369 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
370 this.is_terminated = true;
371 return std::task::Poll::Ready(None);
372 }
373 std::task::Poll::Ready(Err(e)) => {
374 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
375 e.into(),
376 ))))
377 }
378 }
379
380 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
382
383 std::task::Poll::Ready(Some(match header.ordinal {
384 0x523ec9804a4d8d45 => {
385 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
386 let mut req = fidl::new_empty!(InputDeviceRegistryRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
387 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputDeviceRegistryRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
388 let control_handle = InputDeviceRegistryControlHandle {
389 inner: this.inner.clone(),
390 };
391 Ok(InputDeviceRegistryRequest::Register {device: req.device,
392
393 control_handle,
394 })
395 }
396 0x41db5035990763bc => {
397 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
398 let mut req = fidl::new_empty!(InputDeviceRegistryRegisterAndGetDeviceInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
399 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputDeviceRegistryRegisterAndGetDeviceInfoRequest>(&header, _body_bytes, handles, &mut req)?;
400 let control_handle = InputDeviceRegistryControlHandle {
401 inner: this.inner.clone(),
402 };
403 Ok(InputDeviceRegistryRequest::RegisterAndGetDeviceInfo {device: req.device,
404
405 responder: InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
406 control_handle: std::mem::ManuallyDrop::new(control_handle),
407 tx_id: header.tx_id,
408 },
409 })
410 }
411 _ => Err(fidl::Error::UnknownOrdinal {
412 ordinal: header.ordinal,
413 protocol_name: <InputDeviceRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
414 }),
415 }))
416 },
417 )
418 }
419}
420
421#[derive(Debug)]
428pub enum InputDeviceRegistryRequest {
429 Register {
433 device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
434 control_handle: InputDeviceRegistryControlHandle,
435 },
436 RegisterAndGetDeviceInfo {
441 device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
442 responder: InputDeviceRegistryRegisterAndGetDeviceInfoResponder,
443 },
444}
445
446impl InputDeviceRegistryRequest {
447 #[allow(irrefutable_let_patterns)]
448 pub fn into_register(
449 self,
450 ) -> Option<(
451 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
452 InputDeviceRegistryControlHandle,
453 )> {
454 if let InputDeviceRegistryRequest::Register { device, control_handle } = self {
455 Some((device, control_handle))
456 } else {
457 None
458 }
459 }
460
461 #[allow(irrefutable_let_patterns)]
462 pub fn into_register_and_get_device_info(
463 self,
464 ) -> Option<(
465 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
466 InputDeviceRegistryRegisterAndGetDeviceInfoResponder,
467 )> {
468 if let InputDeviceRegistryRequest::RegisterAndGetDeviceInfo { device, responder } = self {
469 Some((device, responder))
470 } else {
471 None
472 }
473 }
474
475 pub fn method_name(&self) -> &'static str {
477 match *self {
478 InputDeviceRegistryRequest::Register { .. } => "register",
479 InputDeviceRegistryRequest::RegisterAndGetDeviceInfo { .. } => {
480 "register_and_get_device_info"
481 }
482 }
483 }
484}
485
486#[derive(Debug, Clone)]
487pub struct InputDeviceRegistryControlHandle {
488 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
489}
490
491impl fidl::endpoints::ControlHandle for InputDeviceRegistryControlHandle {
492 fn shutdown(&self) {
493 self.inner.shutdown()
494 }
495 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
496 self.inner.shutdown_with_epitaph(status)
497 }
498
499 fn is_closed(&self) -> bool {
500 self.inner.channel().is_closed()
501 }
502 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
503 self.inner.channel().on_closed()
504 }
505
506 #[cfg(target_os = "fuchsia")]
507 fn signal_peer(
508 &self,
509 clear_mask: zx::Signals,
510 set_mask: zx::Signals,
511 ) -> Result<(), zx_status::Status> {
512 use fidl::Peered;
513 self.inner.channel().signal_peer(clear_mask, set_mask)
514 }
515}
516
517impl InputDeviceRegistryControlHandle {}
518
519#[must_use = "FIDL methods require a response to be sent"]
520#[derive(Debug)]
521pub struct InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
522 control_handle: std::mem::ManuallyDrop<InputDeviceRegistryControlHandle>,
523 tx_id: u32,
524}
525
526impl std::ops::Drop for InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
530 fn drop(&mut self) {
531 self.control_handle.shutdown();
532 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
534 }
535}
536
537impl fidl::endpoints::Responder for InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
538 type ControlHandle = InputDeviceRegistryControlHandle;
539
540 fn control_handle(&self) -> &InputDeviceRegistryControlHandle {
541 &self.control_handle
542 }
543
544 fn drop_without_shutdown(mut self) {
545 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
547 std::mem::forget(self);
549 }
550}
551
552impl InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
553 pub fn send(
557 self,
558 mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
559 ) -> Result<(), fidl::Error> {
560 let _result = self.send_raw(payload);
561 if _result.is_err() {
562 self.control_handle.shutdown();
563 }
564 self.drop_without_shutdown();
565 _result
566 }
567
568 pub fn send_no_shutdown_on_err(
570 self,
571 mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
572 ) -> Result<(), fidl::Error> {
573 let _result = self.send_raw(payload);
574 self.drop_without_shutdown();
575 _result
576 }
577
578 fn send_raw(
579 &self,
580 mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
581 ) -> Result<(), fidl::Error> {
582 self.control_handle.inner.send::<InputDeviceRegistryRegisterAndGetDeviceInfoResponse>(
583 &mut payload,
584 self.tx_id,
585 0x41db5035990763bc,
586 fidl::encoding::DynamicFlags::empty(),
587 )
588 }
589}
590
591mod internal {
592 use super::*;
593
594 impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoRequest {
595 type Borrowed<'a> = &'a mut Self;
596 fn take_or_borrow<'a>(
597 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
598 ) -> Self::Borrowed<'a> {
599 value
600 }
601 }
602
603 unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoRequest {
604 type Owned = Self;
605
606 #[inline(always)]
607 fn inline_align(_context: fidl::encoding::Context) -> usize {
608 4
609 }
610
611 #[inline(always)]
612 fn inline_size(_context: fidl::encoding::Context) -> usize {
613 4
614 }
615 }
616
617 unsafe impl
618 fidl::encoding::Encode<
619 InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
620 fidl::encoding::DefaultFuchsiaResourceDialect,
621 > for &mut InputDeviceRegistryRegisterAndGetDeviceInfoRequest
622 {
623 #[inline]
624 unsafe fn encode(
625 self,
626 encoder: &mut fidl::encoding::Encoder<
627 '_,
628 fidl::encoding::DefaultFuchsiaResourceDialect,
629 >,
630 offset: usize,
631 _depth: fidl::encoding::Depth,
632 ) -> fidl::Result<()> {
633 encoder
634 .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoRequest>(offset);
635 fidl::encoding::Encode::<
637 InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
638 fidl::encoding::DefaultFuchsiaResourceDialect,
639 >::encode(
640 (<fidl::encoding::Endpoint<
641 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
642 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
643 &mut self.device
644 ),),
645 encoder,
646 offset,
647 _depth,
648 )
649 }
650 }
651 unsafe impl<
652 T0: fidl::encoding::Encode<
653 fidl::encoding::Endpoint<
654 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
655 >,
656 fidl::encoding::DefaultFuchsiaResourceDialect,
657 >,
658 >
659 fidl::encoding::Encode<
660 InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
661 fidl::encoding::DefaultFuchsiaResourceDialect,
662 > for (T0,)
663 {
664 #[inline]
665 unsafe fn encode(
666 self,
667 encoder: &mut fidl::encoding::Encoder<
668 '_,
669 fidl::encoding::DefaultFuchsiaResourceDialect,
670 >,
671 offset: usize,
672 depth: fidl::encoding::Depth,
673 ) -> fidl::Result<()> {
674 encoder
675 .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoRequest>(offset);
676 self.0.encode(encoder, offset + 0, depth)?;
680 Ok(())
681 }
682 }
683
684 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
685 for InputDeviceRegistryRegisterAndGetDeviceInfoRequest
686 {
687 #[inline(always)]
688 fn new_empty() -> Self {
689 Self {
690 device: fidl::new_empty!(
691 fidl::encoding::Endpoint<
692 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
693 >,
694 fidl::encoding::DefaultFuchsiaResourceDialect
695 ),
696 }
697 }
698
699 #[inline]
700 unsafe fn decode(
701 &mut self,
702 decoder: &mut fidl::encoding::Decoder<
703 '_,
704 fidl::encoding::DefaultFuchsiaResourceDialect,
705 >,
706 offset: usize,
707 _depth: fidl::encoding::Depth,
708 ) -> fidl::Result<()> {
709 decoder.debug_check_bounds::<Self>(offset);
710 fidl::decode!(
712 fidl::encoding::Endpoint<
713 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
714 >,
715 fidl::encoding::DefaultFuchsiaResourceDialect,
716 &mut self.device,
717 decoder,
718 offset + 0,
719 _depth
720 )?;
721 Ok(())
722 }
723 }
724
725 impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterRequest {
726 type Borrowed<'a> = &'a mut Self;
727 fn take_or_borrow<'a>(
728 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
729 ) -> Self::Borrowed<'a> {
730 value
731 }
732 }
733
734 unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterRequest {
735 type Owned = Self;
736
737 #[inline(always)]
738 fn inline_align(_context: fidl::encoding::Context) -> usize {
739 4
740 }
741
742 #[inline(always)]
743 fn inline_size(_context: fidl::encoding::Context) -> usize {
744 4
745 }
746 }
747
748 unsafe impl
749 fidl::encoding::Encode<
750 InputDeviceRegistryRegisterRequest,
751 fidl::encoding::DefaultFuchsiaResourceDialect,
752 > for &mut InputDeviceRegistryRegisterRequest
753 {
754 #[inline]
755 unsafe fn encode(
756 self,
757 encoder: &mut fidl::encoding::Encoder<
758 '_,
759 fidl::encoding::DefaultFuchsiaResourceDialect,
760 >,
761 offset: usize,
762 _depth: fidl::encoding::Depth,
763 ) -> fidl::Result<()> {
764 encoder.debug_check_bounds::<InputDeviceRegistryRegisterRequest>(offset);
765 fidl::encoding::Encode::<
767 InputDeviceRegistryRegisterRequest,
768 fidl::encoding::DefaultFuchsiaResourceDialect,
769 >::encode(
770 (<fidl::encoding::Endpoint<
771 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
772 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
773 &mut self.device
774 ),),
775 encoder,
776 offset,
777 _depth,
778 )
779 }
780 }
781 unsafe impl<
782 T0: fidl::encoding::Encode<
783 fidl::encoding::Endpoint<
784 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
785 >,
786 fidl::encoding::DefaultFuchsiaResourceDialect,
787 >,
788 >
789 fidl::encoding::Encode<
790 InputDeviceRegistryRegisterRequest,
791 fidl::encoding::DefaultFuchsiaResourceDialect,
792 > for (T0,)
793 {
794 #[inline]
795 unsafe fn encode(
796 self,
797 encoder: &mut fidl::encoding::Encoder<
798 '_,
799 fidl::encoding::DefaultFuchsiaResourceDialect,
800 >,
801 offset: usize,
802 depth: fidl::encoding::Depth,
803 ) -> fidl::Result<()> {
804 encoder.debug_check_bounds::<InputDeviceRegistryRegisterRequest>(offset);
805 self.0.encode(encoder, offset + 0, depth)?;
809 Ok(())
810 }
811 }
812
813 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
814 for InputDeviceRegistryRegisterRequest
815 {
816 #[inline(always)]
817 fn new_empty() -> Self {
818 Self {
819 device: fidl::new_empty!(
820 fidl::encoding::Endpoint<
821 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
822 >,
823 fidl::encoding::DefaultFuchsiaResourceDialect
824 ),
825 }
826 }
827
828 #[inline]
829 unsafe fn decode(
830 &mut self,
831 decoder: &mut fidl::encoding::Decoder<
832 '_,
833 fidl::encoding::DefaultFuchsiaResourceDialect,
834 >,
835 offset: usize,
836 _depth: fidl::encoding::Depth,
837 ) -> fidl::Result<()> {
838 decoder.debug_check_bounds::<Self>(offset);
839 fidl::decode!(
841 fidl::encoding::Endpoint<
842 fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
843 >,
844 fidl::encoding::DefaultFuchsiaResourceDialect,
845 &mut self.device,
846 decoder,
847 offset + 0,
848 _depth
849 )?;
850 Ok(())
851 }
852 }
853
854 impl InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
855 #[inline(always)]
856 fn max_ordinal_present(&self) -> u64 {
857 if let Some(_) = self.device_id {
858 return 1;
859 }
860 0
861 }
862 }
863
864 impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
865 type Borrowed<'a> = &'a mut Self;
866 fn take_or_borrow<'a>(
867 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
868 ) -> Self::Borrowed<'a> {
869 value
870 }
871 }
872
873 unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
874 type Owned = Self;
875
876 #[inline(always)]
877 fn inline_align(_context: fidl::encoding::Context) -> usize {
878 8
879 }
880
881 #[inline(always)]
882 fn inline_size(_context: fidl::encoding::Context) -> usize {
883 16
884 }
885 }
886
887 unsafe impl
888 fidl::encoding::Encode<
889 InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
890 fidl::encoding::DefaultFuchsiaResourceDialect,
891 > for &mut InputDeviceRegistryRegisterAndGetDeviceInfoResponse
892 {
893 unsafe fn encode(
894 self,
895 encoder: &mut fidl::encoding::Encoder<
896 '_,
897 fidl::encoding::DefaultFuchsiaResourceDialect,
898 >,
899 offset: usize,
900 mut depth: fidl::encoding::Depth,
901 ) -> fidl::Result<()> {
902 encoder
903 .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoResponse>(offset);
904 let max_ordinal: u64 = self.max_ordinal_present();
906 encoder.write_num(max_ordinal, offset);
907 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
908 if max_ordinal == 0 {
910 return Ok(());
911 }
912 depth.increment()?;
913 let envelope_size = 8;
914 let bytes_len = max_ordinal as usize * envelope_size;
915 #[allow(unused_variables)]
916 let offset = encoder.out_of_line_offset(bytes_len);
917 let mut _prev_end_offset: usize = 0;
918 if 1 > max_ordinal {
919 return Ok(());
920 }
921
922 let cur_offset: usize = (1 - 1) * envelope_size;
925
926 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
928
929 fidl::encoding::encode_in_envelope_optional::<
934 u32,
935 fidl::encoding::DefaultFuchsiaResourceDialect,
936 >(
937 self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
938 encoder,
939 offset + cur_offset,
940 depth,
941 )?;
942
943 _prev_end_offset = cur_offset + envelope_size;
944
945 Ok(())
946 }
947 }
948
949 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
950 for InputDeviceRegistryRegisterAndGetDeviceInfoResponse
951 {
952 #[inline(always)]
953 fn new_empty() -> Self {
954 Self::default()
955 }
956
957 unsafe fn decode(
958 &mut self,
959 decoder: &mut fidl::encoding::Decoder<
960 '_,
961 fidl::encoding::DefaultFuchsiaResourceDialect,
962 >,
963 offset: usize,
964 mut depth: fidl::encoding::Depth,
965 ) -> fidl::Result<()> {
966 decoder.debug_check_bounds::<Self>(offset);
967 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
968 None => return Err(fidl::Error::NotNullable),
969 Some(len) => len,
970 };
971 if len == 0 {
973 return Ok(());
974 };
975 depth.increment()?;
976 let envelope_size = 8;
977 let bytes_len = len * envelope_size;
978 let offset = decoder.out_of_line_offset(bytes_len)?;
979 let mut _next_ordinal_to_read = 0;
981 let mut next_offset = offset;
982 let end_offset = offset + bytes_len;
983 _next_ordinal_to_read += 1;
984 if next_offset >= end_offset {
985 return Ok(());
986 }
987
988 while _next_ordinal_to_read < 1 {
990 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
991 _next_ordinal_to_read += 1;
992 next_offset += envelope_size;
993 }
994
995 let next_out_of_line = decoder.next_out_of_line();
996 let handles_before = decoder.remaining_handles();
997 if let Some((inlined, num_bytes, num_handles)) =
998 fidl::encoding::decode_envelope_header(decoder, next_offset)?
999 {
1000 let member_inline_size =
1001 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1002 if inlined != (member_inline_size <= 4) {
1003 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1004 }
1005 let inner_offset;
1006 let mut inner_depth = depth.clone();
1007 if inlined {
1008 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1009 inner_offset = next_offset;
1010 } else {
1011 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1012 inner_depth.increment()?;
1013 }
1014 let val_ref = self.device_id.get_or_insert_with(|| {
1015 fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1016 });
1017 fidl::decode!(
1018 u32,
1019 fidl::encoding::DefaultFuchsiaResourceDialect,
1020 val_ref,
1021 decoder,
1022 inner_offset,
1023 inner_depth
1024 )?;
1025 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1026 {
1027 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1028 }
1029 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1030 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1031 }
1032 }
1033
1034 next_offset += envelope_size;
1035
1036 while next_offset < end_offset {
1038 _next_ordinal_to_read += 1;
1039 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1040 next_offset += envelope_size;
1041 }
1042
1043 Ok(())
1044 }
1045 }
1046}