fidl_fuchsia_input_injection/
fidl_fuchsia_input_injection.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_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    /// Waits until an event arrives and returns it. It is safe for other
109    /// threads to make concurrent requests while waiting for an event.
110    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    /// Registers an input device represented by `device`.
118    /// On registration, the InputDeviceRegistry starts listening for input reports on the
119    /// InputReportsReader returned by device.GetInputReportsReader().
120    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    /// Registers an input device represented by `device` and return the device id of the
132    /// added test device.
133    /// On registration, the InputDeviceRegistry starts listening for input reports on the
134    /// InputReportsReader returned by device.GetInputReportsReader().
135    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#[cfg(target_os = "fuchsia")]
154impl From<InputDeviceRegistrySynchronousProxy> for zx::NullableHandle {
155    fn from(value: InputDeviceRegistrySynchronousProxy) -> Self {
156        value.into_channel().into()
157    }
158}
159
160#[cfg(target_os = "fuchsia")]
161impl From<fidl::Channel> for InputDeviceRegistrySynchronousProxy {
162    fn from(value: fidl::Channel) -> Self {
163        Self::new(value)
164    }
165}
166
167#[cfg(target_os = "fuchsia")]
168impl fidl::endpoints::FromClient for InputDeviceRegistrySynchronousProxy {
169    type Protocol = InputDeviceRegistryMarker;
170
171    fn from_client(value: fidl::endpoints::ClientEnd<InputDeviceRegistryMarker>) -> Self {
172        Self::new(value.into_channel())
173    }
174}
175
176#[derive(Debug, Clone)]
177pub struct InputDeviceRegistryProxy {
178    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
179}
180
181impl fidl::endpoints::Proxy for InputDeviceRegistryProxy {
182    type Protocol = InputDeviceRegistryMarker;
183
184    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
185        Self::new(inner)
186    }
187
188    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
189        self.client.into_channel().map_err(|client| Self { client })
190    }
191
192    fn as_channel(&self) -> &::fidl::AsyncChannel {
193        self.client.as_channel()
194    }
195}
196
197impl InputDeviceRegistryProxy {
198    /// Create a new Proxy for fuchsia.input.injection/InputDeviceRegistry.
199    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
200        let protocol_name =
201            <InputDeviceRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
202        Self { client: fidl::client::Client::new(channel, protocol_name) }
203    }
204
205    /// Get a Stream of events from the remote end of the protocol.
206    ///
207    /// # Panics
208    ///
209    /// Panics if the event stream was already taken.
210    pub fn take_event_stream(&self) -> InputDeviceRegistryEventStream {
211        InputDeviceRegistryEventStream { event_receiver: self.client.take_event_receiver() }
212    }
213
214    /// Registers an input device represented by `device`.
215    /// On registration, the InputDeviceRegistry starts listening for input reports on the
216    /// InputReportsReader returned by device.GetInputReportsReader().
217    pub fn r#register(
218        &self,
219        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
220    ) -> Result<(), fidl::Error> {
221        InputDeviceRegistryProxyInterface::r#register(self, device)
222    }
223
224    /// Registers an input device represented by `device` and return the device id of the
225    /// added test device.
226    /// On registration, the InputDeviceRegistry starts listening for input reports on the
227    /// InputReportsReader returned by device.GetInputReportsReader().
228    pub fn r#register_and_get_device_info(
229        &self,
230        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
231    ) -> fidl::client::QueryResponseFut<
232        InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
233        fidl::encoding::DefaultFuchsiaResourceDialect,
234    > {
235        InputDeviceRegistryProxyInterface::r#register_and_get_device_info(self, device)
236    }
237}
238
239impl InputDeviceRegistryProxyInterface for InputDeviceRegistryProxy {
240    fn r#register(
241        &self,
242        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
243    ) -> Result<(), fidl::Error> {
244        self.client.send::<InputDeviceRegistryRegisterRequest>(
245            (device,),
246            0x523ec9804a4d8d45,
247            fidl::encoding::DynamicFlags::empty(),
248        )
249    }
250
251    type RegisterAndGetDeviceInfoResponseFut = fidl::client::QueryResponseFut<
252        InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
253        fidl::encoding::DefaultFuchsiaResourceDialect,
254    >;
255    fn r#register_and_get_device_info(
256        &self,
257        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
258    ) -> Self::RegisterAndGetDeviceInfoResponseFut {
259        fn _decode(
260            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
261        ) -> Result<InputDeviceRegistryRegisterAndGetDeviceInfoResponse, fidl::Error> {
262            let _response = fidl::client::decode_transaction_body::<
263                InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
264                fidl::encoding::DefaultFuchsiaResourceDialect,
265                0x41db5035990763bc,
266            >(_buf?)?;
267            Ok(_response)
268        }
269        self.client.send_query_and_decode::<
270            InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
271            InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
272        >(
273            (device,),
274            0x41db5035990763bc,
275            fidl::encoding::DynamicFlags::empty(),
276            _decode,
277        )
278    }
279}
280
281pub struct InputDeviceRegistryEventStream {
282    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
283}
284
285impl std::marker::Unpin for InputDeviceRegistryEventStream {}
286
287impl futures::stream::FusedStream for InputDeviceRegistryEventStream {
288    fn is_terminated(&self) -> bool {
289        self.event_receiver.is_terminated()
290    }
291}
292
293impl futures::Stream for InputDeviceRegistryEventStream {
294    type Item = Result<InputDeviceRegistryEvent, fidl::Error>;
295
296    fn poll_next(
297        mut self: std::pin::Pin<&mut Self>,
298        cx: &mut std::task::Context<'_>,
299    ) -> std::task::Poll<Option<Self::Item>> {
300        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
301            &mut self.event_receiver,
302            cx
303        )?) {
304            Some(buf) => std::task::Poll::Ready(Some(InputDeviceRegistryEvent::decode(buf))),
305            None => std::task::Poll::Ready(None),
306        }
307    }
308}
309
310#[derive(Debug)]
311pub enum InputDeviceRegistryEvent {}
312
313impl InputDeviceRegistryEvent {
314    /// Decodes a message buffer as a [`InputDeviceRegistryEvent`].
315    fn decode(
316        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
317    ) -> Result<InputDeviceRegistryEvent, fidl::Error> {
318        let (bytes, _handles) = buf.split_mut();
319        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
320        debug_assert_eq!(tx_header.tx_id, 0);
321        match tx_header.ordinal {
322            _ => Err(fidl::Error::UnknownOrdinal {
323                ordinal: tx_header.ordinal,
324                protocol_name:
325                    <InputDeviceRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
326            }),
327        }
328    }
329}
330
331/// A Stream of incoming requests for fuchsia.input.injection/InputDeviceRegistry.
332pub struct InputDeviceRegistryRequestStream {
333    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
334    is_terminated: bool,
335}
336
337impl std::marker::Unpin for InputDeviceRegistryRequestStream {}
338
339impl futures::stream::FusedStream for InputDeviceRegistryRequestStream {
340    fn is_terminated(&self) -> bool {
341        self.is_terminated
342    }
343}
344
345impl fidl::endpoints::RequestStream for InputDeviceRegistryRequestStream {
346    type Protocol = InputDeviceRegistryMarker;
347    type ControlHandle = InputDeviceRegistryControlHandle;
348
349    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
350        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
351    }
352
353    fn control_handle(&self) -> Self::ControlHandle {
354        InputDeviceRegistryControlHandle { inner: self.inner.clone() }
355    }
356
357    fn into_inner(
358        self,
359    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
360    {
361        (self.inner, self.is_terminated)
362    }
363
364    fn from_inner(
365        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
366        is_terminated: bool,
367    ) -> Self {
368        Self { inner, is_terminated }
369    }
370}
371
372impl futures::Stream for InputDeviceRegistryRequestStream {
373    type Item = Result<InputDeviceRegistryRequest, fidl::Error>;
374
375    fn poll_next(
376        mut self: std::pin::Pin<&mut Self>,
377        cx: &mut std::task::Context<'_>,
378    ) -> std::task::Poll<Option<Self::Item>> {
379        let this = &mut *self;
380        if this.inner.check_shutdown(cx) {
381            this.is_terminated = true;
382            return std::task::Poll::Ready(None);
383        }
384        if this.is_terminated {
385            panic!("polled InputDeviceRegistryRequestStream after completion");
386        }
387        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
388            |bytes, handles| {
389                match this.inner.channel().read_etc(cx, bytes, handles) {
390                    std::task::Poll::Ready(Ok(())) => {}
391                    std::task::Poll::Pending => return std::task::Poll::Pending,
392                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
393                        this.is_terminated = true;
394                        return std::task::Poll::Ready(None);
395                    }
396                    std::task::Poll::Ready(Err(e)) => {
397                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
398                            e.into(),
399                        ))));
400                    }
401                }
402
403                // A message has been received from the channel
404                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
405
406                std::task::Poll::Ready(Some(match header.ordinal {
407                0x523ec9804a4d8d45 => {
408                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
409                    let mut req = fidl::new_empty!(InputDeviceRegistryRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
410                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputDeviceRegistryRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
411                    let control_handle = InputDeviceRegistryControlHandle {
412                        inner: this.inner.clone(),
413                    };
414                    Ok(InputDeviceRegistryRequest::Register {device: req.device,
415
416                        control_handle,
417                    })
418                }
419                0x41db5035990763bc => {
420                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
421                    let mut req = fidl::new_empty!(InputDeviceRegistryRegisterAndGetDeviceInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
422                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InputDeviceRegistryRegisterAndGetDeviceInfoRequest>(&header, _body_bytes, handles, &mut req)?;
423                    let control_handle = InputDeviceRegistryControlHandle {
424                        inner: this.inner.clone(),
425                    };
426                    Ok(InputDeviceRegistryRequest::RegisterAndGetDeviceInfo {device: req.device,
427
428                        responder: InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
429                            control_handle: std::mem::ManuallyDrop::new(control_handle),
430                            tx_id: header.tx_id,
431                        },
432                    })
433                }
434                _ => Err(fidl::Error::UnknownOrdinal {
435                    ordinal: header.ordinal,
436                    protocol_name: <InputDeviceRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
437                }),
438            }))
439            },
440        )
441    }
442}
443
444/// A TEST-ONLY protocol which injects `InputDevice`s into the
445/// input system.
446///
447/// This protocol is not intended for production use; products
448/// _should_ take measures to ensure this protocol is not
449/// routed to production components.
450#[derive(Debug)]
451pub enum InputDeviceRegistryRequest {
452    /// Registers an input device represented by `device`.
453    /// On registration, the InputDeviceRegistry starts listening for input reports on the
454    /// InputReportsReader returned by device.GetInputReportsReader().
455    Register {
456        device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
457        control_handle: InputDeviceRegistryControlHandle,
458    },
459    /// Registers an input device represented by `device` and return the device id of the
460    /// added test device.
461    /// On registration, the InputDeviceRegistry starts listening for input reports on the
462    /// InputReportsReader returned by device.GetInputReportsReader().
463    RegisterAndGetDeviceInfo {
464        device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
465        responder: InputDeviceRegistryRegisterAndGetDeviceInfoResponder,
466    },
467}
468
469impl InputDeviceRegistryRequest {
470    #[allow(irrefutable_let_patterns)]
471    pub fn into_register(
472        self,
473    ) -> Option<(
474        fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
475        InputDeviceRegistryControlHandle,
476    )> {
477        if let InputDeviceRegistryRequest::Register { device, control_handle } = self {
478            Some((device, control_handle))
479        } else {
480            None
481        }
482    }
483
484    #[allow(irrefutable_let_patterns)]
485    pub fn into_register_and_get_device_info(
486        self,
487    ) -> Option<(
488        fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
489        InputDeviceRegistryRegisterAndGetDeviceInfoResponder,
490    )> {
491        if let InputDeviceRegistryRequest::RegisterAndGetDeviceInfo { device, responder } = self {
492            Some((device, responder))
493        } else {
494            None
495        }
496    }
497
498    /// Name of the method defined in FIDL
499    pub fn method_name(&self) -> &'static str {
500        match *self {
501            InputDeviceRegistryRequest::Register { .. } => "register",
502            InputDeviceRegistryRequest::RegisterAndGetDeviceInfo { .. } => {
503                "register_and_get_device_info"
504            }
505        }
506    }
507}
508
509#[derive(Debug, Clone)]
510pub struct InputDeviceRegistryControlHandle {
511    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
512}
513
514impl fidl::endpoints::ControlHandle for InputDeviceRegistryControlHandle {
515    fn shutdown(&self) {
516        self.inner.shutdown()
517    }
518
519    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
520        self.inner.shutdown_with_epitaph(status)
521    }
522
523    fn is_closed(&self) -> bool {
524        self.inner.channel().is_closed()
525    }
526    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
527        self.inner.channel().on_closed()
528    }
529
530    #[cfg(target_os = "fuchsia")]
531    fn signal_peer(
532        &self,
533        clear_mask: zx::Signals,
534        set_mask: zx::Signals,
535    ) -> Result<(), zx_status::Status> {
536        use fidl::Peered;
537        self.inner.channel().signal_peer(clear_mask, set_mask)
538    }
539}
540
541impl InputDeviceRegistryControlHandle {}
542
543#[must_use = "FIDL methods require a response to be sent"]
544#[derive(Debug)]
545pub struct InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
546    control_handle: std::mem::ManuallyDrop<InputDeviceRegistryControlHandle>,
547    tx_id: u32,
548}
549
550/// Set the the channel to be shutdown (see [`InputDeviceRegistryControlHandle::shutdown`])
551/// if the responder is dropped without sending a response, so that the client
552/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
553impl std::ops::Drop for InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
554    fn drop(&mut self) {
555        self.control_handle.shutdown();
556        // Safety: drops once, never accessed again
557        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
558    }
559}
560
561impl fidl::endpoints::Responder for InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
562    type ControlHandle = InputDeviceRegistryControlHandle;
563
564    fn control_handle(&self) -> &InputDeviceRegistryControlHandle {
565        &self.control_handle
566    }
567
568    fn drop_without_shutdown(mut self) {
569        // Safety: drops once, never accessed again due to mem::forget
570        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
571        // Prevent Drop from running (which would shut down the channel)
572        std::mem::forget(self);
573    }
574}
575
576impl InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
577    /// Sends a response to the FIDL transaction.
578    ///
579    /// Sets the channel to shutdown if an error occurs.
580    pub fn send(
581        self,
582        mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
583    ) -> Result<(), fidl::Error> {
584        let _result = self.send_raw(payload);
585        if _result.is_err() {
586            self.control_handle.shutdown();
587        }
588        self.drop_without_shutdown();
589        _result
590    }
591
592    /// Similar to "send" but does not shutdown the channel if an error occurs.
593    pub fn send_no_shutdown_on_err(
594        self,
595        mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
596    ) -> Result<(), fidl::Error> {
597        let _result = self.send_raw(payload);
598        self.drop_without_shutdown();
599        _result
600    }
601
602    fn send_raw(
603        &self,
604        mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
605    ) -> Result<(), fidl::Error> {
606        self.control_handle.inner.send::<InputDeviceRegistryRegisterAndGetDeviceInfoResponse>(
607            &mut payload,
608            self.tx_id,
609            0x41db5035990763bc,
610            fidl::encoding::DynamicFlags::empty(),
611        )
612    }
613}
614
615mod internal {
616    use super::*;
617
618    impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoRequest {
619        type Borrowed<'a> = &'a mut Self;
620        fn take_or_borrow<'a>(
621            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
622        ) -> Self::Borrowed<'a> {
623            value
624        }
625    }
626
627    unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoRequest {
628        type Owned = Self;
629
630        #[inline(always)]
631        fn inline_align(_context: fidl::encoding::Context) -> usize {
632            4
633        }
634
635        #[inline(always)]
636        fn inline_size(_context: fidl::encoding::Context) -> usize {
637            4
638        }
639    }
640
641    unsafe impl
642        fidl::encoding::Encode<
643            InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
644            fidl::encoding::DefaultFuchsiaResourceDialect,
645        > for &mut InputDeviceRegistryRegisterAndGetDeviceInfoRequest
646    {
647        #[inline]
648        unsafe fn encode(
649            self,
650            encoder: &mut fidl::encoding::Encoder<
651                '_,
652                fidl::encoding::DefaultFuchsiaResourceDialect,
653            >,
654            offset: usize,
655            _depth: fidl::encoding::Depth,
656        ) -> fidl::Result<()> {
657            encoder
658                .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoRequest>(offset);
659            // Delegate to tuple encoding.
660            fidl::encoding::Encode::<
661                InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
662                fidl::encoding::DefaultFuchsiaResourceDialect,
663            >::encode(
664                (<fidl::encoding::Endpoint<
665                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
666                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
667                    &mut self.device
668                ),),
669                encoder,
670                offset,
671                _depth,
672            )
673        }
674    }
675    unsafe impl<
676        T0: fidl::encoding::Encode<
677                fidl::encoding::Endpoint<
678                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
679                >,
680                fidl::encoding::DefaultFuchsiaResourceDialect,
681            >,
682    >
683        fidl::encoding::Encode<
684            InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
685            fidl::encoding::DefaultFuchsiaResourceDialect,
686        > for (T0,)
687    {
688        #[inline]
689        unsafe fn encode(
690            self,
691            encoder: &mut fidl::encoding::Encoder<
692                '_,
693                fidl::encoding::DefaultFuchsiaResourceDialect,
694            >,
695            offset: usize,
696            depth: fidl::encoding::Depth,
697        ) -> fidl::Result<()> {
698            encoder
699                .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoRequest>(offset);
700            // Zero out padding regions. There's no need to apply masks
701            // because the unmasked parts will be overwritten by fields.
702            // Write the fields.
703            self.0.encode(encoder, offset + 0, depth)?;
704            Ok(())
705        }
706    }
707
708    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
709        for InputDeviceRegistryRegisterAndGetDeviceInfoRequest
710    {
711        #[inline(always)]
712        fn new_empty() -> Self {
713            Self {
714                device: fidl::new_empty!(
715                    fidl::encoding::Endpoint<
716                        fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
717                    >,
718                    fidl::encoding::DefaultFuchsiaResourceDialect
719                ),
720            }
721        }
722
723        #[inline]
724        unsafe fn decode(
725            &mut self,
726            decoder: &mut fidl::encoding::Decoder<
727                '_,
728                fidl::encoding::DefaultFuchsiaResourceDialect,
729            >,
730            offset: usize,
731            _depth: fidl::encoding::Depth,
732        ) -> fidl::Result<()> {
733            decoder.debug_check_bounds::<Self>(offset);
734            // Verify that padding bytes are zero.
735            fidl::decode!(
736                fidl::encoding::Endpoint<
737                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
738                >,
739                fidl::encoding::DefaultFuchsiaResourceDialect,
740                &mut self.device,
741                decoder,
742                offset + 0,
743                _depth
744            )?;
745            Ok(())
746        }
747    }
748
749    impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterRequest {
750        type Borrowed<'a> = &'a mut Self;
751        fn take_or_borrow<'a>(
752            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
753        ) -> Self::Borrowed<'a> {
754            value
755        }
756    }
757
758    unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterRequest {
759        type Owned = Self;
760
761        #[inline(always)]
762        fn inline_align(_context: fidl::encoding::Context) -> usize {
763            4
764        }
765
766        #[inline(always)]
767        fn inline_size(_context: fidl::encoding::Context) -> usize {
768            4
769        }
770    }
771
772    unsafe impl
773        fidl::encoding::Encode<
774            InputDeviceRegistryRegisterRequest,
775            fidl::encoding::DefaultFuchsiaResourceDialect,
776        > for &mut InputDeviceRegistryRegisterRequest
777    {
778        #[inline]
779        unsafe fn encode(
780            self,
781            encoder: &mut fidl::encoding::Encoder<
782                '_,
783                fidl::encoding::DefaultFuchsiaResourceDialect,
784            >,
785            offset: usize,
786            _depth: fidl::encoding::Depth,
787        ) -> fidl::Result<()> {
788            encoder.debug_check_bounds::<InputDeviceRegistryRegisterRequest>(offset);
789            // Delegate to tuple encoding.
790            fidl::encoding::Encode::<
791                InputDeviceRegistryRegisterRequest,
792                fidl::encoding::DefaultFuchsiaResourceDialect,
793            >::encode(
794                (<fidl::encoding::Endpoint<
795                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
796                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
797                    &mut self.device
798                ),),
799                encoder,
800                offset,
801                _depth,
802            )
803        }
804    }
805    unsafe impl<
806        T0: fidl::encoding::Encode<
807                fidl::encoding::Endpoint<
808                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
809                >,
810                fidl::encoding::DefaultFuchsiaResourceDialect,
811            >,
812    >
813        fidl::encoding::Encode<
814            InputDeviceRegistryRegisterRequest,
815            fidl::encoding::DefaultFuchsiaResourceDialect,
816        > for (T0,)
817    {
818        #[inline]
819        unsafe fn encode(
820            self,
821            encoder: &mut fidl::encoding::Encoder<
822                '_,
823                fidl::encoding::DefaultFuchsiaResourceDialect,
824            >,
825            offset: usize,
826            depth: fidl::encoding::Depth,
827        ) -> fidl::Result<()> {
828            encoder.debug_check_bounds::<InputDeviceRegistryRegisterRequest>(offset);
829            // Zero out padding regions. There's no need to apply masks
830            // because the unmasked parts will be overwritten by fields.
831            // Write the fields.
832            self.0.encode(encoder, offset + 0, depth)?;
833            Ok(())
834        }
835    }
836
837    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
838        for InputDeviceRegistryRegisterRequest
839    {
840        #[inline(always)]
841        fn new_empty() -> Self {
842            Self {
843                device: fidl::new_empty!(
844                    fidl::encoding::Endpoint<
845                        fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
846                    >,
847                    fidl::encoding::DefaultFuchsiaResourceDialect
848                ),
849            }
850        }
851
852        #[inline]
853        unsafe fn decode(
854            &mut self,
855            decoder: &mut fidl::encoding::Decoder<
856                '_,
857                fidl::encoding::DefaultFuchsiaResourceDialect,
858            >,
859            offset: usize,
860            _depth: fidl::encoding::Depth,
861        ) -> fidl::Result<()> {
862            decoder.debug_check_bounds::<Self>(offset);
863            // Verify that padding bytes are zero.
864            fidl::decode!(
865                fidl::encoding::Endpoint<
866                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
867                >,
868                fidl::encoding::DefaultFuchsiaResourceDialect,
869                &mut self.device,
870                decoder,
871                offset + 0,
872                _depth
873            )?;
874            Ok(())
875        }
876    }
877
878    impl InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
879        #[inline(always)]
880        fn max_ordinal_present(&self) -> u64 {
881            if let Some(_) = self.device_id {
882                return 1;
883            }
884            0
885        }
886    }
887
888    impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
889        type Borrowed<'a> = &'a mut Self;
890        fn take_or_borrow<'a>(
891            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
892        ) -> Self::Borrowed<'a> {
893            value
894        }
895    }
896
897    unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
898        type Owned = Self;
899
900        #[inline(always)]
901        fn inline_align(_context: fidl::encoding::Context) -> usize {
902            8
903        }
904
905        #[inline(always)]
906        fn inline_size(_context: fidl::encoding::Context) -> usize {
907            16
908        }
909    }
910
911    unsafe impl
912        fidl::encoding::Encode<
913            InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
914            fidl::encoding::DefaultFuchsiaResourceDialect,
915        > for &mut InputDeviceRegistryRegisterAndGetDeviceInfoResponse
916    {
917        unsafe fn encode(
918            self,
919            encoder: &mut fidl::encoding::Encoder<
920                '_,
921                fidl::encoding::DefaultFuchsiaResourceDialect,
922            >,
923            offset: usize,
924            mut depth: fidl::encoding::Depth,
925        ) -> fidl::Result<()> {
926            encoder
927                .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoResponse>(offset);
928            // Vector header
929            let max_ordinal: u64 = self.max_ordinal_present();
930            encoder.write_num(max_ordinal, offset);
931            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
932            // Calling encoder.out_of_line_offset(0) is not allowed.
933            if max_ordinal == 0 {
934                return Ok(());
935            }
936            depth.increment()?;
937            let envelope_size = 8;
938            let bytes_len = max_ordinal as usize * envelope_size;
939            #[allow(unused_variables)]
940            let offset = encoder.out_of_line_offset(bytes_len);
941            let mut _prev_end_offset: usize = 0;
942            if 1 > max_ordinal {
943                return Ok(());
944            }
945
946            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
947            // are envelope_size bytes.
948            let cur_offset: usize = (1 - 1) * envelope_size;
949
950            // Zero reserved fields.
951            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
952
953            // Safety:
954            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
955            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
956            //   envelope_size bytes, there is always sufficient room.
957            fidl::encoding::encode_in_envelope_optional::<
958                u32,
959                fidl::encoding::DefaultFuchsiaResourceDialect,
960            >(
961                self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
962                encoder,
963                offset + cur_offset,
964                depth,
965            )?;
966
967            _prev_end_offset = cur_offset + envelope_size;
968
969            Ok(())
970        }
971    }
972
973    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
974        for InputDeviceRegistryRegisterAndGetDeviceInfoResponse
975    {
976        #[inline(always)]
977        fn new_empty() -> Self {
978            Self::default()
979        }
980
981        unsafe fn decode(
982            &mut self,
983            decoder: &mut fidl::encoding::Decoder<
984                '_,
985                fidl::encoding::DefaultFuchsiaResourceDialect,
986            >,
987            offset: usize,
988            mut depth: fidl::encoding::Depth,
989        ) -> fidl::Result<()> {
990            decoder.debug_check_bounds::<Self>(offset);
991            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
992                None => return Err(fidl::Error::NotNullable),
993                Some(len) => len,
994            };
995            // Calling decoder.out_of_line_offset(0) is not allowed.
996            if len == 0 {
997                return Ok(());
998            };
999            depth.increment()?;
1000            let envelope_size = 8;
1001            let bytes_len = len * envelope_size;
1002            let offset = decoder.out_of_line_offset(bytes_len)?;
1003            // Decode the envelope for each type.
1004            let mut _next_ordinal_to_read = 0;
1005            let mut next_offset = offset;
1006            let end_offset = offset + bytes_len;
1007            _next_ordinal_to_read += 1;
1008            if next_offset >= end_offset {
1009                return Ok(());
1010            }
1011
1012            // Decode unknown envelopes for gaps in ordinals.
1013            while _next_ordinal_to_read < 1 {
1014                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1015                _next_ordinal_to_read += 1;
1016                next_offset += envelope_size;
1017            }
1018
1019            let next_out_of_line = decoder.next_out_of_line();
1020            let handles_before = decoder.remaining_handles();
1021            if let Some((inlined, num_bytes, num_handles)) =
1022                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1023            {
1024                let member_inline_size =
1025                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1026                if inlined != (member_inline_size <= 4) {
1027                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1028                }
1029                let inner_offset;
1030                let mut inner_depth = depth.clone();
1031                if inlined {
1032                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1033                    inner_offset = next_offset;
1034                } else {
1035                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1036                    inner_depth.increment()?;
1037                }
1038                let val_ref = self.device_id.get_or_insert_with(|| {
1039                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1040                });
1041                fidl::decode!(
1042                    u32,
1043                    fidl::encoding::DefaultFuchsiaResourceDialect,
1044                    val_ref,
1045                    decoder,
1046                    inner_offset,
1047                    inner_depth
1048                )?;
1049                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1050                {
1051                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1052                }
1053                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1054                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1055                }
1056            }
1057
1058            next_offset += envelope_size;
1059
1060            // Decode the remaining unknown envelopes.
1061            while next_offset < end_offset {
1062                _next_ordinal_to_read += 1;
1063                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1064                next_offset += envelope_size;
1065            }
1066
1067            Ok(())
1068        }
1069    }
1070}