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