Skip to main content

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        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    /// Waits until an event arrives and returns it. It is safe for other
107    /// threads to make concurrent requests while waiting for an event.
108    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    /// 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            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    /// Create a new Proxy for fuchsia.input.injection/InputDeviceRegistry.
200    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    /// Get a Stream of events from the remote end of the protocol.
207    ///
208    /// # Panics
209    ///
210    /// Panics if the event stream was already taken.
211    pub fn take_event_stream(&self) -> InputDeviceRegistryEventStream {
212        InputDeviceRegistryEventStream { event_receiver: self.client.take_event_receiver() }
213    }
214
215    /// Registers an input device represented by `device`.
216    /// On registration, the InputDeviceRegistry starts listening for input reports on the
217    /// InputReportsReader returned by device.GetInputReportsReader().
218    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    /// Registers an input device represented by `device` and return the device id of the
226    /// added test device.
227    /// On registration, the InputDeviceRegistry starts listening for input reports on the
228    /// InputReportsReader returned by device.GetInputReportsReader().
229    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    /// Decodes a message buffer as a [`InputDeviceRegistryEvent`].
316    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
332/// A Stream of incoming requests for fuchsia.input.injection/InputDeviceRegistry.
333pub 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                // A message has been received from the channel
405                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/// A TEST-ONLY protocol which injects `InputDevice`s into the
446/// input system.
447///
448/// This protocol is not intended for production use; products
449/// _should_ take measures to ensure this protocol is not
450/// routed to production components.
451#[derive(Debug)]
452pub enum InputDeviceRegistryRequest {
453    /// Registers an input device represented by `device`.
454    /// On registration, the InputDeviceRegistry starts listening for input reports on the
455    /// InputReportsReader returned by device.GetInputReportsReader().
456    Register {
457        device: fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
458        control_handle: InputDeviceRegistryControlHandle,
459    },
460    /// Registers an input device represented by `device` and return the device id of the
461    /// added test device.
462    /// On registration, the InputDeviceRegistry starts listening for input reports on the
463    /// InputReportsReader returned by device.GetInputReportsReader().
464    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    /// Name of the method defined in FIDL
500    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 InputDeviceRegistryControlHandle {
516    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
517        self.inner.shutdown_with_epitaph(status.into())
518    }
519}
520
521impl fidl::endpoints::ControlHandle for InputDeviceRegistryControlHandle {
522    fn shutdown(&self) {
523        self.inner.shutdown()
524    }
525
526    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
527        self.inner.shutdown_with_epitaph(status)
528    }
529
530    fn is_closed(&self) -> bool {
531        self.inner.channel().is_closed()
532    }
533    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
534        self.inner.channel().on_closed()
535    }
536
537    #[cfg(target_os = "fuchsia")]
538    fn signal_peer(
539        &self,
540        clear_mask: zx::Signals,
541        set_mask: zx::Signals,
542    ) -> Result<(), zx_status::Status> {
543        use fidl::Peered;
544        self.inner.channel().signal_peer(clear_mask, set_mask)
545    }
546}
547
548impl InputDeviceRegistryControlHandle {}
549
550#[must_use = "FIDL methods require a response to be sent"]
551#[derive(Debug)]
552pub struct InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
553    control_handle: std::mem::ManuallyDrop<InputDeviceRegistryControlHandle>,
554    tx_id: u32,
555}
556
557/// Set the the channel to be shutdown (see [`InputDeviceRegistryControlHandle::shutdown`])
558/// if the responder is dropped without sending a response, so that the client
559/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
560impl std::ops::Drop for InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
561    fn drop(&mut self) {
562        self.control_handle.shutdown();
563        // Safety: drops once, never accessed again
564        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
565    }
566}
567
568impl fidl::endpoints::Responder for InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
569    type ControlHandle = InputDeviceRegistryControlHandle;
570
571    fn control_handle(&self) -> &InputDeviceRegistryControlHandle {
572        &self.control_handle
573    }
574
575    fn drop_without_shutdown(mut self) {
576        // Safety: drops once, never accessed again due to mem::forget
577        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
578        // Prevent Drop from running (which would shut down the channel)
579        std::mem::forget(self);
580    }
581}
582
583impl InputDeviceRegistryRegisterAndGetDeviceInfoResponder {
584    /// Sends a response to the FIDL transaction.
585    ///
586    /// Sets the channel to shutdown if an error occurs.
587    pub fn send(
588        self,
589        mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
590    ) -> Result<(), fidl::Error> {
591        let _result = self.send_raw(payload);
592        if _result.is_err() {
593            self.control_handle.shutdown();
594        }
595        self.drop_without_shutdown();
596        _result
597    }
598
599    /// Similar to "send" but does not shutdown the channel if an error occurs.
600    pub fn send_no_shutdown_on_err(
601        self,
602        mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
603    ) -> Result<(), fidl::Error> {
604        let _result = self.send_raw(payload);
605        self.drop_without_shutdown();
606        _result
607    }
608
609    fn send_raw(
610        &self,
611        mut payload: InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
612    ) -> Result<(), fidl::Error> {
613        self.control_handle.inner.send::<InputDeviceRegistryRegisterAndGetDeviceInfoResponse>(
614            &mut payload,
615            self.tx_id,
616            0x41db5035990763bc,
617            fidl::encoding::DynamicFlags::empty(),
618        )
619    }
620}
621
622mod internal {
623    use super::*;
624
625    impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoRequest {
626        type Borrowed<'a> = &'a mut Self;
627        fn take_or_borrow<'a>(
628            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
629        ) -> Self::Borrowed<'a> {
630            value
631        }
632    }
633
634    unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoRequest {
635        type Owned = Self;
636
637        #[inline(always)]
638        fn inline_align(_context: fidl::encoding::Context) -> usize {
639            4
640        }
641
642        #[inline(always)]
643        fn inline_size(_context: fidl::encoding::Context) -> usize {
644            4
645        }
646    }
647
648    unsafe impl
649        fidl::encoding::Encode<
650            InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
651            fidl::encoding::DefaultFuchsiaResourceDialect,
652        > for &mut InputDeviceRegistryRegisterAndGetDeviceInfoRequest
653    {
654        #[inline]
655        unsafe fn encode(
656            self,
657            encoder: &mut fidl::encoding::Encoder<
658                '_,
659                fidl::encoding::DefaultFuchsiaResourceDialect,
660            >,
661            offset: usize,
662            _depth: fidl::encoding::Depth,
663        ) -> fidl::Result<()> {
664            encoder
665                .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoRequest>(offset);
666            // Delegate to tuple encoding.
667            fidl::encoding::Encode::<
668                InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
669                fidl::encoding::DefaultFuchsiaResourceDialect,
670            >::encode(
671                (<fidl::encoding::Endpoint<
672                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
673                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
674                    &mut self.device
675                ),),
676                encoder,
677                offset,
678                _depth,
679            )
680        }
681    }
682    unsafe impl<
683        T0: fidl::encoding::Encode<
684                fidl::encoding::Endpoint<
685                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
686                >,
687                fidl::encoding::DefaultFuchsiaResourceDialect,
688            >,
689    >
690        fidl::encoding::Encode<
691            InputDeviceRegistryRegisterAndGetDeviceInfoRequest,
692            fidl::encoding::DefaultFuchsiaResourceDialect,
693        > for (T0,)
694    {
695        #[inline]
696        unsafe fn encode(
697            self,
698            encoder: &mut fidl::encoding::Encoder<
699                '_,
700                fidl::encoding::DefaultFuchsiaResourceDialect,
701            >,
702            offset: usize,
703            depth: fidl::encoding::Depth,
704        ) -> fidl::Result<()> {
705            encoder
706                .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoRequest>(offset);
707            // Zero out padding regions. There's no need to apply masks
708            // because the unmasked parts will be overwritten by fields.
709            // Write the fields.
710            self.0.encode(encoder, offset + 0, depth)?;
711            Ok(())
712        }
713    }
714
715    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
716        for InputDeviceRegistryRegisterAndGetDeviceInfoRequest
717    {
718        #[inline(always)]
719        fn new_empty() -> Self {
720            Self {
721                device: fidl::new_empty!(
722                    fidl::encoding::Endpoint<
723                        fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
724                    >,
725                    fidl::encoding::DefaultFuchsiaResourceDialect
726                ),
727            }
728        }
729
730        #[inline]
731        unsafe fn decode(
732            &mut self,
733            decoder: &mut fidl::encoding::Decoder<
734                '_,
735                fidl::encoding::DefaultFuchsiaResourceDialect,
736            >,
737            offset: usize,
738            _depth: fidl::encoding::Depth,
739        ) -> fidl::Result<()> {
740            decoder.debug_check_bounds::<Self>(offset);
741            // Verify that padding bytes are zero.
742            fidl::decode!(
743                fidl::encoding::Endpoint<
744                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
745                >,
746                fidl::encoding::DefaultFuchsiaResourceDialect,
747                &mut self.device,
748                decoder,
749                offset + 0,
750                _depth
751            )?;
752            Ok(())
753        }
754    }
755
756    impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterRequest {
757        type Borrowed<'a> = &'a mut Self;
758        fn take_or_borrow<'a>(
759            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
760        ) -> Self::Borrowed<'a> {
761            value
762        }
763    }
764
765    unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterRequest {
766        type Owned = Self;
767
768        #[inline(always)]
769        fn inline_align(_context: fidl::encoding::Context) -> usize {
770            4
771        }
772
773        #[inline(always)]
774        fn inline_size(_context: fidl::encoding::Context) -> usize {
775            4
776        }
777    }
778
779    unsafe impl
780        fidl::encoding::Encode<
781            InputDeviceRegistryRegisterRequest,
782            fidl::encoding::DefaultFuchsiaResourceDialect,
783        > for &mut InputDeviceRegistryRegisterRequest
784    {
785        #[inline]
786        unsafe fn encode(
787            self,
788            encoder: &mut fidl::encoding::Encoder<
789                '_,
790                fidl::encoding::DefaultFuchsiaResourceDialect,
791            >,
792            offset: usize,
793            _depth: fidl::encoding::Depth,
794        ) -> fidl::Result<()> {
795            encoder.debug_check_bounds::<InputDeviceRegistryRegisterRequest>(offset);
796            // Delegate to tuple encoding.
797            fidl::encoding::Encode::<
798                InputDeviceRegistryRegisterRequest,
799                fidl::encoding::DefaultFuchsiaResourceDialect,
800            >::encode(
801                (<fidl::encoding::Endpoint<
802                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
803                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
804                    &mut self.device
805                ),),
806                encoder,
807                offset,
808                _depth,
809            )
810        }
811    }
812    unsafe impl<
813        T0: fidl::encoding::Encode<
814                fidl::encoding::Endpoint<
815                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
816                >,
817                fidl::encoding::DefaultFuchsiaResourceDialect,
818            >,
819    >
820        fidl::encoding::Encode<
821            InputDeviceRegistryRegisterRequest,
822            fidl::encoding::DefaultFuchsiaResourceDialect,
823        > for (T0,)
824    {
825        #[inline]
826        unsafe fn encode(
827            self,
828            encoder: &mut fidl::encoding::Encoder<
829                '_,
830                fidl::encoding::DefaultFuchsiaResourceDialect,
831            >,
832            offset: usize,
833            depth: fidl::encoding::Depth,
834        ) -> fidl::Result<()> {
835            encoder.debug_check_bounds::<InputDeviceRegistryRegisterRequest>(offset);
836            // Zero out padding regions. There's no need to apply masks
837            // because the unmasked parts will be overwritten by fields.
838            // Write the fields.
839            self.0.encode(encoder, offset + 0, depth)?;
840            Ok(())
841        }
842    }
843
844    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
845        for InputDeviceRegistryRegisterRequest
846    {
847        #[inline(always)]
848        fn new_empty() -> Self {
849            Self {
850                device: fidl::new_empty!(
851                    fidl::encoding::Endpoint<
852                        fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
853                    >,
854                    fidl::encoding::DefaultFuchsiaResourceDialect
855                ),
856            }
857        }
858
859        #[inline]
860        unsafe fn decode(
861            &mut self,
862            decoder: &mut fidl::encoding::Decoder<
863                '_,
864                fidl::encoding::DefaultFuchsiaResourceDialect,
865            >,
866            offset: usize,
867            _depth: fidl::encoding::Depth,
868        ) -> fidl::Result<()> {
869            decoder.debug_check_bounds::<Self>(offset);
870            // Verify that padding bytes are zero.
871            fidl::decode!(
872                fidl::encoding::Endpoint<
873                    fidl::endpoints::ClientEnd<fidl_fuchsia_input_report::InputDeviceMarker>,
874                >,
875                fidl::encoding::DefaultFuchsiaResourceDialect,
876                &mut self.device,
877                decoder,
878                offset + 0,
879                _depth
880            )?;
881            Ok(())
882        }
883    }
884
885    impl InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
886        #[inline(always)]
887        fn max_ordinal_present(&self) -> u64 {
888            if let Some(_) = self.device_id {
889                return 1;
890            }
891            0
892        }
893    }
894
895    impl fidl::encoding::ResourceTypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
896        type Borrowed<'a> = &'a mut Self;
897        fn take_or_borrow<'a>(
898            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
899        ) -> Self::Borrowed<'a> {
900            value
901        }
902    }
903
904    unsafe impl fidl::encoding::TypeMarker for InputDeviceRegistryRegisterAndGetDeviceInfoResponse {
905        type Owned = Self;
906
907        #[inline(always)]
908        fn inline_align(_context: fidl::encoding::Context) -> usize {
909            8
910        }
911
912        #[inline(always)]
913        fn inline_size(_context: fidl::encoding::Context) -> usize {
914            16
915        }
916    }
917
918    unsafe impl
919        fidl::encoding::Encode<
920            InputDeviceRegistryRegisterAndGetDeviceInfoResponse,
921            fidl::encoding::DefaultFuchsiaResourceDialect,
922        > for &mut InputDeviceRegistryRegisterAndGetDeviceInfoResponse
923    {
924        unsafe fn encode(
925            self,
926            encoder: &mut fidl::encoding::Encoder<
927                '_,
928                fidl::encoding::DefaultFuchsiaResourceDialect,
929            >,
930            offset: usize,
931            mut depth: fidl::encoding::Depth,
932        ) -> fidl::Result<()> {
933            encoder
934                .debug_check_bounds::<InputDeviceRegistryRegisterAndGetDeviceInfoResponse>(offset);
935            // Vector header
936            let max_ordinal: u64 = self.max_ordinal_present();
937            encoder.write_num(max_ordinal, offset);
938            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
939            // Calling encoder.out_of_line_offset(0) is not allowed.
940            if max_ordinal == 0 {
941                return Ok(());
942            }
943            depth.increment()?;
944            let envelope_size = 8;
945            let bytes_len = max_ordinal as usize * envelope_size;
946            #[allow(unused_variables)]
947            let offset = encoder.out_of_line_offset(bytes_len);
948            let mut _prev_end_offset: usize = 0;
949            if 1 > max_ordinal {
950                return Ok(());
951            }
952
953            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
954            // are envelope_size bytes.
955            let cur_offset: usize = (1 - 1) * envelope_size;
956
957            // Zero reserved fields.
958            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
959
960            // Safety:
961            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
962            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
963            //   envelope_size bytes, there is always sufficient room.
964            fidl::encoding::encode_in_envelope_optional::<
965                u32,
966                fidl::encoding::DefaultFuchsiaResourceDialect,
967            >(
968                self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
969                encoder,
970                offset + cur_offset,
971                depth,
972            )?;
973
974            _prev_end_offset = cur_offset + envelope_size;
975
976            Ok(())
977        }
978    }
979
980    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
981        for InputDeviceRegistryRegisterAndGetDeviceInfoResponse
982    {
983        #[inline(always)]
984        fn new_empty() -> Self {
985            Self::default()
986        }
987
988        unsafe fn decode(
989            &mut self,
990            decoder: &mut fidl::encoding::Decoder<
991                '_,
992                fidl::encoding::DefaultFuchsiaResourceDialect,
993            >,
994            offset: usize,
995            mut depth: fidl::encoding::Depth,
996        ) -> fidl::Result<()> {
997            decoder.debug_check_bounds::<Self>(offset);
998            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
999                None => return Err(fidl::Error::NotNullable),
1000                Some(len) => len,
1001            };
1002            // Calling decoder.out_of_line_offset(0) is not allowed.
1003            if len == 0 {
1004                return Ok(());
1005            };
1006            depth.increment()?;
1007            let envelope_size = 8;
1008            let bytes_len = len * envelope_size;
1009            let offset = decoder.out_of_line_offset(bytes_len)?;
1010            // Decode the envelope for each type.
1011            let mut _next_ordinal_to_read = 0;
1012            let mut next_offset = offset;
1013            let end_offset = offset + bytes_len;
1014            _next_ordinal_to_read += 1;
1015            if next_offset >= end_offset {
1016                return Ok(());
1017            }
1018
1019            // Decode unknown envelopes for gaps in ordinals.
1020            while _next_ordinal_to_read < 1 {
1021                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1022                _next_ordinal_to_read += 1;
1023                next_offset += envelope_size;
1024            }
1025
1026            let next_out_of_line = decoder.next_out_of_line();
1027            let handles_before = decoder.remaining_handles();
1028            if let Some((inlined, num_bytes, num_handles)) =
1029                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1030            {
1031                let member_inline_size =
1032                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1033                if inlined != (member_inline_size <= 4) {
1034                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1035                }
1036                let inner_offset;
1037                let mut inner_depth = depth.clone();
1038                if inlined {
1039                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1040                    inner_offset = next_offset;
1041                } else {
1042                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1043                    inner_depth.increment()?;
1044                }
1045                let val_ref = self.device_id.get_or_insert_with(|| {
1046                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1047                });
1048                fidl::decode!(
1049                    u32,
1050                    fidl::encoding::DefaultFuchsiaResourceDialect,
1051                    val_ref,
1052                    decoder,
1053                    inner_offset,
1054                    inner_depth
1055                )?;
1056                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1057                {
1058                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1059                }
1060                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1061                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1062                }
1063            }
1064
1065            next_offset += envelope_size;
1066
1067            // Decode the remaining unknown envelopes.
1068            while next_offset < end_offset {
1069                _next_ordinal_to_read += 1;
1070                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1071                next_offset += envelope_size;
1072            }
1073
1074            Ok(())
1075        }
1076    }
1077}