Skip to main content

fidl_fuchsia_hardware_input/
fidl_fuchsia_hardware_input.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_hardware_input_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ControllerOpenSessionRequest {
16    pub session: fidl::endpoints::ServerEnd<DeviceMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for ControllerOpenSessionRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct DeviceGetDeviceReportsReaderRequest {
26    pub reader: fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for DeviceGetDeviceReportsReaderRequest
31{
32}
33
34#[derive(Debug, PartialEq)]
35pub struct DeviceReportsReaderReadReportsResponse {
36    pub reports: Vec<fidl_fuchsia_hardware_hidbus::Report>,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
40    for DeviceReportsReaderReadReportsResponse
41{
42}
43
44#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct DeviceGetReportsEventResponse {
46    pub event: fidl::Event,
47}
48
49impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
50    for DeviceGetReportsEventResponse
51{
52}
53
54#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
55pub struct ControllerMarker;
56
57impl fidl::endpoints::ProtocolMarker for ControllerMarker {
58    type Proxy = ControllerProxy;
59    type RequestStream = ControllerRequestStream;
60    #[cfg(target_os = "fuchsia")]
61    type SynchronousProxy = ControllerSynchronousProxy;
62
63    const DEBUG_NAME: &'static str = "(anonymous) Controller";
64}
65
66pub trait ControllerProxyInterface: Send + Sync {
67    fn r#open_session(
68        &self,
69        session: fidl::endpoints::ServerEnd<DeviceMarker>,
70    ) -> Result<(), fidl::Error>;
71}
72#[derive(Debug)]
73#[cfg(target_os = "fuchsia")]
74pub struct ControllerSynchronousProxy {
75    client: fidl::client::sync::Client,
76}
77
78#[cfg(target_os = "fuchsia")]
79impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
80    type Proxy = ControllerProxy;
81    type Protocol = ControllerMarker;
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 ControllerSynchronousProxy {
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<ControllerEvent, fidl::Error> {
112        ControllerEvent::decode(self.client.wait_for_event::<ControllerMarker>(deadline)?)
113    }
114
115    /// Opens a new session on the device.
116    pub fn r#open_session(
117        &self,
118        mut session: fidl::endpoints::ServerEnd<DeviceMarker>,
119    ) -> Result<(), fidl::Error> {
120        self.client.send::<ControllerOpenSessionRequest>(
121            (session,),
122            0x404db87008999427,
123            fidl::encoding::DynamicFlags::empty(),
124        )
125    }
126}
127
128#[cfg(target_os = "fuchsia")]
129impl From<ControllerSynchronousProxy> for zx::NullableHandle {
130    fn from(value: ControllerSynchronousProxy) -> Self {
131        value.into_channel().into()
132    }
133}
134
135#[cfg(target_os = "fuchsia")]
136impl From<fidl::Channel> for ControllerSynchronousProxy {
137    fn from(value: fidl::Channel) -> Self {
138        Self::new(value)
139    }
140}
141
142#[cfg(target_os = "fuchsia")]
143impl fidl::endpoints::FromClient for ControllerSynchronousProxy {
144    type Protocol = ControllerMarker;
145
146    fn from_client(value: fidl::endpoints::ClientEnd<ControllerMarker>) -> Self {
147        Self::new(value.into_channel())
148    }
149}
150
151#[derive(Debug, Clone)]
152pub struct ControllerProxy {
153    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
154}
155
156impl fidl::endpoints::Proxy for ControllerProxy {
157    type Protocol = ControllerMarker;
158
159    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
160        Self::new(inner)
161    }
162
163    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
164        self.client.into_channel().map_err(|client| Self { client })
165    }
166
167    fn as_channel(&self) -> &::fidl::AsyncChannel {
168        self.client.as_channel()
169    }
170}
171
172impl ControllerProxy {
173    /// Create a new Proxy for fuchsia.hardware.input/Controller.
174    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
175        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
176        Self { client: fidl::client::Client::new(channel, protocol_name) }
177    }
178
179    /// Get a Stream of events from the remote end of the protocol.
180    ///
181    /// # Panics
182    ///
183    /// Panics if the event stream was already taken.
184    pub fn take_event_stream(&self) -> ControllerEventStream {
185        ControllerEventStream { event_receiver: self.client.take_event_receiver() }
186    }
187
188    /// Opens a new session on the device.
189    pub fn r#open_session(
190        &self,
191        mut session: fidl::endpoints::ServerEnd<DeviceMarker>,
192    ) -> Result<(), fidl::Error> {
193        ControllerProxyInterface::r#open_session(self, session)
194    }
195}
196
197impl ControllerProxyInterface for ControllerProxy {
198    fn r#open_session(
199        &self,
200        mut session: fidl::endpoints::ServerEnd<DeviceMarker>,
201    ) -> Result<(), fidl::Error> {
202        self.client.send::<ControllerOpenSessionRequest>(
203            (session,),
204            0x404db87008999427,
205            fidl::encoding::DynamicFlags::empty(),
206        )
207    }
208}
209
210pub struct ControllerEventStream {
211    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
212}
213
214impl std::marker::Unpin for ControllerEventStream {}
215
216impl futures::stream::FusedStream for ControllerEventStream {
217    fn is_terminated(&self) -> bool {
218        self.event_receiver.is_terminated()
219    }
220}
221
222impl futures::Stream for ControllerEventStream {
223    type Item = Result<ControllerEvent, fidl::Error>;
224
225    fn poll_next(
226        mut self: std::pin::Pin<&mut Self>,
227        cx: &mut std::task::Context<'_>,
228    ) -> std::task::Poll<Option<Self::Item>> {
229        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
230            &mut self.event_receiver,
231            cx
232        )?) {
233            Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
234            None => std::task::Poll::Ready(None),
235        }
236    }
237}
238
239#[derive(Debug)]
240pub enum ControllerEvent {}
241
242impl ControllerEvent {
243    /// Decodes a message buffer as a [`ControllerEvent`].
244    fn decode(
245        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
246    ) -> Result<ControllerEvent, fidl::Error> {
247        let (bytes, _handles) = buf.split_mut();
248        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
249        debug_assert_eq!(tx_header.tx_id, 0);
250        match tx_header.ordinal {
251            _ => Err(fidl::Error::UnknownOrdinal {
252                ordinal: tx_header.ordinal,
253                protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
254            }),
255        }
256    }
257}
258
259/// A Stream of incoming requests for fuchsia.hardware.input/Controller.
260pub struct ControllerRequestStream {
261    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
262    is_terminated: bool,
263}
264
265impl std::marker::Unpin for ControllerRequestStream {}
266
267impl futures::stream::FusedStream for ControllerRequestStream {
268    fn is_terminated(&self) -> bool {
269        self.is_terminated
270    }
271}
272
273impl fidl::endpoints::RequestStream for ControllerRequestStream {
274    type Protocol = ControllerMarker;
275    type ControlHandle = ControllerControlHandle;
276
277    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
278        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
279    }
280
281    fn control_handle(&self) -> Self::ControlHandle {
282        ControllerControlHandle { inner: self.inner.clone() }
283    }
284
285    fn into_inner(
286        self,
287    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
288    {
289        (self.inner, self.is_terminated)
290    }
291
292    fn from_inner(
293        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
294        is_terminated: bool,
295    ) -> Self {
296        Self { inner, is_terminated }
297    }
298}
299
300impl futures::Stream for ControllerRequestStream {
301    type Item = Result<ControllerRequest, fidl::Error>;
302
303    fn poll_next(
304        mut self: std::pin::Pin<&mut Self>,
305        cx: &mut std::task::Context<'_>,
306    ) -> std::task::Poll<Option<Self::Item>> {
307        let this = &mut *self;
308        if this.inner.check_shutdown(cx) {
309            this.is_terminated = true;
310            return std::task::Poll::Ready(None);
311        }
312        if this.is_terminated {
313            panic!("polled ControllerRequestStream after completion");
314        }
315        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
316            |bytes, handles| {
317                match this.inner.channel().read_etc(cx, bytes, handles) {
318                    std::task::Poll::Ready(Ok(())) => {}
319                    std::task::Poll::Pending => return std::task::Poll::Pending,
320                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
321                        this.is_terminated = true;
322                        return std::task::Poll::Ready(None);
323                    }
324                    std::task::Poll::Ready(Err(e)) => {
325                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
326                            e.into(),
327                        ))));
328                    }
329                }
330
331                // A message has been received from the channel
332                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
333
334                std::task::Poll::Ready(Some(match header.ordinal {
335                    0x404db87008999427 => {
336                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
337                        let mut req = fidl::new_empty!(
338                            ControllerOpenSessionRequest,
339                            fidl::encoding::DefaultFuchsiaResourceDialect
340                        );
341                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerOpenSessionRequest>(&header, _body_bytes, handles, &mut req)?;
342                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
343                        Ok(ControllerRequest::OpenSession { session: req.session, control_handle })
344                    }
345                    _ => Err(fidl::Error::UnknownOrdinal {
346                        ordinal: header.ordinal,
347                        protocol_name:
348                            <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
349                    }),
350                }))
351            },
352        )
353    }
354}
355
356#[derive(Debug)]
357pub enum ControllerRequest {
358    /// Opens a new session on the device.
359    OpenSession {
360        session: fidl::endpoints::ServerEnd<DeviceMarker>,
361        control_handle: ControllerControlHandle,
362    },
363}
364
365impl ControllerRequest {
366    #[allow(irrefutable_let_patterns)]
367    pub fn into_open_session(
368        self,
369    ) -> Option<(fidl::endpoints::ServerEnd<DeviceMarker>, ControllerControlHandle)> {
370        if let ControllerRequest::OpenSession { session, control_handle } = self {
371            Some((session, control_handle))
372        } else {
373            None
374        }
375    }
376
377    /// Name of the method defined in FIDL
378    pub fn method_name(&self) -> &'static str {
379        match *self {
380            ControllerRequest::OpenSession { .. } => "open_session",
381        }
382    }
383}
384
385#[derive(Debug, Clone)]
386pub struct ControllerControlHandle {
387    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
388}
389
390impl ControllerControlHandle {
391    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
392        self.inner.shutdown_with_epitaph(status.into())
393    }
394}
395
396impl fidl::endpoints::ControlHandle for ControllerControlHandle {
397    fn shutdown(&self) {
398        self.inner.shutdown()
399    }
400
401    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
402        self.inner.shutdown_with_epitaph(status)
403    }
404
405    fn is_closed(&self) -> bool {
406        self.inner.channel().is_closed()
407    }
408    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
409        self.inner.channel().on_closed()
410    }
411
412    #[cfg(target_os = "fuchsia")]
413    fn signal_peer(
414        &self,
415        clear_mask: zx::Signals,
416        set_mask: zx::Signals,
417    ) -> Result<(), zx_status::Status> {
418        use fidl::Peered;
419        self.inner.channel().signal_peer(clear_mask, set_mask)
420    }
421}
422
423impl ControllerControlHandle {}
424
425#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
426pub struct DeviceMarker;
427
428impl fidl::endpoints::ProtocolMarker for DeviceMarker {
429    type Proxy = DeviceProxy;
430    type RequestStream = DeviceRequestStream;
431    #[cfg(target_os = "fuchsia")]
432    type SynchronousProxy = DeviceSynchronousProxy;
433
434    const DEBUG_NAME: &'static str = "(anonymous) Device";
435}
436pub type DeviceQueryResult = Result<fidl_fuchsia_hardware_hidbus::HidInfo, i32>;
437pub type DeviceGetDeviceReportsReaderResult = Result<(), i32>;
438pub type DeviceReadReportResult = Result<fidl_fuchsia_hardware_hidbus::Report, i32>;
439pub type DeviceReadReportsResult = Result<Vec<u8>, i32>;
440pub type DeviceGetReportsEventResult = Result<fidl::Event, i32>;
441pub type DeviceGetReportResult = Result<Vec<u8>, i32>;
442pub type DeviceSetReportResult = Result<(), i32>;
443
444pub trait DeviceProxyInterface: Send + Sync {
445    type QueryResponseFut: std::future::Future<Output = Result<DeviceQueryResult, fidl::Error>>
446        + Send;
447    fn r#query(&self) -> Self::QueryResponseFut;
448    type GetReportDescResponseFut: std::future::Future<Output = Result<Vec<u8>, fidl::Error>> + Send;
449    fn r#get_report_desc(&self) -> Self::GetReportDescResponseFut;
450    type GetDeviceReportsReaderResponseFut: std::future::Future<Output = Result<DeviceGetDeviceReportsReaderResult, fidl::Error>>
451        + Send;
452    fn r#get_device_reports_reader(
453        &self,
454        reader: fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>,
455    ) -> Self::GetDeviceReportsReaderResponseFut;
456    type ReadReportResponseFut: std::future::Future<Output = Result<DeviceReadReportResult, fidl::Error>>
457        + Send;
458    fn r#read_report(&self) -> Self::ReadReportResponseFut;
459    type ReadReportsResponseFut: std::future::Future<Output = Result<DeviceReadReportsResult, fidl::Error>>
460        + Send;
461    fn r#read_reports(&self) -> Self::ReadReportsResponseFut;
462    type GetReportsEventResponseFut: std::future::Future<Output = Result<DeviceGetReportsEventResult, fidl::Error>>
463        + Send;
464    fn r#get_reports_event(&self) -> Self::GetReportsEventResponseFut;
465    type GetReportResponseFut: std::future::Future<Output = Result<DeviceGetReportResult, fidl::Error>>
466        + Send;
467    fn r#get_report(
468        &self,
469        type_: fidl_fuchsia_hardware_hidbus::ReportType,
470        id: u8,
471    ) -> Self::GetReportResponseFut;
472    type SetReportResponseFut: std::future::Future<Output = Result<DeviceSetReportResult, fidl::Error>>
473        + Send;
474    fn r#set_report(
475        &self,
476        type_: fidl_fuchsia_hardware_hidbus::ReportType,
477        id: u8,
478        report: &[u8],
479    ) -> Self::SetReportResponseFut;
480    fn r#set_trace_id(&self, id: u32) -> Result<(), fidl::Error>;
481}
482#[derive(Debug)]
483#[cfg(target_os = "fuchsia")]
484pub struct DeviceSynchronousProxy {
485    client: fidl::client::sync::Client,
486}
487
488#[cfg(target_os = "fuchsia")]
489impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
490    type Proxy = DeviceProxy;
491    type Protocol = DeviceMarker;
492
493    fn from_channel(inner: fidl::Channel) -> Self {
494        Self::new(inner)
495    }
496
497    fn into_channel(self) -> fidl::Channel {
498        self.client.into_channel()
499    }
500
501    fn as_channel(&self) -> &fidl::Channel {
502        self.client.as_channel()
503    }
504}
505
506#[cfg(target_os = "fuchsia")]
507impl DeviceSynchronousProxy {
508    pub fn new(channel: fidl::Channel) -> Self {
509        Self { client: fidl::client::sync::Client::new(channel) }
510    }
511
512    pub fn into_channel(self) -> fidl::Channel {
513        self.client.into_channel()
514    }
515
516    /// Waits until an event arrives and returns it. It is safe for other
517    /// threads to make concurrent requests while waiting for an event.
518    pub fn wait_for_event(
519        &self,
520        deadline: zx::MonotonicInstant,
521    ) -> Result<DeviceEvent, fidl::Error> {
522        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
523    }
524
525    /// Obtain information about the hidbus device and supported features.
526    pub fn r#query(
527        &self,
528        ___deadline: zx::MonotonicInstant,
529    ) -> Result<DeviceQueryResult, fidl::Error> {
530        let _response = self.client.send_query::<
531            fidl::encoding::EmptyPayload,
532            fidl::encoding::ResultType<DeviceQueryResponse, i32>,
533            DeviceMarker,
534        >(
535            (),
536            0x6d1d90313259dae3,
537            fidl::encoding::DynamicFlags::empty(),
538            ___deadline,
539        )?;
540        Ok(_response.map(|x| x.info))
541    }
542
543    /// Get the report descriptor
544    pub fn r#get_report_desc(
545        &self,
546        ___deadline: zx::MonotonicInstant,
547    ) -> Result<Vec<u8>, fidl::Error> {
548        let _response = self
549            .client
550            .send_query::<fidl::encoding::EmptyPayload, DeviceGetReportDescResponse, DeviceMarker>(
551                (),
552                0x7fe4aff57d9019f8,
553                fidl::encoding::DynamicFlags::empty(),
554                ___deadline,
555            )?;
556        Ok(_response.desc)
557    }
558
559    /// Open a new DeviceReportsReader on this device. Opening a DeviceReportsReader
560    /// allocates a new FIFO for receiving input reports.
561    pub fn r#get_device_reports_reader(
562        &self,
563        mut reader: fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>,
564        ___deadline: zx::MonotonicInstant,
565    ) -> Result<DeviceGetDeviceReportsReaderResult, fidl::Error> {
566        let _response = self.client.send_query::<
567            DeviceGetDeviceReportsReaderRequest,
568            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
569            DeviceMarker,
570        >(
571            (reader,),
572            0x67aee4993bb823ee,
573            fidl::encoding::DynamicFlags::empty(),
574            ___deadline,
575        )?;
576        Ok(_response.map(|x| x))
577    }
578
579    /// Read one report out of the report FIFO. Only a single report will be
580    /// returned in this API. `time` is the time the report was created, from
581    /// the view of the monotonic clock.
582    /// If status is ZX_ERR_SHOULD_WAIT the client can wait on the event
583    /// from `GetReportsEvent`.
584    pub fn r#read_report(
585        &self,
586        ___deadline: zx::MonotonicInstant,
587    ) -> Result<DeviceReadReportResult, fidl::Error> {
588        let _response = self.client.send_query::<
589            fidl::encoding::EmptyPayload,
590            fidl::encoding::ResultType<fidl_fuchsia_hardware_hidbus::Report, i32>,
591            DeviceMarker,
592        >(
593            (),
594            0x69871e1e2b75e46f,
595            fidl::encoding::DynamicFlags::empty(),
596            ___deadline,
597        )?;
598        Ok(_response.map(|x| x))
599    }
600
601    /// Read up to MAX_REPORT_DATA bytes of reports that have been sent from a device.
602    /// This is the interface that is supposed to be used for continuous polling.
603    /// Multiple reports can be returned from this API at a time, it is up to the client
604    /// to do the parsing of the reports with the correct sizes and offset.
605    /// It is guaranteed that only whole reports will be sent.
606    /// If there are no reports, this will return ZX_ERR_SHOULD_WAIT, and the client can
607    /// wait on the event from `GetReportsEvent`.
608    pub fn r#read_reports(
609        &self,
610        ___deadline: zx::MonotonicInstant,
611    ) -> Result<DeviceReadReportsResult, fidl::Error> {
612        let _response = self.client.send_query::<
613            fidl::encoding::EmptyPayload,
614            fidl::encoding::ResultType<DeviceReadReportsResponse, i32>,
615            DeviceMarker,
616        >(
617            (),
618            0x6e20cf64707a4ee4,
619            fidl::encoding::DynamicFlags::empty(),
620            ___deadline,
621        )?;
622        Ok(_response.map(|x| x.data))
623    }
624
625    /// Receive an event that will signal on `ZX_USER_SIGNAL_0` when there are reports in the
626    /// Device's report FIFO. This signal will be de-asserted when there are no
627    /// reports in the Device's report FIFO. This event can be re-used each time
628    /// the client wishes to know if there are reports in the FIFO.
629    pub fn r#get_reports_event(
630        &self,
631        ___deadline: zx::MonotonicInstant,
632    ) -> Result<DeviceGetReportsEventResult, fidl::Error> {
633        let _response = self.client.send_query::<
634            fidl::encoding::EmptyPayload,
635            fidl::encoding::ResultType<DeviceGetReportsEventResponse, i32>,
636            DeviceMarker,
637        >(
638            (),
639            0x6198970f9308041c,
640            fidl::encoding::DynamicFlags::empty(),
641            ___deadline,
642        )?;
643        Ok(_response.map(|x| x.event))
644    }
645
646    /// Send a request to the hardware for a given report described by type and id.
647    /// Returns the hardware's response. This interface is not intended
648    /// to be used for continuous polling of the reports.
649    pub fn r#get_report(
650        &self,
651        mut type_: fidl_fuchsia_hardware_hidbus::ReportType,
652        mut id: u8,
653        ___deadline: zx::MonotonicInstant,
654    ) -> Result<DeviceGetReportResult, fidl::Error> {
655        let _response = self.client.send_query::<
656            DeviceGetReportRequest,
657            fidl::encoding::ResultType<DeviceGetReportResponse, i32>,
658            DeviceMarker,
659        >(
660            (type_, id,),
661            0x5b2a44555defd970,
662            fidl::encoding::DynamicFlags::empty(),
663            ___deadline,
664        )?;
665        Ok(_response.map(|x| x.report))
666    }
667
668    /// Set a single report of the given (type, id) pair.
669    pub fn r#set_report(
670        &self,
671        mut type_: fidl_fuchsia_hardware_hidbus::ReportType,
672        mut id: u8,
673        mut report: &[u8],
674        ___deadline: zx::MonotonicInstant,
675    ) -> Result<DeviceSetReportResult, fidl::Error> {
676        let _response = self.client.send_query::<
677            DeviceSetReportRequest,
678            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
679            DeviceMarker,
680        >(
681            (type_, id, report,),
682            0x51cc85eb4e769ee,
683            fidl::encoding::DynamicFlags::empty(),
684            ___deadline,
685        )?;
686        Ok(_response.map(|x| x))
687    }
688
689    /// Set the trace ID that is used for HID report flow events.
690    pub fn r#set_trace_id(&self, mut id: u32) -> Result<(), fidl::Error> {
691        self.client.send::<DeviceSetTraceIdRequest>(
692            (id,),
693            0x7fe8815219c66700,
694            fidl::encoding::DynamicFlags::empty(),
695        )
696    }
697}
698
699#[cfg(target_os = "fuchsia")]
700impl From<DeviceSynchronousProxy> for zx::NullableHandle {
701    fn from(value: DeviceSynchronousProxy) -> Self {
702        value.into_channel().into()
703    }
704}
705
706#[cfg(target_os = "fuchsia")]
707impl From<fidl::Channel> for DeviceSynchronousProxy {
708    fn from(value: fidl::Channel) -> Self {
709        Self::new(value)
710    }
711}
712
713#[cfg(target_os = "fuchsia")]
714impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
715    type Protocol = DeviceMarker;
716
717    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
718        Self::new(value.into_channel())
719    }
720}
721
722#[derive(Debug, Clone)]
723pub struct DeviceProxy {
724    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
725}
726
727impl fidl::endpoints::Proxy for DeviceProxy {
728    type Protocol = DeviceMarker;
729
730    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
731        Self::new(inner)
732    }
733
734    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
735        self.client.into_channel().map_err(|client| Self { client })
736    }
737
738    fn as_channel(&self) -> &::fidl::AsyncChannel {
739        self.client.as_channel()
740    }
741}
742
743impl DeviceProxy {
744    /// Create a new Proxy for fuchsia.hardware.input/Device.
745    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
746        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
747        Self { client: fidl::client::Client::new(channel, protocol_name) }
748    }
749
750    /// Get a Stream of events from the remote end of the protocol.
751    ///
752    /// # Panics
753    ///
754    /// Panics if the event stream was already taken.
755    pub fn take_event_stream(&self) -> DeviceEventStream {
756        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
757    }
758
759    /// Obtain information about the hidbus device and supported features.
760    pub fn r#query(
761        &self,
762    ) -> fidl::client::QueryResponseFut<
763        DeviceQueryResult,
764        fidl::encoding::DefaultFuchsiaResourceDialect,
765    > {
766        DeviceProxyInterface::r#query(self)
767    }
768
769    /// Get the report descriptor
770    pub fn r#get_report_desc(
771        &self,
772    ) -> fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>
773    {
774        DeviceProxyInterface::r#get_report_desc(self)
775    }
776
777    /// Open a new DeviceReportsReader on this device. Opening a DeviceReportsReader
778    /// allocates a new FIFO for receiving input reports.
779    pub fn r#get_device_reports_reader(
780        &self,
781        mut reader: fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>,
782    ) -> fidl::client::QueryResponseFut<
783        DeviceGetDeviceReportsReaderResult,
784        fidl::encoding::DefaultFuchsiaResourceDialect,
785    > {
786        DeviceProxyInterface::r#get_device_reports_reader(self, reader)
787    }
788
789    /// Read one report out of the report FIFO. Only a single report will be
790    /// returned in this API. `time` is the time the report was created, from
791    /// the view of the monotonic clock.
792    /// If status is ZX_ERR_SHOULD_WAIT the client can wait on the event
793    /// from `GetReportsEvent`.
794    pub fn r#read_report(
795        &self,
796    ) -> fidl::client::QueryResponseFut<
797        DeviceReadReportResult,
798        fidl::encoding::DefaultFuchsiaResourceDialect,
799    > {
800        DeviceProxyInterface::r#read_report(self)
801    }
802
803    /// Read up to MAX_REPORT_DATA bytes of reports that have been sent from a device.
804    /// This is the interface that is supposed to be used for continuous polling.
805    /// Multiple reports can be returned from this API at a time, it is up to the client
806    /// to do the parsing of the reports with the correct sizes and offset.
807    /// It is guaranteed that only whole reports will be sent.
808    /// If there are no reports, this will return ZX_ERR_SHOULD_WAIT, and the client can
809    /// wait on the event from `GetReportsEvent`.
810    pub fn r#read_reports(
811        &self,
812    ) -> fidl::client::QueryResponseFut<
813        DeviceReadReportsResult,
814        fidl::encoding::DefaultFuchsiaResourceDialect,
815    > {
816        DeviceProxyInterface::r#read_reports(self)
817    }
818
819    /// Receive an event that will signal on `ZX_USER_SIGNAL_0` when there are reports in the
820    /// Device's report FIFO. This signal will be de-asserted when there are no
821    /// reports in the Device's report FIFO. This event can be re-used each time
822    /// the client wishes to know if there are reports in the FIFO.
823    pub fn r#get_reports_event(
824        &self,
825    ) -> fidl::client::QueryResponseFut<
826        DeviceGetReportsEventResult,
827        fidl::encoding::DefaultFuchsiaResourceDialect,
828    > {
829        DeviceProxyInterface::r#get_reports_event(self)
830    }
831
832    /// Send a request to the hardware for a given report described by type and id.
833    /// Returns the hardware's response. This interface is not intended
834    /// to be used for continuous polling of the reports.
835    pub fn r#get_report(
836        &self,
837        mut type_: fidl_fuchsia_hardware_hidbus::ReportType,
838        mut id: u8,
839    ) -> fidl::client::QueryResponseFut<
840        DeviceGetReportResult,
841        fidl::encoding::DefaultFuchsiaResourceDialect,
842    > {
843        DeviceProxyInterface::r#get_report(self, type_, id)
844    }
845
846    /// Set a single report of the given (type, id) pair.
847    pub fn r#set_report(
848        &self,
849        mut type_: fidl_fuchsia_hardware_hidbus::ReportType,
850        mut id: u8,
851        mut report: &[u8],
852    ) -> fidl::client::QueryResponseFut<
853        DeviceSetReportResult,
854        fidl::encoding::DefaultFuchsiaResourceDialect,
855    > {
856        DeviceProxyInterface::r#set_report(self, type_, id, report)
857    }
858
859    /// Set the trace ID that is used for HID report flow events.
860    pub fn r#set_trace_id(&self, mut id: u32) -> Result<(), fidl::Error> {
861        DeviceProxyInterface::r#set_trace_id(self, id)
862    }
863}
864
865impl DeviceProxyInterface for DeviceProxy {
866    type QueryResponseFut = fidl::client::QueryResponseFut<
867        DeviceQueryResult,
868        fidl::encoding::DefaultFuchsiaResourceDialect,
869    >;
870    fn r#query(&self) -> Self::QueryResponseFut {
871        fn _decode(
872            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
873        ) -> Result<DeviceQueryResult, fidl::Error> {
874            let _response = fidl::client::decode_transaction_body::<
875                fidl::encoding::ResultType<DeviceQueryResponse, i32>,
876                fidl::encoding::DefaultFuchsiaResourceDialect,
877                0x6d1d90313259dae3,
878            >(_buf?)?;
879            Ok(_response.map(|x| x.info))
880        }
881        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceQueryResult>(
882            (),
883            0x6d1d90313259dae3,
884            fidl::encoding::DynamicFlags::empty(),
885            _decode,
886        )
887    }
888
889    type GetReportDescResponseFut =
890        fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>;
891    fn r#get_report_desc(&self) -> Self::GetReportDescResponseFut {
892        fn _decode(
893            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
894        ) -> Result<Vec<u8>, fidl::Error> {
895            let _response = fidl::client::decode_transaction_body::<
896                DeviceGetReportDescResponse,
897                fidl::encoding::DefaultFuchsiaResourceDialect,
898                0x7fe4aff57d9019f8,
899            >(_buf?)?;
900            Ok(_response.desc)
901        }
902        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<u8>>(
903            (),
904            0x7fe4aff57d9019f8,
905            fidl::encoding::DynamicFlags::empty(),
906            _decode,
907        )
908    }
909
910    type GetDeviceReportsReaderResponseFut = fidl::client::QueryResponseFut<
911        DeviceGetDeviceReportsReaderResult,
912        fidl::encoding::DefaultFuchsiaResourceDialect,
913    >;
914    fn r#get_device_reports_reader(
915        &self,
916        mut reader: fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>,
917    ) -> Self::GetDeviceReportsReaderResponseFut {
918        fn _decode(
919            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
920        ) -> Result<DeviceGetDeviceReportsReaderResult, fidl::Error> {
921            let _response = fidl::client::decode_transaction_body::<
922                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
923                fidl::encoding::DefaultFuchsiaResourceDialect,
924                0x67aee4993bb823ee,
925            >(_buf?)?;
926            Ok(_response.map(|x| x))
927        }
928        self.client.send_query_and_decode::<
929            DeviceGetDeviceReportsReaderRequest,
930            DeviceGetDeviceReportsReaderResult,
931        >(
932            (reader,),
933            0x67aee4993bb823ee,
934            fidl::encoding::DynamicFlags::empty(),
935            _decode,
936        )
937    }
938
939    type ReadReportResponseFut = fidl::client::QueryResponseFut<
940        DeviceReadReportResult,
941        fidl::encoding::DefaultFuchsiaResourceDialect,
942    >;
943    fn r#read_report(&self) -> Self::ReadReportResponseFut {
944        fn _decode(
945            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
946        ) -> Result<DeviceReadReportResult, fidl::Error> {
947            let _response = fidl::client::decode_transaction_body::<
948                fidl::encoding::ResultType<fidl_fuchsia_hardware_hidbus::Report, i32>,
949                fidl::encoding::DefaultFuchsiaResourceDialect,
950                0x69871e1e2b75e46f,
951            >(_buf?)?;
952            Ok(_response.map(|x| x))
953        }
954        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceReadReportResult>(
955            (),
956            0x69871e1e2b75e46f,
957            fidl::encoding::DynamicFlags::empty(),
958            _decode,
959        )
960    }
961
962    type ReadReportsResponseFut = fidl::client::QueryResponseFut<
963        DeviceReadReportsResult,
964        fidl::encoding::DefaultFuchsiaResourceDialect,
965    >;
966    fn r#read_reports(&self) -> Self::ReadReportsResponseFut {
967        fn _decode(
968            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
969        ) -> Result<DeviceReadReportsResult, fidl::Error> {
970            let _response = fidl::client::decode_transaction_body::<
971                fidl::encoding::ResultType<DeviceReadReportsResponse, i32>,
972                fidl::encoding::DefaultFuchsiaResourceDialect,
973                0x6e20cf64707a4ee4,
974            >(_buf?)?;
975            Ok(_response.map(|x| x.data))
976        }
977        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceReadReportsResult>(
978            (),
979            0x6e20cf64707a4ee4,
980            fidl::encoding::DynamicFlags::empty(),
981            _decode,
982        )
983    }
984
985    type GetReportsEventResponseFut = fidl::client::QueryResponseFut<
986        DeviceGetReportsEventResult,
987        fidl::encoding::DefaultFuchsiaResourceDialect,
988    >;
989    fn r#get_reports_event(&self) -> Self::GetReportsEventResponseFut {
990        fn _decode(
991            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
992        ) -> Result<DeviceGetReportsEventResult, fidl::Error> {
993            let _response = fidl::client::decode_transaction_body::<
994                fidl::encoding::ResultType<DeviceGetReportsEventResponse, i32>,
995                fidl::encoding::DefaultFuchsiaResourceDialect,
996                0x6198970f9308041c,
997            >(_buf?)?;
998            Ok(_response.map(|x| x.event))
999        }
1000        self.client
1001            .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetReportsEventResult>(
1002                (),
1003                0x6198970f9308041c,
1004                fidl::encoding::DynamicFlags::empty(),
1005                _decode,
1006            )
1007    }
1008
1009    type GetReportResponseFut = fidl::client::QueryResponseFut<
1010        DeviceGetReportResult,
1011        fidl::encoding::DefaultFuchsiaResourceDialect,
1012    >;
1013    fn r#get_report(
1014        &self,
1015        mut type_: fidl_fuchsia_hardware_hidbus::ReportType,
1016        mut id: u8,
1017    ) -> Self::GetReportResponseFut {
1018        fn _decode(
1019            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1020        ) -> Result<DeviceGetReportResult, fidl::Error> {
1021            let _response = fidl::client::decode_transaction_body::<
1022                fidl::encoding::ResultType<DeviceGetReportResponse, i32>,
1023                fidl::encoding::DefaultFuchsiaResourceDialect,
1024                0x5b2a44555defd970,
1025            >(_buf?)?;
1026            Ok(_response.map(|x| x.report))
1027        }
1028        self.client.send_query_and_decode::<DeviceGetReportRequest, DeviceGetReportResult>(
1029            (type_, id),
1030            0x5b2a44555defd970,
1031            fidl::encoding::DynamicFlags::empty(),
1032            _decode,
1033        )
1034    }
1035
1036    type SetReportResponseFut = fidl::client::QueryResponseFut<
1037        DeviceSetReportResult,
1038        fidl::encoding::DefaultFuchsiaResourceDialect,
1039    >;
1040    fn r#set_report(
1041        &self,
1042        mut type_: fidl_fuchsia_hardware_hidbus::ReportType,
1043        mut id: u8,
1044        mut report: &[u8],
1045    ) -> Self::SetReportResponseFut {
1046        fn _decode(
1047            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1048        ) -> Result<DeviceSetReportResult, fidl::Error> {
1049            let _response = fidl::client::decode_transaction_body::<
1050                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1051                fidl::encoding::DefaultFuchsiaResourceDialect,
1052                0x51cc85eb4e769ee,
1053            >(_buf?)?;
1054            Ok(_response.map(|x| x))
1055        }
1056        self.client.send_query_and_decode::<DeviceSetReportRequest, DeviceSetReportResult>(
1057            (type_, id, report),
1058            0x51cc85eb4e769ee,
1059            fidl::encoding::DynamicFlags::empty(),
1060            _decode,
1061        )
1062    }
1063
1064    fn r#set_trace_id(&self, mut id: u32) -> Result<(), fidl::Error> {
1065        self.client.send::<DeviceSetTraceIdRequest>(
1066            (id,),
1067            0x7fe8815219c66700,
1068            fidl::encoding::DynamicFlags::empty(),
1069        )
1070    }
1071}
1072
1073pub struct DeviceEventStream {
1074    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1075}
1076
1077impl std::marker::Unpin for DeviceEventStream {}
1078
1079impl futures::stream::FusedStream for DeviceEventStream {
1080    fn is_terminated(&self) -> bool {
1081        self.event_receiver.is_terminated()
1082    }
1083}
1084
1085impl futures::Stream for DeviceEventStream {
1086    type Item = Result<DeviceEvent, fidl::Error>;
1087
1088    fn poll_next(
1089        mut self: std::pin::Pin<&mut Self>,
1090        cx: &mut std::task::Context<'_>,
1091    ) -> std::task::Poll<Option<Self::Item>> {
1092        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1093            &mut self.event_receiver,
1094            cx
1095        )?) {
1096            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1097            None => std::task::Poll::Ready(None),
1098        }
1099    }
1100}
1101
1102#[derive(Debug)]
1103pub enum DeviceEvent {}
1104
1105impl DeviceEvent {
1106    /// Decodes a message buffer as a [`DeviceEvent`].
1107    fn decode(
1108        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1109    ) -> Result<DeviceEvent, fidl::Error> {
1110        let (bytes, _handles) = buf.split_mut();
1111        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1112        debug_assert_eq!(tx_header.tx_id, 0);
1113        match tx_header.ordinal {
1114            _ => Err(fidl::Error::UnknownOrdinal {
1115                ordinal: tx_header.ordinal,
1116                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1117            }),
1118        }
1119    }
1120}
1121
1122/// A Stream of incoming requests for fuchsia.hardware.input/Device.
1123pub struct DeviceRequestStream {
1124    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1125    is_terminated: bool,
1126}
1127
1128impl std::marker::Unpin for DeviceRequestStream {}
1129
1130impl futures::stream::FusedStream for DeviceRequestStream {
1131    fn is_terminated(&self) -> bool {
1132        self.is_terminated
1133    }
1134}
1135
1136impl fidl::endpoints::RequestStream for DeviceRequestStream {
1137    type Protocol = DeviceMarker;
1138    type ControlHandle = DeviceControlHandle;
1139
1140    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1141        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1142    }
1143
1144    fn control_handle(&self) -> Self::ControlHandle {
1145        DeviceControlHandle { inner: self.inner.clone() }
1146    }
1147
1148    fn into_inner(
1149        self,
1150    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1151    {
1152        (self.inner, self.is_terminated)
1153    }
1154
1155    fn from_inner(
1156        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1157        is_terminated: bool,
1158    ) -> Self {
1159        Self { inner, is_terminated }
1160    }
1161}
1162
1163impl futures::Stream for DeviceRequestStream {
1164    type Item = Result<DeviceRequest, fidl::Error>;
1165
1166    fn poll_next(
1167        mut self: std::pin::Pin<&mut Self>,
1168        cx: &mut std::task::Context<'_>,
1169    ) -> std::task::Poll<Option<Self::Item>> {
1170        let this = &mut *self;
1171        if this.inner.check_shutdown(cx) {
1172            this.is_terminated = true;
1173            return std::task::Poll::Ready(None);
1174        }
1175        if this.is_terminated {
1176            panic!("polled DeviceRequestStream after completion");
1177        }
1178        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1179            |bytes, handles| {
1180                match this.inner.channel().read_etc(cx, bytes, handles) {
1181                    std::task::Poll::Ready(Ok(())) => {}
1182                    std::task::Poll::Pending => return std::task::Poll::Pending,
1183                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1184                        this.is_terminated = true;
1185                        return std::task::Poll::Ready(None);
1186                    }
1187                    std::task::Poll::Ready(Err(e)) => {
1188                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1189                            e.into(),
1190                        ))));
1191                    }
1192                }
1193
1194                // A message has been received from the channel
1195                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1196
1197                std::task::Poll::Ready(Some(match header.ordinal {
1198                    0x6d1d90313259dae3 => {
1199                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1200                        let mut req = fidl::new_empty!(
1201                            fidl::encoding::EmptyPayload,
1202                            fidl::encoding::DefaultFuchsiaResourceDialect
1203                        );
1204                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1205                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1206                        Ok(DeviceRequest::Query {
1207                            responder: DeviceQueryResponder {
1208                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1209                                tx_id: header.tx_id,
1210                            },
1211                        })
1212                    }
1213                    0x7fe4aff57d9019f8 => {
1214                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1215                        let mut req = fidl::new_empty!(
1216                            fidl::encoding::EmptyPayload,
1217                            fidl::encoding::DefaultFuchsiaResourceDialect
1218                        );
1219                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1220                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1221                        Ok(DeviceRequest::GetReportDesc {
1222                            responder: DeviceGetReportDescResponder {
1223                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1224                                tx_id: header.tx_id,
1225                            },
1226                        })
1227                    }
1228                    0x67aee4993bb823ee => {
1229                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1230                        let mut req = fidl::new_empty!(
1231                            DeviceGetDeviceReportsReaderRequest,
1232                            fidl::encoding::DefaultFuchsiaResourceDialect
1233                        );
1234                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetDeviceReportsReaderRequest>(&header, _body_bytes, handles, &mut req)?;
1235                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1236                        Ok(DeviceRequest::GetDeviceReportsReader {
1237                            reader: req.reader,
1238
1239                            responder: DeviceGetDeviceReportsReaderResponder {
1240                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1241                                tx_id: header.tx_id,
1242                            },
1243                        })
1244                    }
1245                    0x69871e1e2b75e46f => {
1246                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1247                        let mut req = fidl::new_empty!(
1248                            fidl::encoding::EmptyPayload,
1249                            fidl::encoding::DefaultFuchsiaResourceDialect
1250                        );
1251                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1252                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1253                        Ok(DeviceRequest::ReadReport {
1254                            responder: DeviceReadReportResponder {
1255                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1256                                tx_id: header.tx_id,
1257                            },
1258                        })
1259                    }
1260                    0x6e20cf64707a4ee4 => {
1261                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1262                        let mut req = fidl::new_empty!(
1263                            fidl::encoding::EmptyPayload,
1264                            fidl::encoding::DefaultFuchsiaResourceDialect
1265                        );
1266                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1267                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1268                        Ok(DeviceRequest::ReadReports {
1269                            responder: DeviceReadReportsResponder {
1270                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1271                                tx_id: header.tx_id,
1272                            },
1273                        })
1274                    }
1275                    0x6198970f9308041c => {
1276                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1277                        let mut req = fidl::new_empty!(
1278                            fidl::encoding::EmptyPayload,
1279                            fidl::encoding::DefaultFuchsiaResourceDialect
1280                        );
1281                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1282                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1283                        Ok(DeviceRequest::GetReportsEvent {
1284                            responder: DeviceGetReportsEventResponder {
1285                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1286                                tx_id: header.tx_id,
1287                            },
1288                        })
1289                    }
1290                    0x5b2a44555defd970 => {
1291                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1292                        let mut req = fidl::new_empty!(
1293                            DeviceGetReportRequest,
1294                            fidl::encoding::DefaultFuchsiaResourceDialect
1295                        );
1296                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetReportRequest>(&header, _body_bytes, handles, &mut req)?;
1297                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1298                        Ok(DeviceRequest::GetReport {
1299                            type_: req.type_,
1300                            id: req.id,
1301
1302                            responder: DeviceGetReportResponder {
1303                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1304                                tx_id: header.tx_id,
1305                            },
1306                        })
1307                    }
1308                    0x51cc85eb4e769ee => {
1309                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1310                        let mut req = fidl::new_empty!(
1311                            DeviceSetReportRequest,
1312                            fidl::encoding::DefaultFuchsiaResourceDialect
1313                        );
1314                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetReportRequest>(&header, _body_bytes, handles, &mut req)?;
1315                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1316                        Ok(DeviceRequest::SetReport {
1317                            type_: req.type_,
1318                            id: req.id,
1319                            report: req.report,
1320
1321                            responder: DeviceSetReportResponder {
1322                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1323                                tx_id: header.tx_id,
1324                            },
1325                        })
1326                    }
1327                    0x7fe8815219c66700 => {
1328                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1329                        let mut req = fidl::new_empty!(
1330                            DeviceSetTraceIdRequest,
1331                            fidl::encoding::DefaultFuchsiaResourceDialect
1332                        );
1333                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetTraceIdRequest>(&header, _body_bytes, handles, &mut req)?;
1334                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1335                        Ok(DeviceRequest::SetTraceId { id: req.id, control_handle })
1336                    }
1337                    _ => Err(fidl::Error::UnknownOrdinal {
1338                        ordinal: header.ordinal,
1339                        protocol_name:
1340                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1341                    }),
1342                }))
1343            },
1344        )
1345    }
1346}
1347
1348#[derive(Debug)]
1349pub enum DeviceRequest {
1350    /// Obtain information about the hidbus device and supported features.
1351    Query { responder: DeviceQueryResponder },
1352    /// Get the report descriptor
1353    GetReportDesc { responder: DeviceGetReportDescResponder },
1354    /// Open a new DeviceReportsReader on this device. Opening a DeviceReportsReader
1355    /// allocates a new FIFO for receiving input reports.
1356    GetDeviceReportsReader {
1357        reader: fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>,
1358        responder: DeviceGetDeviceReportsReaderResponder,
1359    },
1360    /// Read one report out of the report FIFO. Only a single report will be
1361    /// returned in this API. `time` is the time the report was created, from
1362    /// the view of the monotonic clock.
1363    /// If status is ZX_ERR_SHOULD_WAIT the client can wait on the event
1364    /// from `GetReportsEvent`.
1365    ReadReport { responder: DeviceReadReportResponder },
1366    /// Read up to MAX_REPORT_DATA bytes of reports that have been sent from a device.
1367    /// This is the interface that is supposed to be used for continuous polling.
1368    /// Multiple reports can be returned from this API at a time, it is up to the client
1369    /// to do the parsing of the reports with the correct sizes and offset.
1370    /// It is guaranteed that only whole reports will be sent.
1371    /// If there are no reports, this will return ZX_ERR_SHOULD_WAIT, and the client can
1372    /// wait on the event from `GetReportsEvent`.
1373    ReadReports { responder: DeviceReadReportsResponder },
1374    /// Receive an event that will signal on `ZX_USER_SIGNAL_0` when there are reports in the
1375    /// Device's report FIFO. This signal will be de-asserted when there are no
1376    /// reports in the Device's report FIFO. This event can be re-used each time
1377    /// the client wishes to know if there are reports in the FIFO.
1378    GetReportsEvent { responder: DeviceGetReportsEventResponder },
1379    /// Send a request to the hardware for a given report described by type and id.
1380    /// Returns the hardware's response. This interface is not intended
1381    /// to be used for continuous polling of the reports.
1382    GetReport {
1383        type_: fidl_fuchsia_hardware_hidbus::ReportType,
1384        id: u8,
1385        responder: DeviceGetReportResponder,
1386    },
1387    /// Set a single report of the given (type, id) pair.
1388    SetReport {
1389        type_: fidl_fuchsia_hardware_hidbus::ReportType,
1390        id: u8,
1391        report: Vec<u8>,
1392        responder: DeviceSetReportResponder,
1393    },
1394    /// Set the trace ID that is used for HID report flow events.
1395    SetTraceId { id: u32, control_handle: DeviceControlHandle },
1396}
1397
1398impl DeviceRequest {
1399    #[allow(irrefutable_let_patterns)]
1400    pub fn into_query(self) -> Option<(DeviceQueryResponder)> {
1401        if let DeviceRequest::Query { responder } = self { Some((responder)) } else { None }
1402    }
1403
1404    #[allow(irrefutable_let_patterns)]
1405    pub fn into_get_report_desc(self) -> Option<(DeviceGetReportDescResponder)> {
1406        if let DeviceRequest::GetReportDesc { responder } = self { Some((responder)) } else { None }
1407    }
1408
1409    #[allow(irrefutable_let_patterns)]
1410    pub fn into_get_device_reports_reader(
1411        self,
1412    ) -> Option<(
1413        fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>,
1414        DeviceGetDeviceReportsReaderResponder,
1415    )> {
1416        if let DeviceRequest::GetDeviceReportsReader { reader, responder } = self {
1417            Some((reader, responder))
1418        } else {
1419            None
1420        }
1421    }
1422
1423    #[allow(irrefutable_let_patterns)]
1424    pub fn into_read_report(self) -> Option<(DeviceReadReportResponder)> {
1425        if let DeviceRequest::ReadReport { responder } = self { Some((responder)) } else { None }
1426    }
1427
1428    #[allow(irrefutable_let_patterns)]
1429    pub fn into_read_reports(self) -> Option<(DeviceReadReportsResponder)> {
1430        if let DeviceRequest::ReadReports { responder } = self { Some((responder)) } else { None }
1431    }
1432
1433    #[allow(irrefutable_let_patterns)]
1434    pub fn into_get_reports_event(self) -> Option<(DeviceGetReportsEventResponder)> {
1435        if let DeviceRequest::GetReportsEvent { responder } = self {
1436            Some((responder))
1437        } else {
1438            None
1439        }
1440    }
1441
1442    #[allow(irrefutable_let_patterns)]
1443    pub fn into_get_report(
1444        self,
1445    ) -> Option<(fidl_fuchsia_hardware_hidbus::ReportType, u8, DeviceGetReportResponder)> {
1446        if let DeviceRequest::GetReport { type_, id, responder } = self {
1447            Some((type_, id, responder))
1448        } else {
1449            None
1450        }
1451    }
1452
1453    #[allow(irrefutable_let_patterns)]
1454    pub fn into_set_report(
1455        self,
1456    ) -> Option<(fidl_fuchsia_hardware_hidbus::ReportType, u8, Vec<u8>, DeviceSetReportResponder)>
1457    {
1458        if let DeviceRequest::SetReport { type_, id, report, responder } = self {
1459            Some((type_, id, report, responder))
1460        } else {
1461            None
1462        }
1463    }
1464
1465    #[allow(irrefutable_let_patterns)]
1466    pub fn into_set_trace_id(self) -> Option<(u32, DeviceControlHandle)> {
1467        if let DeviceRequest::SetTraceId { id, control_handle } = self {
1468            Some((id, control_handle))
1469        } else {
1470            None
1471        }
1472    }
1473
1474    /// Name of the method defined in FIDL
1475    pub fn method_name(&self) -> &'static str {
1476        match *self {
1477            DeviceRequest::Query { .. } => "query",
1478            DeviceRequest::GetReportDesc { .. } => "get_report_desc",
1479            DeviceRequest::GetDeviceReportsReader { .. } => "get_device_reports_reader",
1480            DeviceRequest::ReadReport { .. } => "read_report",
1481            DeviceRequest::ReadReports { .. } => "read_reports",
1482            DeviceRequest::GetReportsEvent { .. } => "get_reports_event",
1483            DeviceRequest::GetReport { .. } => "get_report",
1484            DeviceRequest::SetReport { .. } => "set_report",
1485            DeviceRequest::SetTraceId { .. } => "set_trace_id",
1486        }
1487    }
1488}
1489
1490#[derive(Debug, Clone)]
1491pub struct DeviceControlHandle {
1492    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1493}
1494
1495impl DeviceControlHandle {
1496    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1497        self.inner.shutdown_with_epitaph(status.into())
1498    }
1499}
1500
1501impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1502    fn shutdown(&self) {
1503        self.inner.shutdown()
1504    }
1505
1506    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1507        self.inner.shutdown_with_epitaph(status)
1508    }
1509
1510    fn is_closed(&self) -> bool {
1511        self.inner.channel().is_closed()
1512    }
1513    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1514        self.inner.channel().on_closed()
1515    }
1516
1517    #[cfg(target_os = "fuchsia")]
1518    fn signal_peer(
1519        &self,
1520        clear_mask: zx::Signals,
1521        set_mask: zx::Signals,
1522    ) -> Result<(), zx_status::Status> {
1523        use fidl::Peered;
1524        self.inner.channel().signal_peer(clear_mask, set_mask)
1525    }
1526}
1527
1528impl DeviceControlHandle {}
1529
1530#[must_use = "FIDL methods require a response to be sent"]
1531#[derive(Debug)]
1532pub struct DeviceQueryResponder {
1533    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1534    tx_id: u32,
1535}
1536
1537/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1538/// if the responder is dropped without sending a response, so that the client
1539/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1540impl std::ops::Drop for DeviceQueryResponder {
1541    fn drop(&mut self) {
1542        self.control_handle.shutdown();
1543        // Safety: drops once, never accessed again
1544        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1545    }
1546}
1547
1548impl fidl::endpoints::Responder for DeviceQueryResponder {
1549    type ControlHandle = DeviceControlHandle;
1550
1551    fn control_handle(&self) -> &DeviceControlHandle {
1552        &self.control_handle
1553    }
1554
1555    fn drop_without_shutdown(mut self) {
1556        // Safety: drops once, never accessed again due to mem::forget
1557        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1558        // Prevent Drop from running (which would shut down the channel)
1559        std::mem::forget(self);
1560    }
1561}
1562
1563impl DeviceQueryResponder {
1564    /// Sends a response to the FIDL transaction.
1565    ///
1566    /// Sets the channel to shutdown if an error occurs.
1567    pub fn send(
1568        self,
1569        mut result: Result<&fidl_fuchsia_hardware_hidbus::HidInfo, i32>,
1570    ) -> Result<(), fidl::Error> {
1571        let _result = self.send_raw(result);
1572        if _result.is_err() {
1573            self.control_handle.shutdown();
1574        }
1575        self.drop_without_shutdown();
1576        _result
1577    }
1578
1579    /// Similar to "send" but does not shutdown the channel if an error occurs.
1580    pub fn send_no_shutdown_on_err(
1581        self,
1582        mut result: Result<&fidl_fuchsia_hardware_hidbus::HidInfo, i32>,
1583    ) -> Result<(), fidl::Error> {
1584        let _result = self.send_raw(result);
1585        self.drop_without_shutdown();
1586        _result
1587    }
1588
1589    fn send_raw(
1590        &self,
1591        mut result: Result<&fidl_fuchsia_hardware_hidbus::HidInfo, i32>,
1592    ) -> Result<(), fidl::Error> {
1593        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceQueryResponse, i32>>(
1594            result.map(|info| (info,)),
1595            self.tx_id,
1596            0x6d1d90313259dae3,
1597            fidl::encoding::DynamicFlags::empty(),
1598        )
1599    }
1600}
1601
1602#[must_use = "FIDL methods require a response to be sent"]
1603#[derive(Debug)]
1604pub struct DeviceGetReportDescResponder {
1605    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1606    tx_id: u32,
1607}
1608
1609/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1610/// if the responder is dropped without sending a response, so that the client
1611/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1612impl std::ops::Drop for DeviceGetReportDescResponder {
1613    fn drop(&mut self) {
1614        self.control_handle.shutdown();
1615        // Safety: drops once, never accessed again
1616        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1617    }
1618}
1619
1620impl fidl::endpoints::Responder for DeviceGetReportDescResponder {
1621    type ControlHandle = DeviceControlHandle;
1622
1623    fn control_handle(&self) -> &DeviceControlHandle {
1624        &self.control_handle
1625    }
1626
1627    fn drop_without_shutdown(mut self) {
1628        // Safety: drops once, never accessed again due to mem::forget
1629        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1630        // Prevent Drop from running (which would shut down the channel)
1631        std::mem::forget(self);
1632    }
1633}
1634
1635impl DeviceGetReportDescResponder {
1636    /// Sends a response to the FIDL transaction.
1637    ///
1638    /// Sets the channel to shutdown if an error occurs.
1639    pub fn send(self, mut desc: &[u8]) -> Result<(), fidl::Error> {
1640        let _result = self.send_raw(desc);
1641        if _result.is_err() {
1642            self.control_handle.shutdown();
1643        }
1644        self.drop_without_shutdown();
1645        _result
1646    }
1647
1648    /// Similar to "send" but does not shutdown the channel if an error occurs.
1649    pub fn send_no_shutdown_on_err(self, mut desc: &[u8]) -> Result<(), fidl::Error> {
1650        let _result = self.send_raw(desc);
1651        self.drop_without_shutdown();
1652        _result
1653    }
1654
1655    fn send_raw(&self, mut desc: &[u8]) -> Result<(), fidl::Error> {
1656        self.control_handle.inner.send::<DeviceGetReportDescResponse>(
1657            (desc,),
1658            self.tx_id,
1659            0x7fe4aff57d9019f8,
1660            fidl::encoding::DynamicFlags::empty(),
1661        )
1662    }
1663}
1664
1665#[must_use = "FIDL methods require a response to be sent"]
1666#[derive(Debug)]
1667pub struct DeviceGetDeviceReportsReaderResponder {
1668    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1669    tx_id: u32,
1670}
1671
1672/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1673/// if the responder is dropped without sending a response, so that the client
1674/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1675impl std::ops::Drop for DeviceGetDeviceReportsReaderResponder {
1676    fn drop(&mut self) {
1677        self.control_handle.shutdown();
1678        // Safety: drops once, never accessed again
1679        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1680    }
1681}
1682
1683impl fidl::endpoints::Responder for DeviceGetDeviceReportsReaderResponder {
1684    type ControlHandle = DeviceControlHandle;
1685
1686    fn control_handle(&self) -> &DeviceControlHandle {
1687        &self.control_handle
1688    }
1689
1690    fn drop_without_shutdown(mut self) {
1691        // Safety: drops once, never accessed again due to mem::forget
1692        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1693        // Prevent Drop from running (which would shut down the channel)
1694        std::mem::forget(self);
1695    }
1696}
1697
1698impl DeviceGetDeviceReportsReaderResponder {
1699    /// Sends a response to the FIDL transaction.
1700    ///
1701    /// Sets the channel to shutdown if an error occurs.
1702    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1703        let _result = self.send_raw(result);
1704        if _result.is_err() {
1705            self.control_handle.shutdown();
1706        }
1707        self.drop_without_shutdown();
1708        _result
1709    }
1710
1711    /// Similar to "send" but does not shutdown the channel if an error occurs.
1712    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1713        let _result = self.send_raw(result);
1714        self.drop_without_shutdown();
1715        _result
1716    }
1717
1718    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1719        self.control_handle
1720            .inner
1721            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1722                result,
1723                self.tx_id,
1724                0x67aee4993bb823ee,
1725                fidl::encoding::DynamicFlags::empty(),
1726            )
1727    }
1728}
1729
1730#[must_use = "FIDL methods require a response to be sent"]
1731#[derive(Debug)]
1732pub struct DeviceReadReportResponder {
1733    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1734    tx_id: u32,
1735}
1736
1737/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1738/// if the responder is dropped without sending a response, so that the client
1739/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1740impl std::ops::Drop for DeviceReadReportResponder {
1741    fn drop(&mut self) {
1742        self.control_handle.shutdown();
1743        // Safety: drops once, never accessed again
1744        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1745    }
1746}
1747
1748impl fidl::endpoints::Responder for DeviceReadReportResponder {
1749    type ControlHandle = DeviceControlHandle;
1750
1751    fn control_handle(&self) -> &DeviceControlHandle {
1752        &self.control_handle
1753    }
1754
1755    fn drop_without_shutdown(mut self) {
1756        // Safety: drops once, never accessed again due to mem::forget
1757        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1758        // Prevent Drop from running (which would shut down the channel)
1759        std::mem::forget(self);
1760    }
1761}
1762
1763impl DeviceReadReportResponder {
1764    /// Sends a response to the FIDL transaction.
1765    ///
1766    /// Sets the channel to shutdown if an error occurs.
1767    pub fn send(
1768        self,
1769        mut result: Result<fidl_fuchsia_hardware_hidbus::Report, i32>,
1770    ) -> Result<(), fidl::Error> {
1771        let _result = self.send_raw(result);
1772        if _result.is_err() {
1773            self.control_handle.shutdown();
1774        }
1775        self.drop_without_shutdown();
1776        _result
1777    }
1778
1779    /// Similar to "send" but does not shutdown the channel if an error occurs.
1780    pub fn send_no_shutdown_on_err(
1781        self,
1782        mut result: Result<fidl_fuchsia_hardware_hidbus::Report, i32>,
1783    ) -> Result<(), fidl::Error> {
1784        let _result = self.send_raw(result);
1785        self.drop_without_shutdown();
1786        _result
1787    }
1788
1789    fn send_raw(
1790        &self,
1791        mut result: Result<fidl_fuchsia_hardware_hidbus::Report, i32>,
1792    ) -> Result<(), fidl::Error> {
1793        self.control_handle.inner.send::<fidl::encoding::ResultType<
1794            fidl_fuchsia_hardware_hidbus::Report,
1795            i32,
1796        >>(
1797            result.as_mut().map_err(|e| *e),
1798            self.tx_id,
1799            0x69871e1e2b75e46f,
1800            fidl::encoding::DynamicFlags::empty(),
1801        )
1802    }
1803}
1804
1805#[must_use = "FIDL methods require a response to be sent"]
1806#[derive(Debug)]
1807pub struct DeviceReadReportsResponder {
1808    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1809    tx_id: u32,
1810}
1811
1812/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1813/// if the responder is dropped without sending a response, so that the client
1814/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1815impl std::ops::Drop for DeviceReadReportsResponder {
1816    fn drop(&mut self) {
1817        self.control_handle.shutdown();
1818        // Safety: drops once, never accessed again
1819        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1820    }
1821}
1822
1823impl fidl::endpoints::Responder for DeviceReadReportsResponder {
1824    type ControlHandle = DeviceControlHandle;
1825
1826    fn control_handle(&self) -> &DeviceControlHandle {
1827        &self.control_handle
1828    }
1829
1830    fn drop_without_shutdown(mut self) {
1831        // Safety: drops once, never accessed again due to mem::forget
1832        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1833        // Prevent Drop from running (which would shut down the channel)
1834        std::mem::forget(self);
1835    }
1836}
1837
1838impl DeviceReadReportsResponder {
1839    /// Sends a response to the FIDL transaction.
1840    ///
1841    /// Sets the channel to shutdown if an error occurs.
1842    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1843        let _result = self.send_raw(result);
1844        if _result.is_err() {
1845            self.control_handle.shutdown();
1846        }
1847        self.drop_without_shutdown();
1848        _result
1849    }
1850
1851    /// Similar to "send" but does not shutdown the channel if an error occurs.
1852    pub fn send_no_shutdown_on_err(
1853        self,
1854        mut result: Result<&[u8], i32>,
1855    ) -> Result<(), fidl::Error> {
1856        let _result = self.send_raw(result);
1857        self.drop_without_shutdown();
1858        _result
1859    }
1860
1861    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1862        self.control_handle
1863            .inner
1864            .send::<fidl::encoding::ResultType<DeviceReadReportsResponse, i32>>(
1865                result.map(|data| (data,)),
1866                self.tx_id,
1867                0x6e20cf64707a4ee4,
1868                fidl::encoding::DynamicFlags::empty(),
1869            )
1870    }
1871}
1872
1873#[must_use = "FIDL methods require a response to be sent"]
1874#[derive(Debug)]
1875pub struct DeviceGetReportsEventResponder {
1876    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1877    tx_id: u32,
1878}
1879
1880/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1881/// if the responder is dropped without sending a response, so that the client
1882/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1883impl std::ops::Drop for DeviceGetReportsEventResponder {
1884    fn drop(&mut self) {
1885        self.control_handle.shutdown();
1886        // Safety: drops once, never accessed again
1887        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1888    }
1889}
1890
1891impl fidl::endpoints::Responder for DeviceGetReportsEventResponder {
1892    type ControlHandle = DeviceControlHandle;
1893
1894    fn control_handle(&self) -> &DeviceControlHandle {
1895        &self.control_handle
1896    }
1897
1898    fn drop_without_shutdown(mut self) {
1899        // Safety: drops once, never accessed again due to mem::forget
1900        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1901        // Prevent Drop from running (which would shut down the channel)
1902        std::mem::forget(self);
1903    }
1904}
1905
1906impl DeviceGetReportsEventResponder {
1907    /// Sends a response to the FIDL transaction.
1908    ///
1909    /// Sets the channel to shutdown if an error occurs.
1910    pub fn send(self, mut result: Result<fidl::Event, i32>) -> Result<(), fidl::Error> {
1911        let _result = self.send_raw(result);
1912        if _result.is_err() {
1913            self.control_handle.shutdown();
1914        }
1915        self.drop_without_shutdown();
1916        _result
1917    }
1918
1919    /// Similar to "send" but does not shutdown the channel if an error occurs.
1920    pub fn send_no_shutdown_on_err(
1921        self,
1922        mut result: Result<fidl::Event, i32>,
1923    ) -> Result<(), fidl::Error> {
1924        let _result = self.send_raw(result);
1925        self.drop_without_shutdown();
1926        _result
1927    }
1928
1929    fn send_raw(&self, mut result: Result<fidl::Event, i32>) -> Result<(), fidl::Error> {
1930        self.control_handle
1931            .inner
1932            .send::<fidl::encoding::ResultType<DeviceGetReportsEventResponse, i32>>(
1933                result.map(|event| (event,)),
1934                self.tx_id,
1935                0x6198970f9308041c,
1936                fidl::encoding::DynamicFlags::empty(),
1937            )
1938    }
1939}
1940
1941#[must_use = "FIDL methods require a response to be sent"]
1942#[derive(Debug)]
1943pub struct DeviceGetReportResponder {
1944    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1945    tx_id: u32,
1946}
1947
1948/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1949/// if the responder is dropped without sending a response, so that the client
1950/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1951impl std::ops::Drop for DeviceGetReportResponder {
1952    fn drop(&mut self) {
1953        self.control_handle.shutdown();
1954        // Safety: drops once, never accessed again
1955        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1956    }
1957}
1958
1959impl fidl::endpoints::Responder for DeviceGetReportResponder {
1960    type ControlHandle = DeviceControlHandle;
1961
1962    fn control_handle(&self) -> &DeviceControlHandle {
1963        &self.control_handle
1964    }
1965
1966    fn drop_without_shutdown(mut self) {
1967        // Safety: drops once, never accessed again due to mem::forget
1968        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1969        // Prevent Drop from running (which would shut down the channel)
1970        std::mem::forget(self);
1971    }
1972}
1973
1974impl DeviceGetReportResponder {
1975    /// Sends a response to the FIDL transaction.
1976    ///
1977    /// Sets the channel to shutdown if an error occurs.
1978    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1979        let _result = self.send_raw(result);
1980        if _result.is_err() {
1981            self.control_handle.shutdown();
1982        }
1983        self.drop_without_shutdown();
1984        _result
1985    }
1986
1987    /// Similar to "send" but does not shutdown the channel if an error occurs.
1988    pub fn send_no_shutdown_on_err(
1989        self,
1990        mut result: Result<&[u8], i32>,
1991    ) -> Result<(), fidl::Error> {
1992        let _result = self.send_raw(result);
1993        self.drop_without_shutdown();
1994        _result
1995    }
1996
1997    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1998        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceGetReportResponse, i32>>(
1999            result.map(|report| (report,)),
2000            self.tx_id,
2001            0x5b2a44555defd970,
2002            fidl::encoding::DynamicFlags::empty(),
2003        )
2004    }
2005}
2006
2007#[must_use = "FIDL methods require a response to be sent"]
2008#[derive(Debug)]
2009pub struct DeviceSetReportResponder {
2010    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2011    tx_id: u32,
2012}
2013
2014/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2015/// if the responder is dropped without sending a response, so that the client
2016/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2017impl std::ops::Drop for DeviceSetReportResponder {
2018    fn drop(&mut self) {
2019        self.control_handle.shutdown();
2020        // Safety: drops once, never accessed again
2021        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2022    }
2023}
2024
2025impl fidl::endpoints::Responder for DeviceSetReportResponder {
2026    type ControlHandle = DeviceControlHandle;
2027
2028    fn control_handle(&self) -> &DeviceControlHandle {
2029        &self.control_handle
2030    }
2031
2032    fn drop_without_shutdown(mut self) {
2033        // Safety: drops once, never accessed again due to mem::forget
2034        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2035        // Prevent Drop from running (which would shut down the channel)
2036        std::mem::forget(self);
2037    }
2038}
2039
2040impl DeviceSetReportResponder {
2041    /// Sends a response to the FIDL transaction.
2042    ///
2043    /// Sets the channel to shutdown if an error occurs.
2044    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2045        let _result = self.send_raw(result);
2046        if _result.is_err() {
2047            self.control_handle.shutdown();
2048        }
2049        self.drop_without_shutdown();
2050        _result
2051    }
2052
2053    /// Similar to "send" but does not shutdown the channel if an error occurs.
2054    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2055        let _result = self.send_raw(result);
2056        self.drop_without_shutdown();
2057        _result
2058    }
2059
2060    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2061        self.control_handle
2062            .inner
2063            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2064                result,
2065                self.tx_id,
2066                0x51cc85eb4e769ee,
2067                fidl::encoding::DynamicFlags::empty(),
2068            )
2069    }
2070}
2071
2072#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2073pub struct DeviceReportsReaderMarker;
2074
2075impl fidl::endpoints::ProtocolMarker for DeviceReportsReaderMarker {
2076    type Proxy = DeviceReportsReaderProxy;
2077    type RequestStream = DeviceReportsReaderRequestStream;
2078    #[cfg(target_os = "fuchsia")]
2079    type SynchronousProxy = DeviceReportsReaderSynchronousProxy;
2080
2081    const DEBUG_NAME: &'static str = "(anonymous) DeviceReportsReader";
2082}
2083pub type DeviceReportsReaderReadReportsResult =
2084    Result<Vec<fidl_fuchsia_hardware_hidbus::Report>, i32>;
2085
2086pub trait DeviceReportsReaderProxyInterface: Send + Sync {
2087    type ReadReportsResponseFut: std::future::Future<Output = Result<DeviceReportsReaderReadReportsResult, fidl::Error>>
2088        + Send;
2089    fn r#read_reports(&self) -> Self::ReadReportsResponseFut;
2090}
2091#[derive(Debug)]
2092#[cfg(target_os = "fuchsia")]
2093pub struct DeviceReportsReaderSynchronousProxy {
2094    client: fidl::client::sync::Client,
2095}
2096
2097#[cfg(target_os = "fuchsia")]
2098impl fidl::endpoints::SynchronousProxy for DeviceReportsReaderSynchronousProxy {
2099    type Proxy = DeviceReportsReaderProxy;
2100    type Protocol = DeviceReportsReaderMarker;
2101
2102    fn from_channel(inner: fidl::Channel) -> Self {
2103        Self::new(inner)
2104    }
2105
2106    fn into_channel(self) -> fidl::Channel {
2107        self.client.into_channel()
2108    }
2109
2110    fn as_channel(&self) -> &fidl::Channel {
2111        self.client.as_channel()
2112    }
2113}
2114
2115#[cfg(target_os = "fuchsia")]
2116impl DeviceReportsReaderSynchronousProxy {
2117    pub fn new(channel: fidl::Channel) -> Self {
2118        Self { client: fidl::client::sync::Client::new(channel) }
2119    }
2120
2121    pub fn into_channel(self) -> fidl::Channel {
2122        self.client.into_channel()
2123    }
2124
2125    /// Waits until an event arrives and returns it. It is safe for other
2126    /// threads to make concurrent requests while waiting for an event.
2127    pub fn wait_for_event(
2128        &self,
2129        deadline: zx::MonotonicInstant,
2130    ) -> Result<DeviceReportsReaderEvent, fidl::Error> {
2131        DeviceReportsReaderEvent::decode(
2132            self.client.wait_for_event::<DeviceReportsReaderMarker>(deadline)?,
2133        )
2134    }
2135
2136    /// This is a Hanging-Get function to read the reports in the Report FIFO.
2137    /// This will block until there is at least one report available.
2138    /// If there is already one outstanding Hanging-Get, calling this again will
2139    /// return ZX_ERR_ALREADY_BOUND.
2140    pub fn r#read_reports(
2141        &self,
2142        ___deadline: zx::MonotonicInstant,
2143    ) -> Result<DeviceReportsReaderReadReportsResult, fidl::Error> {
2144        let _response = self.client.send_query::<
2145            fidl::encoding::EmptyPayload,
2146            fidl::encoding::ResultType<DeviceReportsReaderReadReportsResponse, i32>,
2147            DeviceReportsReaderMarker,
2148        >(
2149            (),
2150            0x36077c1b177d4291,
2151            fidl::encoding::DynamicFlags::empty(),
2152            ___deadline,
2153        )?;
2154        Ok(_response.map(|x| x.reports))
2155    }
2156}
2157
2158#[cfg(target_os = "fuchsia")]
2159impl From<DeviceReportsReaderSynchronousProxy> for zx::NullableHandle {
2160    fn from(value: DeviceReportsReaderSynchronousProxy) -> Self {
2161        value.into_channel().into()
2162    }
2163}
2164
2165#[cfg(target_os = "fuchsia")]
2166impl From<fidl::Channel> for DeviceReportsReaderSynchronousProxy {
2167    fn from(value: fidl::Channel) -> Self {
2168        Self::new(value)
2169    }
2170}
2171
2172#[cfg(target_os = "fuchsia")]
2173impl fidl::endpoints::FromClient for DeviceReportsReaderSynchronousProxy {
2174    type Protocol = DeviceReportsReaderMarker;
2175
2176    fn from_client(value: fidl::endpoints::ClientEnd<DeviceReportsReaderMarker>) -> Self {
2177        Self::new(value.into_channel())
2178    }
2179}
2180
2181#[derive(Debug, Clone)]
2182pub struct DeviceReportsReaderProxy {
2183    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2184}
2185
2186impl fidl::endpoints::Proxy for DeviceReportsReaderProxy {
2187    type Protocol = DeviceReportsReaderMarker;
2188
2189    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2190        Self::new(inner)
2191    }
2192
2193    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2194        self.client.into_channel().map_err(|client| Self { client })
2195    }
2196
2197    fn as_channel(&self) -> &::fidl::AsyncChannel {
2198        self.client.as_channel()
2199    }
2200}
2201
2202impl DeviceReportsReaderProxy {
2203    /// Create a new Proxy for fuchsia.hardware.input/DeviceReportsReader.
2204    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2205        let protocol_name =
2206            <DeviceReportsReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2207        Self { client: fidl::client::Client::new(channel, protocol_name) }
2208    }
2209
2210    /// Get a Stream of events from the remote end of the protocol.
2211    ///
2212    /// # Panics
2213    ///
2214    /// Panics if the event stream was already taken.
2215    pub fn take_event_stream(&self) -> DeviceReportsReaderEventStream {
2216        DeviceReportsReaderEventStream { event_receiver: self.client.take_event_receiver() }
2217    }
2218
2219    /// This is a Hanging-Get function to read the reports in the Report FIFO.
2220    /// This will block until there is at least one report available.
2221    /// If there is already one outstanding Hanging-Get, calling this again will
2222    /// return ZX_ERR_ALREADY_BOUND.
2223    pub fn r#read_reports(
2224        &self,
2225    ) -> fidl::client::QueryResponseFut<
2226        DeviceReportsReaderReadReportsResult,
2227        fidl::encoding::DefaultFuchsiaResourceDialect,
2228    > {
2229        DeviceReportsReaderProxyInterface::r#read_reports(self)
2230    }
2231}
2232
2233impl DeviceReportsReaderProxyInterface for DeviceReportsReaderProxy {
2234    type ReadReportsResponseFut = fidl::client::QueryResponseFut<
2235        DeviceReportsReaderReadReportsResult,
2236        fidl::encoding::DefaultFuchsiaResourceDialect,
2237    >;
2238    fn r#read_reports(&self) -> Self::ReadReportsResponseFut {
2239        fn _decode(
2240            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2241        ) -> Result<DeviceReportsReaderReadReportsResult, fidl::Error> {
2242            let _response = fidl::client::decode_transaction_body::<
2243                fidl::encoding::ResultType<DeviceReportsReaderReadReportsResponse, i32>,
2244                fidl::encoding::DefaultFuchsiaResourceDialect,
2245                0x36077c1b177d4291,
2246            >(_buf?)?;
2247            Ok(_response.map(|x| x.reports))
2248        }
2249        self.client.send_query_and_decode::<
2250            fidl::encoding::EmptyPayload,
2251            DeviceReportsReaderReadReportsResult,
2252        >(
2253            (),
2254            0x36077c1b177d4291,
2255            fidl::encoding::DynamicFlags::empty(),
2256            _decode,
2257        )
2258    }
2259}
2260
2261pub struct DeviceReportsReaderEventStream {
2262    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2263}
2264
2265impl std::marker::Unpin for DeviceReportsReaderEventStream {}
2266
2267impl futures::stream::FusedStream for DeviceReportsReaderEventStream {
2268    fn is_terminated(&self) -> bool {
2269        self.event_receiver.is_terminated()
2270    }
2271}
2272
2273impl futures::Stream for DeviceReportsReaderEventStream {
2274    type Item = Result<DeviceReportsReaderEvent, fidl::Error>;
2275
2276    fn poll_next(
2277        mut self: std::pin::Pin<&mut Self>,
2278        cx: &mut std::task::Context<'_>,
2279    ) -> std::task::Poll<Option<Self::Item>> {
2280        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2281            &mut self.event_receiver,
2282            cx
2283        )?) {
2284            Some(buf) => std::task::Poll::Ready(Some(DeviceReportsReaderEvent::decode(buf))),
2285            None => std::task::Poll::Ready(None),
2286        }
2287    }
2288}
2289
2290#[derive(Debug)]
2291pub enum DeviceReportsReaderEvent {}
2292
2293impl DeviceReportsReaderEvent {
2294    /// Decodes a message buffer as a [`DeviceReportsReaderEvent`].
2295    fn decode(
2296        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2297    ) -> Result<DeviceReportsReaderEvent, fidl::Error> {
2298        let (bytes, _handles) = buf.split_mut();
2299        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2300        debug_assert_eq!(tx_header.tx_id, 0);
2301        match tx_header.ordinal {
2302            _ => Err(fidl::Error::UnknownOrdinal {
2303                ordinal: tx_header.ordinal,
2304                protocol_name:
2305                    <DeviceReportsReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2306            }),
2307        }
2308    }
2309}
2310
2311/// A Stream of incoming requests for fuchsia.hardware.input/DeviceReportsReader.
2312pub struct DeviceReportsReaderRequestStream {
2313    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2314    is_terminated: bool,
2315}
2316
2317impl std::marker::Unpin for DeviceReportsReaderRequestStream {}
2318
2319impl futures::stream::FusedStream for DeviceReportsReaderRequestStream {
2320    fn is_terminated(&self) -> bool {
2321        self.is_terminated
2322    }
2323}
2324
2325impl fidl::endpoints::RequestStream for DeviceReportsReaderRequestStream {
2326    type Protocol = DeviceReportsReaderMarker;
2327    type ControlHandle = DeviceReportsReaderControlHandle;
2328
2329    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2330        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2331    }
2332
2333    fn control_handle(&self) -> Self::ControlHandle {
2334        DeviceReportsReaderControlHandle { inner: self.inner.clone() }
2335    }
2336
2337    fn into_inner(
2338        self,
2339    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2340    {
2341        (self.inner, self.is_terminated)
2342    }
2343
2344    fn from_inner(
2345        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2346        is_terminated: bool,
2347    ) -> Self {
2348        Self { inner, is_terminated }
2349    }
2350}
2351
2352impl futures::Stream for DeviceReportsReaderRequestStream {
2353    type Item = Result<DeviceReportsReaderRequest, fidl::Error>;
2354
2355    fn poll_next(
2356        mut self: std::pin::Pin<&mut Self>,
2357        cx: &mut std::task::Context<'_>,
2358    ) -> std::task::Poll<Option<Self::Item>> {
2359        let this = &mut *self;
2360        if this.inner.check_shutdown(cx) {
2361            this.is_terminated = true;
2362            return std::task::Poll::Ready(None);
2363        }
2364        if this.is_terminated {
2365            panic!("polled DeviceReportsReaderRequestStream after completion");
2366        }
2367        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2368            |bytes, handles| {
2369                match this.inner.channel().read_etc(cx, bytes, handles) {
2370                    std::task::Poll::Ready(Ok(())) => {}
2371                    std::task::Poll::Pending => return std::task::Poll::Pending,
2372                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2373                        this.is_terminated = true;
2374                        return std::task::Poll::Ready(None);
2375                    }
2376                    std::task::Poll::Ready(Err(e)) => {
2377                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2378                            e.into(),
2379                        ))));
2380                    }
2381                }
2382
2383                // A message has been received from the channel
2384                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2385
2386                std::task::Poll::Ready(Some(match header.ordinal {
2387                0x36077c1b177d4291 => {
2388                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2389                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
2390                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2391                    let control_handle = DeviceReportsReaderControlHandle {
2392                        inner: this.inner.clone(),
2393                    };
2394                    Ok(DeviceReportsReaderRequest::ReadReports {
2395                        responder: DeviceReportsReaderReadReportsResponder {
2396                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2397                            tx_id: header.tx_id,
2398                        },
2399                    })
2400                }
2401                _ => Err(fidl::Error::UnknownOrdinal {
2402                    ordinal: header.ordinal,
2403                    protocol_name: <DeviceReportsReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2404                }),
2405            }))
2406            },
2407        )
2408    }
2409}
2410
2411/// Each `DeviceReportsReader` has its own FIFO of reports in the driver.
2412/// Calling `ReadReports` drains the Report FIFO. If the Report FIFO fills up
2413/// between calls to `ReadReports` the channel will be closed.
2414#[derive(Debug)]
2415pub enum DeviceReportsReaderRequest {
2416    /// This is a Hanging-Get function to read the reports in the Report FIFO.
2417    /// This will block until there is at least one report available.
2418    /// If there is already one outstanding Hanging-Get, calling this again will
2419    /// return ZX_ERR_ALREADY_BOUND.
2420    ReadReports { responder: DeviceReportsReaderReadReportsResponder },
2421}
2422
2423impl DeviceReportsReaderRequest {
2424    #[allow(irrefutable_let_patterns)]
2425    pub fn into_read_reports(self) -> Option<(DeviceReportsReaderReadReportsResponder)> {
2426        if let DeviceReportsReaderRequest::ReadReports { responder } = self {
2427            Some((responder))
2428        } else {
2429            None
2430        }
2431    }
2432
2433    /// Name of the method defined in FIDL
2434    pub fn method_name(&self) -> &'static str {
2435        match *self {
2436            DeviceReportsReaderRequest::ReadReports { .. } => "read_reports",
2437        }
2438    }
2439}
2440
2441#[derive(Debug, Clone)]
2442pub struct DeviceReportsReaderControlHandle {
2443    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2444}
2445
2446impl DeviceReportsReaderControlHandle {
2447    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2448        self.inner.shutdown_with_epitaph(status.into())
2449    }
2450}
2451
2452impl fidl::endpoints::ControlHandle for DeviceReportsReaderControlHandle {
2453    fn shutdown(&self) {
2454        self.inner.shutdown()
2455    }
2456
2457    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2458        self.inner.shutdown_with_epitaph(status)
2459    }
2460
2461    fn is_closed(&self) -> bool {
2462        self.inner.channel().is_closed()
2463    }
2464    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2465        self.inner.channel().on_closed()
2466    }
2467
2468    #[cfg(target_os = "fuchsia")]
2469    fn signal_peer(
2470        &self,
2471        clear_mask: zx::Signals,
2472        set_mask: zx::Signals,
2473    ) -> Result<(), zx_status::Status> {
2474        use fidl::Peered;
2475        self.inner.channel().signal_peer(clear_mask, set_mask)
2476    }
2477}
2478
2479impl DeviceReportsReaderControlHandle {}
2480
2481#[must_use = "FIDL methods require a response to be sent"]
2482#[derive(Debug)]
2483pub struct DeviceReportsReaderReadReportsResponder {
2484    control_handle: std::mem::ManuallyDrop<DeviceReportsReaderControlHandle>,
2485    tx_id: u32,
2486}
2487
2488/// Set the the channel to be shutdown (see [`DeviceReportsReaderControlHandle::shutdown`])
2489/// if the responder is dropped without sending a response, so that the client
2490/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2491impl std::ops::Drop for DeviceReportsReaderReadReportsResponder {
2492    fn drop(&mut self) {
2493        self.control_handle.shutdown();
2494        // Safety: drops once, never accessed again
2495        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2496    }
2497}
2498
2499impl fidl::endpoints::Responder for DeviceReportsReaderReadReportsResponder {
2500    type ControlHandle = DeviceReportsReaderControlHandle;
2501
2502    fn control_handle(&self) -> &DeviceReportsReaderControlHandle {
2503        &self.control_handle
2504    }
2505
2506    fn drop_without_shutdown(mut self) {
2507        // Safety: drops once, never accessed again due to mem::forget
2508        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2509        // Prevent Drop from running (which would shut down the channel)
2510        std::mem::forget(self);
2511    }
2512}
2513
2514impl DeviceReportsReaderReadReportsResponder {
2515    /// Sends a response to the FIDL transaction.
2516    ///
2517    /// Sets the channel to shutdown if an error occurs.
2518    pub fn send(
2519        self,
2520        mut result: Result<Vec<fidl_fuchsia_hardware_hidbus::Report>, i32>,
2521    ) -> Result<(), fidl::Error> {
2522        let _result = self.send_raw(result);
2523        if _result.is_err() {
2524            self.control_handle.shutdown();
2525        }
2526        self.drop_without_shutdown();
2527        _result
2528    }
2529
2530    /// Similar to "send" but does not shutdown the channel if an error occurs.
2531    pub fn send_no_shutdown_on_err(
2532        self,
2533        mut result: Result<Vec<fidl_fuchsia_hardware_hidbus::Report>, i32>,
2534    ) -> Result<(), fidl::Error> {
2535        let _result = self.send_raw(result);
2536        self.drop_without_shutdown();
2537        _result
2538    }
2539
2540    fn send_raw(
2541        &self,
2542        mut result: Result<Vec<fidl_fuchsia_hardware_hidbus::Report>, i32>,
2543    ) -> Result<(), fidl::Error> {
2544        self.control_handle.inner.send::<fidl::encoding::ResultType<
2545            DeviceReportsReaderReadReportsResponse,
2546            i32,
2547        >>(
2548            result.as_mut().map_err(|e| *e).map(|reports| (reports.as_mut_slice(),)),
2549            self.tx_id,
2550            0x36077c1b177d4291,
2551            fidl::encoding::DynamicFlags::empty(),
2552        )
2553    }
2554}
2555
2556#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2557pub struct ServiceMarker;
2558
2559#[cfg(target_os = "fuchsia")]
2560impl fidl::endpoints::ServiceMarker for ServiceMarker {
2561    type Proxy = ServiceProxy;
2562    type Request = ServiceRequest;
2563    const SERVICE_NAME: &'static str = "fuchsia.hardware.input.Service";
2564}
2565
2566/// A request for one of the member protocols of Service.
2567///
2568#[cfg(target_os = "fuchsia")]
2569pub enum ServiceRequest {
2570    Controller(ControllerRequestStream),
2571}
2572
2573#[cfg(target_os = "fuchsia")]
2574impl fidl::endpoints::ServiceRequest for ServiceRequest {
2575    type Service = ServiceMarker;
2576
2577    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2578        match name {
2579            "controller" => Self::Controller(
2580                <ControllerRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2581            ),
2582            _ => panic!("no such member protocol name for service Service"),
2583        }
2584    }
2585
2586    fn member_names() -> &'static [&'static str] {
2587        &["controller"]
2588    }
2589}
2590#[cfg(target_os = "fuchsia")]
2591pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2592
2593#[cfg(target_os = "fuchsia")]
2594impl fidl::endpoints::ServiceProxy for ServiceProxy {
2595    type Service = ServiceMarker;
2596
2597    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2598        Self(opener)
2599    }
2600}
2601
2602#[cfg(target_os = "fuchsia")]
2603impl ServiceProxy {
2604    pub fn connect_to_controller(&self) -> Result<ControllerProxy, fidl::Error> {
2605        let (proxy, server_end) = fidl::endpoints::create_proxy::<ControllerMarker>();
2606        self.connect_channel_to_controller(server_end)?;
2607        Ok(proxy)
2608    }
2609
2610    /// Like `connect_to_controller`, but returns a sync proxy.
2611    /// See [`Self::connect_to_controller`] for more details.
2612    pub fn connect_to_controller_sync(&self) -> Result<ControllerSynchronousProxy, fidl::Error> {
2613        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ControllerMarker>();
2614        self.connect_channel_to_controller(server_end)?;
2615        Ok(proxy)
2616    }
2617
2618    /// Like `connect_to_controller`, but accepts a server end.
2619    /// See [`Self::connect_to_controller`] for more details.
2620    pub fn connect_channel_to_controller(
2621        &self,
2622        server_end: fidl::endpoints::ServerEnd<ControllerMarker>,
2623    ) -> Result<(), fidl::Error> {
2624        self.0.open_member("controller", server_end.into_channel())
2625    }
2626
2627    pub fn instance_name(&self) -> &str {
2628        self.0.instance_name()
2629    }
2630}
2631
2632mod internal {
2633    use super::*;
2634
2635    impl fidl::encoding::ResourceTypeMarker for ControllerOpenSessionRequest {
2636        type Borrowed<'a> = &'a mut Self;
2637        fn take_or_borrow<'a>(
2638            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2639        ) -> Self::Borrowed<'a> {
2640            value
2641        }
2642    }
2643
2644    unsafe impl fidl::encoding::TypeMarker for ControllerOpenSessionRequest {
2645        type Owned = Self;
2646
2647        #[inline(always)]
2648        fn inline_align(_context: fidl::encoding::Context) -> usize {
2649            4
2650        }
2651
2652        #[inline(always)]
2653        fn inline_size(_context: fidl::encoding::Context) -> usize {
2654            4
2655        }
2656    }
2657
2658    unsafe impl
2659        fidl::encoding::Encode<
2660            ControllerOpenSessionRequest,
2661            fidl::encoding::DefaultFuchsiaResourceDialect,
2662        > for &mut ControllerOpenSessionRequest
2663    {
2664        #[inline]
2665        unsafe fn encode(
2666            self,
2667            encoder: &mut fidl::encoding::Encoder<
2668                '_,
2669                fidl::encoding::DefaultFuchsiaResourceDialect,
2670            >,
2671            offset: usize,
2672            _depth: fidl::encoding::Depth,
2673        ) -> fidl::Result<()> {
2674            encoder.debug_check_bounds::<ControllerOpenSessionRequest>(offset);
2675            // Delegate to tuple encoding.
2676            fidl::encoding::Encode::<ControllerOpenSessionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2677                (
2678                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
2679                ),
2680                encoder, offset, _depth
2681            )
2682        }
2683    }
2684    unsafe impl<
2685        T0: fidl::encoding::Encode<
2686                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2687                fidl::encoding::DefaultFuchsiaResourceDialect,
2688            >,
2689    >
2690        fidl::encoding::Encode<
2691            ControllerOpenSessionRequest,
2692            fidl::encoding::DefaultFuchsiaResourceDialect,
2693        > for (T0,)
2694    {
2695        #[inline]
2696        unsafe fn encode(
2697            self,
2698            encoder: &mut fidl::encoding::Encoder<
2699                '_,
2700                fidl::encoding::DefaultFuchsiaResourceDialect,
2701            >,
2702            offset: usize,
2703            depth: fidl::encoding::Depth,
2704        ) -> fidl::Result<()> {
2705            encoder.debug_check_bounds::<ControllerOpenSessionRequest>(offset);
2706            // Zero out padding regions. There's no need to apply masks
2707            // because the unmasked parts will be overwritten by fields.
2708            // Write the fields.
2709            self.0.encode(encoder, offset + 0, depth)?;
2710            Ok(())
2711        }
2712    }
2713
2714    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2715        for ControllerOpenSessionRequest
2716    {
2717        #[inline(always)]
2718        fn new_empty() -> Self {
2719            Self {
2720                session: fidl::new_empty!(
2721                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2722                    fidl::encoding::DefaultFuchsiaResourceDialect
2723                ),
2724            }
2725        }
2726
2727        #[inline]
2728        unsafe fn decode(
2729            &mut self,
2730            decoder: &mut fidl::encoding::Decoder<
2731                '_,
2732                fidl::encoding::DefaultFuchsiaResourceDialect,
2733            >,
2734            offset: usize,
2735            _depth: fidl::encoding::Depth,
2736        ) -> fidl::Result<()> {
2737            decoder.debug_check_bounds::<Self>(offset);
2738            // Verify that padding bytes are zero.
2739            fidl::decode!(
2740                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2741                fidl::encoding::DefaultFuchsiaResourceDialect,
2742                &mut self.session,
2743                decoder,
2744                offset + 0,
2745                _depth
2746            )?;
2747            Ok(())
2748        }
2749    }
2750
2751    impl fidl::encoding::ResourceTypeMarker for DeviceGetDeviceReportsReaderRequest {
2752        type Borrowed<'a> = &'a mut Self;
2753        fn take_or_borrow<'a>(
2754            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2755        ) -> Self::Borrowed<'a> {
2756            value
2757        }
2758    }
2759
2760    unsafe impl fidl::encoding::TypeMarker for DeviceGetDeviceReportsReaderRequest {
2761        type Owned = Self;
2762
2763        #[inline(always)]
2764        fn inline_align(_context: fidl::encoding::Context) -> usize {
2765            4
2766        }
2767
2768        #[inline(always)]
2769        fn inline_size(_context: fidl::encoding::Context) -> usize {
2770            4
2771        }
2772    }
2773
2774    unsafe impl
2775        fidl::encoding::Encode<
2776            DeviceGetDeviceReportsReaderRequest,
2777            fidl::encoding::DefaultFuchsiaResourceDialect,
2778        > for &mut DeviceGetDeviceReportsReaderRequest
2779    {
2780        #[inline]
2781        unsafe fn encode(
2782            self,
2783            encoder: &mut fidl::encoding::Encoder<
2784                '_,
2785                fidl::encoding::DefaultFuchsiaResourceDialect,
2786            >,
2787            offset: usize,
2788            _depth: fidl::encoding::Depth,
2789        ) -> fidl::Result<()> {
2790            encoder.debug_check_bounds::<DeviceGetDeviceReportsReaderRequest>(offset);
2791            // Delegate to tuple encoding.
2792            fidl::encoding::Encode::<DeviceGetDeviceReportsReaderRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2793                (
2794                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.reader),
2795                ),
2796                encoder, offset, _depth
2797            )
2798        }
2799    }
2800    unsafe impl<
2801        T0: fidl::encoding::Encode<
2802                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>>,
2803                fidl::encoding::DefaultFuchsiaResourceDialect,
2804            >,
2805    >
2806        fidl::encoding::Encode<
2807            DeviceGetDeviceReportsReaderRequest,
2808            fidl::encoding::DefaultFuchsiaResourceDialect,
2809        > for (T0,)
2810    {
2811        #[inline]
2812        unsafe fn encode(
2813            self,
2814            encoder: &mut fidl::encoding::Encoder<
2815                '_,
2816                fidl::encoding::DefaultFuchsiaResourceDialect,
2817            >,
2818            offset: usize,
2819            depth: fidl::encoding::Depth,
2820        ) -> fidl::Result<()> {
2821            encoder.debug_check_bounds::<DeviceGetDeviceReportsReaderRequest>(offset);
2822            // Zero out padding regions. There's no need to apply masks
2823            // because the unmasked parts will be overwritten by fields.
2824            // Write the fields.
2825            self.0.encode(encoder, offset + 0, depth)?;
2826            Ok(())
2827        }
2828    }
2829
2830    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2831        for DeviceGetDeviceReportsReaderRequest
2832    {
2833        #[inline(always)]
2834        fn new_empty() -> Self {
2835            Self {
2836                reader: fidl::new_empty!(
2837                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>>,
2838                    fidl::encoding::DefaultFuchsiaResourceDialect
2839                ),
2840            }
2841        }
2842
2843        #[inline]
2844        unsafe fn decode(
2845            &mut self,
2846            decoder: &mut fidl::encoding::Decoder<
2847                '_,
2848                fidl::encoding::DefaultFuchsiaResourceDialect,
2849            >,
2850            offset: usize,
2851            _depth: fidl::encoding::Depth,
2852        ) -> fidl::Result<()> {
2853            decoder.debug_check_bounds::<Self>(offset);
2854            // Verify that padding bytes are zero.
2855            fidl::decode!(
2856                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>>,
2857                fidl::encoding::DefaultFuchsiaResourceDialect,
2858                &mut self.reader,
2859                decoder,
2860                offset + 0,
2861                _depth
2862            )?;
2863            Ok(())
2864        }
2865    }
2866
2867    impl fidl::encoding::ResourceTypeMarker for DeviceReportsReaderReadReportsResponse {
2868        type Borrowed<'a> = &'a mut Self;
2869        fn take_or_borrow<'a>(
2870            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2871        ) -> Self::Borrowed<'a> {
2872            value
2873        }
2874    }
2875
2876    unsafe impl fidl::encoding::TypeMarker for DeviceReportsReaderReadReportsResponse {
2877        type Owned = Self;
2878
2879        #[inline(always)]
2880        fn inline_align(_context: fidl::encoding::Context) -> usize {
2881            8
2882        }
2883
2884        #[inline(always)]
2885        fn inline_size(_context: fidl::encoding::Context) -> usize {
2886            16
2887        }
2888    }
2889
2890    unsafe impl
2891        fidl::encoding::Encode<
2892            DeviceReportsReaderReadReportsResponse,
2893            fidl::encoding::DefaultFuchsiaResourceDialect,
2894        > for &mut DeviceReportsReaderReadReportsResponse
2895    {
2896        #[inline]
2897        unsafe fn encode(
2898            self,
2899            encoder: &mut fidl::encoding::Encoder<
2900                '_,
2901                fidl::encoding::DefaultFuchsiaResourceDialect,
2902            >,
2903            offset: usize,
2904            _depth: fidl::encoding::Depth,
2905        ) -> fidl::Result<()> {
2906            encoder.debug_check_bounds::<DeviceReportsReaderReadReportsResponse>(offset);
2907            // Delegate to tuple encoding.
2908            fidl::encoding::Encode::<DeviceReportsReaderReadReportsResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2909                (
2910                    <fidl::encoding::Vector<fidl_fuchsia_hardware_hidbus::Report, 50> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.reports),
2911                ),
2912                encoder, offset, _depth
2913            )
2914        }
2915    }
2916    unsafe impl<
2917        T0: fidl::encoding::Encode<
2918                fidl::encoding::Vector<fidl_fuchsia_hardware_hidbus::Report, 50>,
2919                fidl::encoding::DefaultFuchsiaResourceDialect,
2920            >,
2921    >
2922        fidl::encoding::Encode<
2923            DeviceReportsReaderReadReportsResponse,
2924            fidl::encoding::DefaultFuchsiaResourceDialect,
2925        > for (T0,)
2926    {
2927        #[inline]
2928        unsafe fn encode(
2929            self,
2930            encoder: &mut fidl::encoding::Encoder<
2931                '_,
2932                fidl::encoding::DefaultFuchsiaResourceDialect,
2933            >,
2934            offset: usize,
2935            depth: fidl::encoding::Depth,
2936        ) -> fidl::Result<()> {
2937            encoder.debug_check_bounds::<DeviceReportsReaderReadReportsResponse>(offset);
2938            // Zero out padding regions. There's no need to apply masks
2939            // because the unmasked parts will be overwritten by fields.
2940            // Write the fields.
2941            self.0.encode(encoder, offset + 0, depth)?;
2942            Ok(())
2943        }
2944    }
2945
2946    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2947        for DeviceReportsReaderReadReportsResponse
2948    {
2949        #[inline(always)]
2950        fn new_empty() -> Self {
2951            Self {
2952                reports: fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_hardware_hidbus::Report, 50>, fidl::encoding::DefaultFuchsiaResourceDialect),
2953            }
2954        }
2955
2956        #[inline]
2957        unsafe fn decode(
2958            &mut self,
2959            decoder: &mut fidl::encoding::Decoder<
2960                '_,
2961                fidl::encoding::DefaultFuchsiaResourceDialect,
2962            >,
2963            offset: usize,
2964            _depth: fidl::encoding::Depth,
2965        ) -> fidl::Result<()> {
2966            decoder.debug_check_bounds::<Self>(offset);
2967            // Verify that padding bytes are zero.
2968            fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_hardware_hidbus::Report, 50>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reports, decoder, offset + 0, _depth)?;
2969            Ok(())
2970        }
2971    }
2972
2973    impl fidl::encoding::ResourceTypeMarker for DeviceGetReportsEventResponse {
2974        type Borrowed<'a> = &'a mut Self;
2975        fn take_or_borrow<'a>(
2976            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2977        ) -> Self::Borrowed<'a> {
2978            value
2979        }
2980    }
2981
2982    unsafe impl fidl::encoding::TypeMarker for DeviceGetReportsEventResponse {
2983        type Owned = Self;
2984
2985        #[inline(always)]
2986        fn inline_align(_context: fidl::encoding::Context) -> usize {
2987            4
2988        }
2989
2990        #[inline(always)]
2991        fn inline_size(_context: fidl::encoding::Context) -> usize {
2992            4
2993        }
2994    }
2995
2996    unsafe impl
2997        fidl::encoding::Encode<
2998            DeviceGetReportsEventResponse,
2999            fidl::encoding::DefaultFuchsiaResourceDialect,
3000        > for &mut DeviceGetReportsEventResponse
3001    {
3002        #[inline]
3003        unsafe fn encode(
3004            self,
3005            encoder: &mut fidl::encoding::Encoder<
3006                '_,
3007                fidl::encoding::DefaultFuchsiaResourceDialect,
3008            >,
3009            offset: usize,
3010            _depth: fidl::encoding::Depth,
3011        ) -> fidl::Result<()> {
3012            encoder.debug_check_bounds::<DeviceGetReportsEventResponse>(offset);
3013            // Delegate to tuple encoding.
3014            fidl::encoding::Encode::<
3015                DeviceGetReportsEventResponse,
3016                fidl::encoding::DefaultFuchsiaResourceDialect,
3017            >::encode(
3018                (<fidl::encoding::HandleType<
3019                    fidl::Event,
3020                    { fidl::ObjectType::EVENT.into_raw() },
3021                    2147483648,
3022                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3023                    &mut self.event
3024                ),),
3025                encoder,
3026                offset,
3027                _depth,
3028            )
3029        }
3030    }
3031    unsafe impl<
3032        T0: fidl::encoding::Encode<
3033                fidl::encoding::HandleType<
3034                    fidl::Event,
3035                    { fidl::ObjectType::EVENT.into_raw() },
3036                    2147483648,
3037                >,
3038                fidl::encoding::DefaultFuchsiaResourceDialect,
3039            >,
3040    >
3041        fidl::encoding::Encode<
3042            DeviceGetReportsEventResponse,
3043            fidl::encoding::DefaultFuchsiaResourceDialect,
3044        > for (T0,)
3045    {
3046        #[inline]
3047        unsafe fn encode(
3048            self,
3049            encoder: &mut fidl::encoding::Encoder<
3050                '_,
3051                fidl::encoding::DefaultFuchsiaResourceDialect,
3052            >,
3053            offset: usize,
3054            depth: fidl::encoding::Depth,
3055        ) -> fidl::Result<()> {
3056            encoder.debug_check_bounds::<DeviceGetReportsEventResponse>(offset);
3057            // Zero out padding regions. There's no need to apply masks
3058            // because the unmasked parts will be overwritten by fields.
3059            // Write the fields.
3060            self.0.encode(encoder, offset + 0, depth)?;
3061            Ok(())
3062        }
3063    }
3064
3065    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3066        for DeviceGetReportsEventResponse
3067    {
3068        #[inline(always)]
3069        fn new_empty() -> Self {
3070            Self {
3071                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3072            }
3073        }
3074
3075        #[inline]
3076        unsafe fn decode(
3077            &mut self,
3078            decoder: &mut fidl::encoding::Decoder<
3079                '_,
3080                fidl::encoding::DefaultFuchsiaResourceDialect,
3081            >,
3082            offset: usize,
3083            _depth: fidl::encoding::Depth,
3084        ) -> fidl::Result<()> {
3085            decoder.debug_check_bounds::<Self>(offset);
3086            // Verify that padding bytes are zero.
3087            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3088            Ok(())
3089        }
3090    }
3091}