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 {
1389            Some((responder))
1390        } else {
1391            None
1392        }
1393    }
1394
1395    #[allow(irrefutable_let_patterns)]
1396    pub fn into_get_report_desc(self) -> Option<(DeviceGetReportDescResponder)> {
1397        if let DeviceRequest::GetReportDesc { responder } = self {
1398            Some((responder))
1399        } else {
1400            None
1401        }
1402    }
1403
1404    #[allow(irrefutable_let_patterns)]
1405    pub fn into_get_device_reports_reader(
1406        self,
1407    ) -> Option<(
1408        fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>,
1409        DeviceGetDeviceReportsReaderResponder,
1410    )> {
1411        if let DeviceRequest::GetDeviceReportsReader { reader, responder } = self {
1412            Some((reader, responder))
1413        } else {
1414            None
1415        }
1416    }
1417
1418    #[allow(irrefutable_let_patterns)]
1419    pub fn into_read_report(self) -> Option<(DeviceReadReportResponder)> {
1420        if let DeviceRequest::ReadReport { responder } = self {
1421            Some((responder))
1422        } else {
1423            None
1424        }
1425    }
1426
1427    #[allow(irrefutable_let_patterns)]
1428    pub fn into_read_reports(self) -> Option<(DeviceReadReportsResponder)> {
1429        if let DeviceRequest::ReadReports { responder } = self {
1430            Some((responder))
1431        } else {
1432            None
1433        }
1434    }
1435
1436    #[allow(irrefutable_let_patterns)]
1437    pub fn into_get_reports_event(self) -> Option<(DeviceGetReportsEventResponder)> {
1438        if let DeviceRequest::GetReportsEvent { responder } = self {
1439            Some((responder))
1440        } else {
1441            None
1442        }
1443    }
1444
1445    #[allow(irrefutable_let_patterns)]
1446    pub fn into_get_report(
1447        self,
1448    ) -> Option<(fidl_fuchsia_hardware_hidbus::ReportType, u8, DeviceGetReportResponder)> {
1449        if let DeviceRequest::GetReport { type_, id, responder } = self {
1450            Some((type_, id, responder))
1451        } else {
1452            None
1453        }
1454    }
1455
1456    #[allow(irrefutable_let_patterns)]
1457    pub fn into_set_report(
1458        self,
1459    ) -> Option<(fidl_fuchsia_hardware_hidbus::ReportType, u8, Vec<u8>, DeviceSetReportResponder)>
1460    {
1461        if let DeviceRequest::SetReport { type_, id, report, responder } = self {
1462            Some((type_, id, report, responder))
1463        } else {
1464            None
1465        }
1466    }
1467
1468    #[allow(irrefutable_let_patterns)]
1469    pub fn into_set_trace_id(self) -> Option<(u32, DeviceControlHandle)> {
1470        if let DeviceRequest::SetTraceId { id, control_handle } = self {
1471            Some((id, control_handle))
1472        } else {
1473            None
1474        }
1475    }
1476
1477    /// Name of the method defined in FIDL
1478    pub fn method_name(&self) -> &'static str {
1479        match *self {
1480            DeviceRequest::Query { .. } => "query",
1481            DeviceRequest::GetReportDesc { .. } => "get_report_desc",
1482            DeviceRequest::GetDeviceReportsReader { .. } => "get_device_reports_reader",
1483            DeviceRequest::ReadReport { .. } => "read_report",
1484            DeviceRequest::ReadReports { .. } => "read_reports",
1485            DeviceRequest::GetReportsEvent { .. } => "get_reports_event",
1486            DeviceRequest::GetReport { .. } => "get_report",
1487            DeviceRequest::SetReport { .. } => "set_report",
1488            DeviceRequest::SetTraceId { .. } => "set_trace_id",
1489        }
1490    }
1491}
1492
1493#[derive(Debug, Clone)]
1494pub struct DeviceControlHandle {
1495    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1496}
1497
1498impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1499    fn shutdown(&self) {
1500        self.inner.shutdown()
1501    }
1502    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1503        self.inner.shutdown_with_epitaph(status)
1504    }
1505
1506    fn is_closed(&self) -> bool {
1507        self.inner.channel().is_closed()
1508    }
1509    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1510        self.inner.channel().on_closed()
1511    }
1512
1513    #[cfg(target_os = "fuchsia")]
1514    fn signal_peer(
1515        &self,
1516        clear_mask: zx::Signals,
1517        set_mask: zx::Signals,
1518    ) -> Result<(), zx_status::Status> {
1519        use fidl::Peered;
1520        self.inner.channel().signal_peer(clear_mask, set_mask)
1521    }
1522}
1523
1524impl DeviceControlHandle {}
1525
1526#[must_use = "FIDL methods require a response to be sent"]
1527#[derive(Debug)]
1528pub struct DeviceQueryResponder {
1529    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1530    tx_id: u32,
1531}
1532
1533/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1534/// if the responder is dropped without sending a response, so that the client
1535/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1536impl std::ops::Drop for DeviceQueryResponder {
1537    fn drop(&mut self) {
1538        self.control_handle.shutdown();
1539        // Safety: drops once, never accessed again
1540        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1541    }
1542}
1543
1544impl fidl::endpoints::Responder for DeviceQueryResponder {
1545    type ControlHandle = DeviceControlHandle;
1546
1547    fn control_handle(&self) -> &DeviceControlHandle {
1548        &self.control_handle
1549    }
1550
1551    fn drop_without_shutdown(mut self) {
1552        // Safety: drops once, never accessed again due to mem::forget
1553        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1554        // Prevent Drop from running (which would shut down the channel)
1555        std::mem::forget(self);
1556    }
1557}
1558
1559impl DeviceQueryResponder {
1560    /// Sends a response to the FIDL transaction.
1561    ///
1562    /// Sets the channel to shutdown if an error occurs.
1563    pub fn send(
1564        self,
1565        mut result: Result<&fidl_fuchsia_hardware_hidbus::HidInfo, i32>,
1566    ) -> Result<(), fidl::Error> {
1567        let _result = self.send_raw(result);
1568        if _result.is_err() {
1569            self.control_handle.shutdown();
1570        }
1571        self.drop_without_shutdown();
1572        _result
1573    }
1574
1575    /// Similar to "send" but does not shutdown the channel if an error occurs.
1576    pub fn send_no_shutdown_on_err(
1577        self,
1578        mut result: Result<&fidl_fuchsia_hardware_hidbus::HidInfo, i32>,
1579    ) -> Result<(), fidl::Error> {
1580        let _result = self.send_raw(result);
1581        self.drop_without_shutdown();
1582        _result
1583    }
1584
1585    fn send_raw(
1586        &self,
1587        mut result: Result<&fidl_fuchsia_hardware_hidbus::HidInfo, i32>,
1588    ) -> Result<(), fidl::Error> {
1589        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceQueryResponse, i32>>(
1590            result.map(|info| (info,)),
1591            self.tx_id,
1592            0x6d1d90313259dae3,
1593            fidl::encoding::DynamicFlags::empty(),
1594        )
1595    }
1596}
1597
1598#[must_use = "FIDL methods require a response to be sent"]
1599#[derive(Debug)]
1600pub struct DeviceGetReportDescResponder {
1601    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1602    tx_id: u32,
1603}
1604
1605/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1606/// if the responder is dropped without sending a response, so that the client
1607/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1608impl std::ops::Drop for DeviceGetReportDescResponder {
1609    fn drop(&mut self) {
1610        self.control_handle.shutdown();
1611        // Safety: drops once, never accessed again
1612        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1613    }
1614}
1615
1616impl fidl::endpoints::Responder for DeviceGetReportDescResponder {
1617    type ControlHandle = DeviceControlHandle;
1618
1619    fn control_handle(&self) -> &DeviceControlHandle {
1620        &self.control_handle
1621    }
1622
1623    fn drop_without_shutdown(mut self) {
1624        // Safety: drops once, never accessed again due to mem::forget
1625        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1626        // Prevent Drop from running (which would shut down the channel)
1627        std::mem::forget(self);
1628    }
1629}
1630
1631impl DeviceGetReportDescResponder {
1632    /// Sends a response to the FIDL transaction.
1633    ///
1634    /// Sets the channel to shutdown if an error occurs.
1635    pub fn send(self, mut desc: &[u8]) -> Result<(), fidl::Error> {
1636        let _result = self.send_raw(desc);
1637        if _result.is_err() {
1638            self.control_handle.shutdown();
1639        }
1640        self.drop_without_shutdown();
1641        _result
1642    }
1643
1644    /// Similar to "send" but does not shutdown the channel if an error occurs.
1645    pub fn send_no_shutdown_on_err(self, mut desc: &[u8]) -> Result<(), fidl::Error> {
1646        let _result = self.send_raw(desc);
1647        self.drop_without_shutdown();
1648        _result
1649    }
1650
1651    fn send_raw(&self, mut desc: &[u8]) -> Result<(), fidl::Error> {
1652        self.control_handle.inner.send::<DeviceGetReportDescResponse>(
1653            (desc,),
1654            self.tx_id,
1655            0x7fe4aff57d9019f8,
1656            fidl::encoding::DynamicFlags::empty(),
1657        )
1658    }
1659}
1660
1661#[must_use = "FIDL methods require a response to be sent"]
1662#[derive(Debug)]
1663pub struct DeviceGetDeviceReportsReaderResponder {
1664    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1665    tx_id: u32,
1666}
1667
1668/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1669/// if the responder is dropped without sending a response, so that the client
1670/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1671impl std::ops::Drop for DeviceGetDeviceReportsReaderResponder {
1672    fn drop(&mut self) {
1673        self.control_handle.shutdown();
1674        // Safety: drops once, never accessed again
1675        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1676    }
1677}
1678
1679impl fidl::endpoints::Responder for DeviceGetDeviceReportsReaderResponder {
1680    type ControlHandle = DeviceControlHandle;
1681
1682    fn control_handle(&self) -> &DeviceControlHandle {
1683        &self.control_handle
1684    }
1685
1686    fn drop_without_shutdown(mut self) {
1687        // Safety: drops once, never accessed again due to mem::forget
1688        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1689        // Prevent Drop from running (which would shut down the channel)
1690        std::mem::forget(self);
1691    }
1692}
1693
1694impl DeviceGetDeviceReportsReaderResponder {
1695    /// Sends a response to the FIDL transaction.
1696    ///
1697    /// Sets the channel to shutdown if an error occurs.
1698    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1699        let _result = self.send_raw(result);
1700        if _result.is_err() {
1701            self.control_handle.shutdown();
1702        }
1703        self.drop_without_shutdown();
1704        _result
1705    }
1706
1707    /// Similar to "send" but does not shutdown the channel if an error occurs.
1708    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1709        let _result = self.send_raw(result);
1710        self.drop_without_shutdown();
1711        _result
1712    }
1713
1714    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1715        self.control_handle
1716            .inner
1717            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1718                result,
1719                self.tx_id,
1720                0x67aee4993bb823ee,
1721                fidl::encoding::DynamicFlags::empty(),
1722            )
1723    }
1724}
1725
1726#[must_use = "FIDL methods require a response to be sent"]
1727#[derive(Debug)]
1728pub struct DeviceReadReportResponder {
1729    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1730    tx_id: u32,
1731}
1732
1733/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1734/// if the responder is dropped without sending a response, so that the client
1735/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1736impl std::ops::Drop for DeviceReadReportResponder {
1737    fn drop(&mut self) {
1738        self.control_handle.shutdown();
1739        // Safety: drops once, never accessed again
1740        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1741    }
1742}
1743
1744impl fidl::endpoints::Responder for DeviceReadReportResponder {
1745    type ControlHandle = DeviceControlHandle;
1746
1747    fn control_handle(&self) -> &DeviceControlHandle {
1748        &self.control_handle
1749    }
1750
1751    fn drop_without_shutdown(mut self) {
1752        // Safety: drops once, never accessed again due to mem::forget
1753        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1754        // Prevent Drop from running (which would shut down the channel)
1755        std::mem::forget(self);
1756    }
1757}
1758
1759impl DeviceReadReportResponder {
1760    /// Sends a response to the FIDL transaction.
1761    ///
1762    /// Sets the channel to shutdown if an error occurs.
1763    pub fn send(
1764        self,
1765        mut result: Result<fidl_fuchsia_hardware_hidbus::Report, i32>,
1766    ) -> Result<(), fidl::Error> {
1767        let _result = self.send_raw(result);
1768        if _result.is_err() {
1769            self.control_handle.shutdown();
1770        }
1771        self.drop_without_shutdown();
1772        _result
1773    }
1774
1775    /// Similar to "send" but does not shutdown the channel if an error occurs.
1776    pub fn send_no_shutdown_on_err(
1777        self,
1778        mut result: Result<fidl_fuchsia_hardware_hidbus::Report, i32>,
1779    ) -> Result<(), fidl::Error> {
1780        let _result = self.send_raw(result);
1781        self.drop_without_shutdown();
1782        _result
1783    }
1784
1785    fn send_raw(
1786        &self,
1787        mut result: Result<fidl_fuchsia_hardware_hidbus::Report, i32>,
1788    ) -> Result<(), fidl::Error> {
1789        self.control_handle.inner.send::<fidl::encoding::ResultType<
1790            fidl_fuchsia_hardware_hidbus::Report,
1791            i32,
1792        >>(
1793            result.as_mut().map_err(|e| *e),
1794            self.tx_id,
1795            0x69871e1e2b75e46f,
1796            fidl::encoding::DynamicFlags::empty(),
1797        )
1798    }
1799}
1800
1801#[must_use = "FIDL methods require a response to be sent"]
1802#[derive(Debug)]
1803pub struct DeviceReadReportsResponder {
1804    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1805    tx_id: u32,
1806}
1807
1808/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1809/// if the responder is dropped without sending a response, so that the client
1810/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1811impl std::ops::Drop for DeviceReadReportsResponder {
1812    fn drop(&mut self) {
1813        self.control_handle.shutdown();
1814        // Safety: drops once, never accessed again
1815        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1816    }
1817}
1818
1819impl fidl::endpoints::Responder for DeviceReadReportsResponder {
1820    type ControlHandle = DeviceControlHandle;
1821
1822    fn control_handle(&self) -> &DeviceControlHandle {
1823        &self.control_handle
1824    }
1825
1826    fn drop_without_shutdown(mut self) {
1827        // Safety: drops once, never accessed again due to mem::forget
1828        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1829        // Prevent Drop from running (which would shut down the channel)
1830        std::mem::forget(self);
1831    }
1832}
1833
1834impl DeviceReadReportsResponder {
1835    /// Sends a response to the FIDL transaction.
1836    ///
1837    /// Sets the channel to shutdown if an error occurs.
1838    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1839        let _result = self.send_raw(result);
1840        if _result.is_err() {
1841            self.control_handle.shutdown();
1842        }
1843        self.drop_without_shutdown();
1844        _result
1845    }
1846
1847    /// Similar to "send" but does not shutdown the channel if an error occurs.
1848    pub fn send_no_shutdown_on_err(
1849        self,
1850        mut result: Result<&[u8], i32>,
1851    ) -> Result<(), fidl::Error> {
1852        let _result = self.send_raw(result);
1853        self.drop_without_shutdown();
1854        _result
1855    }
1856
1857    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1858        self.control_handle
1859            .inner
1860            .send::<fidl::encoding::ResultType<DeviceReadReportsResponse, i32>>(
1861                result.map(|data| (data,)),
1862                self.tx_id,
1863                0x6e20cf64707a4ee4,
1864                fidl::encoding::DynamicFlags::empty(),
1865            )
1866    }
1867}
1868
1869#[must_use = "FIDL methods require a response to be sent"]
1870#[derive(Debug)]
1871pub struct DeviceGetReportsEventResponder {
1872    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1873    tx_id: u32,
1874}
1875
1876/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1877/// if the responder is dropped without sending a response, so that the client
1878/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1879impl std::ops::Drop for DeviceGetReportsEventResponder {
1880    fn drop(&mut self) {
1881        self.control_handle.shutdown();
1882        // Safety: drops once, never accessed again
1883        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1884    }
1885}
1886
1887impl fidl::endpoints::Responder for DeviceGetReportsEventResponder {
1888    type ControlHandle = DeviceControlHandle;
1889
1890    fn control_handle(&self) -> &DeviceControlHandle {
1891        &self.control_handle
1892    }
1893
1894    fn drop_without_shutdown(mut self) {
1895        // Safety: drops once, never accessed again due to mem::forget
1896        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1897        // Prevent Drop from running (which would shut down the channel)
1898        std::mem::forget(self);
1899    }
1900}
1901
1902impl DeviceGetReportsEventResponder {
1903    /// Sends a response to the FIDL transaction.
1904    ///
1905    /// Sets the channel to shutdown if an error occurs.
1906    pub fn send(self, mut result: Result<fidl::Event, i32>) -> Result<(), fidl::Error> {
1907        let _result = self.send_raw(result);
1908        if _result.is_err() {
1909            self.control_handle.shutdown();
1910        }
1911        self.drop_without_shutdown();
1912        _result
1913    }
1914
1915    /// Similar to "send" but does not shutdown the channel if an error occurs.
1916    pub fn send_no_shutdown_on_err(
1917        self,
1918        mut result: Result<fidl::Event, i32>,
1919    ) -> Result<(), fidl::Error> {
1920        let _result = self.send_raw(result);
1921        self.drop_without_shutdown();
1922        _result
1923    }
1924
1925    fn send_raw(&self, mut result: Result<fidl::Event, i32>) -> Result<(), fidl::Error> {
1926        self.control_handle
1927            .inner
1928            .send::<fidl::encoding::ResultType<DeviceGetReportsEventResponse, i32>>(
1929                result.map(|event| (event,)),
1930                self.tx_id,
1931                0x6198970f9308041c,
1932                fidl::encoding::DynamicFlags::empty(),
1933            )
1934    }
1935}
1936
1937#[must_use = "FIDL methods require a response to be sent"]
1938#[derive(Debug)]
1939pub struct DeviceGetReportResponder {
1940    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1941    tx_id: u32,
1942}
1943
1944/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1945/// if the responder is dropped without sending a response, so that the client
1946/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1947impl std::ops::Drop for DeviceGetReportResponder {
1948    fn drop(&mut self) {
1949        self.control_handle.shutdown();
1950        // Safety: drops once, never accessed again
1951        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1952    }
1953}
1954
1955impl fidl::endpoints::Responder for DeviceGetReportResponder {
1956    type ControlHandle = DeviceControlHandle;
1957
1958    fn control_handle(&self) -> &DeviceControlHandle {
1959        &self.control_handle
1960    }
1961
1962    fn drop_without_shutdown(mut self) {
1963        // Safety: drops once, never accessed again due to mem::forget
1964        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1965        // Prevent Drop from running (which would shut down the channel)
1966        std::mem::forget(self);
1967    }
1968}
1969
1970impl DeviceGetReportResponder {
1971    /// Sends a response to the FIDL transaction.
1972    ///
1973    /// Sets the channel to shutdown if an error occurs.
1974    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1975        let _result = self.send_raw(result);
1976        if _result.is_err() {
1977            self.control_handle.shutdown();
1978        }
1979        self.drop_without_shutdown();
1980        _result
1981    }
1982
1983    /// Similar to "send" but does not shutdown the channel if an error occurs.
1984    pub fn send_no_shutdown_on_err(
1985        self,
1986        mut result: Result<&[u8], i32>,
1987    ) -> Result<(), fidl::Error> {
1988        let _result = self.send_raw(result);
1989        self.drop_without_shutdown();
1990        _result
1991    }
1992
1993    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1994        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceGetReportResponse, i32>>(
1995            result.map(|report| (report,)),
1996            self.tx_id,
1997            0x5b2a44555defd970,
1998            fidl::encoding::DynamicFlags::empty(),
1999        )
2000    }
2001}
2002
2003#[must_use = "FIDL methods require a response to be sent"]
2004#[derive(Debug)]
2005pub struct DeviceSetReportResponder {
2006    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2007    tx_id: u32,
2008}
2009
2010/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2011/// if the responder is dropped without sending a response, so that the client
2012/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2013impl std::ops::Drop for DeviceSetReportResponder {
2014    fn drop(&mut self) {
2015        self.control_handle.shutdown();
2016        // Safety: drops once, never accessed again
2017        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2018    }
2019}
2020
2021impl fidl::endpoints::Responder for DeviceSetReportResponder {
2022    type ControlHandle = DeviceControlHandle;
2023
2024    fn control_handle(&self) -> &DeviceControlHandle {
2025        &self.control_handle
2026    }
2027
2028    fn drop_without_shutdown(mut self) {
2029        // Safety: drops once, never accessed again due to mem::forget
2030        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2031        // Prevent Drop from running (which would shut down the channel)
2032        std::mem::forget(self);
2033    }
2034}
2035
2036impl DeviceSetReportResponder {
2037    /// Sends a response to the FIDL transaction.
2038    ///
2039    /// Sets the channel to shutdown if an error occurs.
2040    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2041        let _result = self.send_raw(result);
2042        if _result.is_err() {
2043            self.control_handle.shutdown();
2044        }
2045        self.drop_without_shutdown();
2046        _result
2047    }
2048
2049    /// Similar to "send" but does not shutdown the channel if an error occurs.
2050    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2051        let _result = self.send_raw(result);
2052        self.drop_without_shutdown();
2053        _result
2054    }
2055
2056    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2057        self.control_handle
2058            .inner
2059            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2060                result,
2061                self.tx_id,
2062                0x51cc85eb4e769ee,
2063                fidl::encoding::DynamicFlags::empty(),
2064            )
2065    }
2066}
2067
2068#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2069pub struct DeviceReportsReaderMarker;
2070
2071impl fidl::endpoints::ProtocolMarker for DeviceReportsReaderMarker {
2072    type Proxy = DeviceReportsReaderProxy;
2073    type RequestStream = DeviceReportsReaderRequestStream;
2074    #[cfg(target_os = "fuchsia")]
2075    type SynchronousProxy = DeviceReportsReaderSynchronousProxy;
2076
2077    const DEBUG_NAME: &'static str = "(anonymous) DeviceReportsReader";
2078}
2079pub type DeviceReportsReaderReadReportsResult =
2080    Result<Vec<fidl_fuchsia_hardware_hidbus::Report>, i32>;
2081
2082pub trait DeviceReportsReaderProxyInterface: Send + Sync {
2083    type ReadReportsResponseFut: std::future::Future<Output = Result<DeviceReportsReaderReadReportsResult, fidl::Error>>
2084        + Send;
2085    fn r#read_reports(&self) -> Self::ReadReportsResponseFut;
2086}
2087#[derive(Debug)]
2088#[cfg(target_os = "fuchsia")]
2089pub struct DeviceReportsReaderSynchronousProxy {
2090    client: fidl::client::sync::Client,
2091}
2092
2093#[cfg(target_os = "fuchsia")]
2094impl fidl::endpoints::SynchronousProxy for DeviceReportsReaderSynchronousProxy {
2095    type Proxy = DeviceReportsReaderProxy;
2096    type Protocol = DeviceReportsReaderMarker;
2097
2098    fn from_channel(inner: fidl::Channel) -> Self {
2099        Self::new(inner)
2100    }
2101
2102    fn into_channel(self) -> fidl::Channel {
2103        self.client.into_channel()
2104    }
2105
2106    fn as_channel(&self) -> &fidl::Channel {
2107        self.client.as_channel()
2108    }
2109}
2110
2111#[cfg(target_os = "fuchsia")]
2112impl DeviceReportsReaderSynchronousProxy {
2113    pub fn new(channel: fidl::Channel) -> Self {
2114        let protocol_name =
2115            <DeviceReportsReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2116        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2117    }
2118
2119    pub fn into_channel(self) -> fidl::Channel {
2120        self.client.into_channel()
2121    }
2122
2123    /// Waits until an event arrives and returns it. It is safe for other
2124    /// threads to make concurrent requests while waiting for an event.
2125    pub fn wait_for_event(
2126        &self,
2127        deadline: zx::MonotonicInstant,
2128    ) -> Result<DeviceReportsReaderEvent, fidl::Error> {
2129        DeviceReportsReaderEvent::decode(self.client.wait_for_event(deadline)?)
2130    }
2131
2132    /// This is a Hanging-Get function to read the reports in the Report FIFO.
2133    /// This will block until there is at least one report available.
2134    /// If there is already one outstanding Hanging-Get, calling this again will
2135    /// return ZX_ERR_ALREADY_BOUND.
2136    pub fn r#read_reports(
2137        &self,
2138        ___deadline: zx::MonotonicInstant,
2139    ) -> Result<DeviceReportsReaderReadReportsResult, fidl::Error> {
2140        let _response = self.client.send_query::<
2141            fidl::encoding::EmptyPayload,
2142            fidl::encoding::ResultType<DeviceReportsReaderReadReportsResponse, i32>,
2143        >(
2144            (),
2145            0x36077c1b177d4291,
2146            fidl::encoding::DynamicFlags::empty(),
2147            ___deadline,
2148        )?;
2149        Ok(_response.map(|x| x.reports))
2150    }
2151}
2152
2153#[cfg(target_os = "fuchsia")]
2154impl From<DeviceReportsReaderSynchronousProxy> for zx::Handle {
2155    fn from(value: DeviceReportsReaderSynchronousProxy) -> Self {
2156        value.into_channel().into()
2157    }
2158}
2159
2160#[cfg(target_os = "fuchsia")]
2161impl From<fidl::Channel> for DeviceReportsReaderSynchronousProxy {
2162    fn from(value: fidl::Channel) -> Self {
2163        Self::new(value)
2164    }
2165}
2166
2167#[cfg(target_os = "fuchsia")]
2168impl fidl::endpoints::FromClient for DeviceReportsReaderSynchronousProxy {
2169    type Protocol = DeviceReportsReaderMarker;
2170
2171    fn from_client(value: fidl::endpoints::ClientEnd<DeviceReportsReaderMarker>) -> Self {
2172        Self::new(value.into_channel())
2173    }
2174}
2175
2176#[derive(Debug, Clone)]
2177pub struct DeviceReportsReaderProxy {
2178    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2179}
2180
2181impl fidl::endpoints::Proxy for DeviceReportsReaderProxy {
2182    type Protocol = DeviceReportsReaderMarker;
2183
2184    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2185        Self::new(inner)
2186    }
2187
2188    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2189        self.client.into_channel().map_err(|client| Self { client })
2190    }
2191
2192    fn as_channel(&self) -> &::fidl::AsyncChannel {
2193        self.client.as_channel()
2194    }
2195}
2196
2197impl DeviceReportsReaderProxy {
2198    /// Create a new Proxy for fuchsia.hardware.input/DeviceReportsReader.
2199    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2200        let protocol_name =
2201            <DeviceReportsReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2202        Self { client: fidl::client::Client::new(channel, protocol_name) }
2203    }
2204
2205    /// Get a Stream of events from the remote end of the protocol.
2206    ///
2207    /// # Panics
2208    ///
2209    /// Panics if the event stream was already taken.
2210    pub fn take_event_stream(&self) -> DeviceReportsReaderEventStream {
2211        DeviceReportsReaderEventStream { event_receiver: self.client.take_event_receiver() }
2212    }
2213
2214    /// This is a Hanging-Get function to read the reports in the Report FIFO.
2215    /// This will block until there is at least one report available.
2216    /// If there is already one outstanding Hanging-Get, calling this again will
2217    /// return ZX_ERR_ALREADY_BOUND.
2218    pub fn r#read_reports(
2219        &self,
2220    ) -> fidl::client::QueryResponseFut<
2221        DeviceReportsReaderReadReportsResult,
2222        fidl::encoding::DefaultFuchsiaResourceDialect,
2223    > {
2224        DeviceReportsReaderProxyInterface::r#read_reports(self)
2225    }
2226}
2227
2228impl DeviceReportsReaderProxyInterface for DeviceReportsReaderProxy {
2229    type ReadReportsResponseFut = fidl::client::QueryResponseFut<
2230        DeviceReportsReaderReadReportsResult,
2231        fidl::encoding::DefaultFuchsiaResourceDialect,
2232    >;
2233    fn r#read_reports(&self) -> Self::ReadReportsResponseFut {
2234        fn _decode(
2235            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2236        ) -> Result<DeviceReportsReaderReadReportsResult, fidl::Error> {
2237            let _response = fidl::client::decode_transaction_body::<
2238                fidl::encoding::ResultType<DeviceReportsReaderReadReportsResponse, i32>,
2239                fidl::encoding::DefaultFuchsiaResourceDialect,
2240                0x36077c1b177d4291,
2241            >(_buf?)?;
2242            Ok(_response.map(|x| x.reports))
2243        }
2244        self.client.send_query_and_decode::<
2245            fidl::encoding::EmptyPayload,
2246            DeviceReportsReaderReadReportsResult,
2247        >(
2248            (),
2249            0x36077c1b177d4291,
2250            fidl::encoding::DynamicFlags::empty(),
2251            _decode,
2252        )
2253    }
2254}
2255
2256pub struct DeviceReportsReaderEventStream {
2257    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2258}
2259
2260impl std::marker::Unpin for DeviceReportsReaderEventStream {}
2261
2262impl futures::stream::FusedStream for DeviceReportsReaderEventStream {
2263    fn is_terminated(&self) -> bool {
2264        self.event_receiver.is_terminated()
2265    }
2266}
2267
2268impl futures::Stream for DeviceReportsReaderEventStream {
2269    type Item = Result<DeviceReportsReaderEvent, fidl::Error>;
2270
2271    fn poll_next(
2272        mut self: std::pin::Pin<&mut Self>,
2273        cx: &mut std::task::Context<'_>,
2274    ) -> std::task::Poll<Option<Self::Item>> {
2275        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2276            &mut self.event_receiver,
2277            cx
2278        )?) {
2279            Some(buf) => std::task::Poll::Ready(Some(DeviceReportsReaderEvent::decode(buf))),
2280            None => std::task::Poll::Ready(None),
2281        }
2282    }
2283}
2284
2285#[derive(Debug)]
2286pub enum DeviceReportsReaderEvent {}
2287
2288impl DeviceReportsReaderEvent {
2289    /// Decodes a message buffer as a [`DeviceReportsReaderEvent`].
2290    fn decode(
2291        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2292    ) -> Result<DeviceReportsReaderEvent, fidl::Error> {
2293        let (bytes, _handles) = buf.split_mut();
2294        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2295        debug_assert_eq!(tx_header.tx_id, 0);
2296        match tx_header.ordinal {
2297            _ => Err(fidl::Error::UnknownOrdinal {
2298                ordinal: tx_header.ordinal,
2299                protocol_name:
2300                    <DeviceReportsReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2301            }),
2302        }
2303    }
2304}
2305
2306/// A Stream of incoming requests for fuchsia.hardware.input/DeviceReportsReader.
2307pub struct DeviceReportsReaderRequestStream {
2308    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2309    is_terminated: bool,
2310}
2311
2312impl std::marker::Unpin for DeviceReportsReaderRequestStream {}
2313
2314impl futures::stream::FusedStream for DeviceReportsReaderRequestStream {
2315    fn is_terminated(&self) -> bool {
2316        self.is_terminated
2317    }
2318}
2319
2320impl fidl::endpoints::RequestStream for DeviceReportsReaderRequestStream {
2321    type Protocol = DeviceReportsReaderMarker;
2322    type ControlHandle = DeviceReportsReaderControlHandle;
2323
2324    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2325        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2326    }
2327
2328    fn control_handle(&self) -> Self::ControlHandle {
2329        DeviceReportsReaderControlHandle { inner: self.inner.clone() }
2330    }
2331
2332    fn into_inner(
2333        self,
2334    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2335    {
2336        (self.inner, self.is_terminated)
2337    }
2338
2339    fn from_inner(
2340        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2341        is_terminated: bool,
2342    ) -> Self {
2343        Self { inner, is_terminated }
2344    }
2345}
2346
2347impl futures::Stream for DeviceReportsReaderRequestStream {
2348    type Item = Result<DeviceReportsReaderRequest, fidl::Error>;
2349
2350    fn poll_next(
2351        mut self: std::pin::Pin<&mut Self>,
2352        cx: &mut std::task::Context<'_>,
2353    ) -> std::task::Poll<Option<Self::Item>> {
2354        let this = &mut *self;
2355        if this.inner.check_shutdown(cx) {
2356            this.is_terminated = true;
2357            return std::task::Poll::Ready(None);
2358        }
2359        if this.is_terminated {
2360            panic!("polled DeviceReportsReaderRequestStream after completion");
2361        }
2362        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2363            |bytes, handles| {
2364                match this.inner.channel().read_etc(cx, bytes, handles) {
2365                    std::task::Poll::Ready(Ok(())) => {}
2366                    std::task::Poll::Pending => return std::task::Poll::Pending,
2367                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2368                        this.is_terminated = true;
2369                        return std::task::Poll::Ready(None);
2370                    }
2371                    std::task::Poll::Ready(Err(e)) => {
2372                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2373                            e.into(),
2374                        ))))
2375                    }
2376                }
2377
2378                // A message has been received from the channel
2379                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2380
2381                std::task::Poll::Ready(Some(match header.ordinal {
2382                0x36077c1b177d4291 => {
2383                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2384                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
2385                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2386                    let control_handle = DeviceReportsReaderControlHandle {
2387                        inner: this.inner.clone(),
2388                    };
2389                    Ok(DeviceReportsReaderRequest::ReadReports {
2390                        responder: DeviceReportsReaderReadReportsResponder {
2391                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2392                            tx_id: header.tx_id,
2393                        },
2394                    })
2395                }
2396                _ => Err(fidl::Error::UnknownOrdinal {
2397                    ordinal: header.ordinal,
2398                    protocol_name: <DeviceReportsReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2399                }),
2400            }))
2401            },
2402        )
2403    }
2404}
2405
2406/// Each `DeviceReportsReader` has its own FIFO of reports in the driver.
2407/// Calling `ReadReports` drains the Report FIFO. If the Report FIFO fills up
2408/// between calls to `ReadReports` the channel will be closed.
2409#[derive(Debug)]
2410pub enum DeviceReportsReaderRequest {
2411    /// This is a Hanging-Get function to read the reports in the Report FIFO.
2412    /// This will block until there is at least one report available.
2413    /// If there is already one outstanding Hanging-Get, calling this again will
2414    /// return ZX_ERR_ALREADY_BOUND.
2415    ReadReports { responder: DeviceReportsReaderReadReportsResponder },
2416}
2417
2418impl DeviceReportsReaderRequest {
2419    #[allow(irrefutable_let_patterns)]
2420    pub fn into_read_reports(self) -> Option<(DeviceReportsReaderReadReportsResponder)> {
2421        if let DeviceReportsReaderRequest::ReadReports { responder } = self {
2422            Some((responder))
2423        } else {
2424            None
2425        }
2426    }
2427
2428    /// Name of the method defined in FIDL
2429    pub fn method_name(&self) -> &'static str {
2430        match *self {
2431            DeviceReportsReaderRequest::ReadReports { .. } => "read_reports",
2432        }
2433    }
2434}
2435
2436#[derive(Debug, Clone)]
2437pub struct DeviceReportsReaderControlHandle {
2438    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2439}
2440
2441impl fidl::endpoints::ControlHandle for DeviceReportsReaderControlHandle {
2442    fn shutdown(&self) {
2443        self.inner.shutdown()
2444    }
2445    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2446        self.inner.shutdown_with_epitaph(status)
2447    }
2448
2449    fn is_closed(&self) -> bool {
2450        self.inner.channel().is_closed()
2451    }
2452    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2453        self.inner.channel().on_closed()
2454    }
2455
2456    #[cfg(target_os = "fuchsia")]
2457    fn signal_peer(
2458        &self,
2459        clear_mask: zx::Signals,
2460        set_mask: zx::Signals,
2461    ) -> Result<(), zx_status::Status> {
2462        use fidl::Peered;
2463        self.inner.channel().signal_peer(clear_mask, set_mask)
2464    }
2465}
2466
2467impl DeviceReportsReaderControlHandle {}
2468
2469#[must_use = "FIDL methods require a response to be sent"]
2470#[derive(Debug)]
2471pub struct DeviceReportsReaderReadReportsResponder {
2472    control_handle: std::mem::ManuallyDrop<DeviceReportsReaderControlHandle>,
2473    tx_id: u32,
2474}
2475
2476/// Set the the channel to be shutdown (see [`DeviceReportsReaderControlHandle::shutdown`])
2477/// if the responder is dropped without sending a response, so that the client
2478/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2479impl std::ops::Drop for DeviceReportsReaderReadReportsResponder {
2480    fn drop(&mut self) {
2481        self.control_handle.shutdown();
2482        // Safety: drops once, never accessed again
2483        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2484    }
2485}
2486
2487impl fidl::endpoints::Responder for DeviceReportsReaderReadReportsResponder {
2488    type ControlHandle = DeviceReportsReaderControlHandle;
2489
2490    fn control_handle(&self) -> &DeviceReportsReaderControlHandle {
2491        &self.control_handle
2492    }
2493
2494    fn drop_without_shutdown(mut self) {
2495        // Safety: drops once, never accessed again due to mem::forget
2496        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2497        // Prevent Drop from running (which would shut down the channel)
2498        std::mem::forget(self);
2499    }
2500}
2501
2502impl DeviceReportsReaderReadReportsResponder {
2503    /// Sends a response to the FIDL transaction.
2504    ///
2505    /// Sets the channel to shutdown if an error occurs.
2506    pub fn send(
2507        self,
2508        mut result: Result<Vec<fidl_fuchsia_hardware_hidbus::Report>, i32>,
2509    ) -> Result<(), fidl::Error> {
2510        let _result = self.send_raw(result);
2511        if _result.is_err() {
2512            self.control_handle.shutdown();
2513        }
2514        self.drop_without_shutdown();
2515        _result
2516    }
2517
2518    /// Similar to "send" but does not shutdown the channel if an error occurs.
2519    pub fn send_no_shutdown_on_err(
2520        self,
2521        mut result: Result<Vec<fidl_fuchsia_hardware_hidbus::Report>, i32>,
2522    ) -> Result<(), fidl::Error> {
2523        let _result = self.send_raw(result);
2524        self.drop_without_shutdown();
2525        _result
2526    }
2527
2528    fn send_raw(
2529        &self,
2530        mut result: Result<Vec<fidl_fuchsia_hardware_hidbus::Report>, i32>,
2531    ) -> Result<(), fidl::Error> {
2532        self.control_handle.inner.send::<fidl::encoding::ResultType<
2533            DeviceReportsReaderReadReportsResponse,
2534            i32,
2535        >>(
2536            result.as_mut().map_err(|e| *e).map(|reports| (reports.as_mut_slice(),)),
2537            self.tx_id,
2538            0x36077c1b177d4291,
2539            fidl::encoding::DynamicFlags::empty(),
2540        )
2541    }
2542}
2543
2544#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2545pub struct ServiceMarker;
2546
2547#[cfg(target_os = "fuchsia")]
2548impl fidl::endpoints::ServiceMarker for ServiceMarker {
2549    type Proxy = ServiceProxy;
2550    type Request = ServiceRequest;
2551    const SERVICE_NAME: &'static str = "fuchsia.hardware.input.Service";
2552}
2553
2554/// A request for one of the member protocols of Service.
2555///
2556#[cfg(target_os = "fuchsia")]
2557pub enum ServiceRequest {
2558    Controller(ControllerRequestStream),
2559}
2560
2561#[cfg(target_os = "fuchsia")]
2562impl fidl::endpoints::ServiceRequest for ServiceRequest {
2563    type Service = ServiceMarker;
2564
2565    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2566        match name {
2567            "controller" => Self::Controller(
2568                <ControllerRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2569            ),
2570            _ => panic!("no such member protocol name for service Service"),
2571        }
2572    }
2573
2574    fn member_names() -> &'static [&'static str] {
2575        &["controller"]
2576    }
2577}
2578#[cfg(target_os = "fuchsia")]
2579pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2580
2581#[cfg(target_os = "fuchsia")]
2582impl fidl::endpoints::ServiceProxy for ServiceProxy {
2583    type Service = ServiceMarker;
2584
2585    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2586        Self(opener)
2587    }
2588}
2589
2590#[cfg(target_os = "fuchsia")]
2591impl ServiceProxy {
2592    pub fn connect_to_controller(&self) -> Result<ControllerProxy, fidl::Error> {
2593        let (proxy, server_end) = fidl::endpoints::create_proxy::<ControllerMarker>();
2594        self.connect_channel_to_controller(server_end)?;
2595        Ok(proxy)
2596    }
2597
2598    /// Like `connect_to_controller`, but returns a sync proxy.
2599    /// See [`Self::connect_to_controller`] for more details.
2600    pub fn connect_to_controller_sync(&self) -> Result<ControllerSynchronousProxy, fidl::Error> {
2601        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ControllerMarker>();
2602        self.connect_channel_to_controller(server_end)?;
2603        Ok(proxy)
2604    }
2605
2606    /// Like `connect_to_controller`, but accepts a server end.
2607    /// See [`Self::connect_to_controller`] for more details.
2608    pub fn connect_channel_to_controller(
2609        &self,
2610        server_end: fidl::endpoints::ServerEnd<ControllerMarker>,
2611    ) -> Result<(), fidl::Error> {
2612        self.0.open_member("controller", server_end.into_channel())
2613    }
2614
2615    pub fn instance_name(&self) -> &str {
2616        self.0.instance_name()
2617    }
2618}
2619
2620mod internal {
2621    use super::*;
2622
2623    impl fidl::encoding::ResourceTypeMarker for ControllerOpenSessionRequest {
2624        type Borrowed<'a> = &'a mut Self;
2625        fn take_or_borrow<'a>(
2626            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2627        ) -> Self::Borrowed<'a> {
2628            value
2629        }
2630    }
2631
2632    unsafe impl fidl::encoding::TypeMarker for ControllerOpenSessionRequest {
2633        type Owned = Self;
2634
2635        #[inline(always)]
2636        fn inline_align(_context: fidl::encoding::Context) -> usize {
2637            4
2638        }
2639
2640        #[inline(always)]
2641        fn inline_size(_context: fidl::encoding::Context) -> usize {
2642            4
2643        }
2644    }
2645
2646    unsafe impl
2647        fidl::encoding::Encode<
2648            ControllerOpenSessionRequest,
2649            fidl::encoding::DefaultFuchsiaResourceDialect,
2650        > for &mut ControllerOpenSessionRequest
2651    {
2652        #[inline]
2653        unsafe fn encode(
2654            self,
2655            encoder: &mut fidl::encoding::Encoder<
2656                '_,
2657                fidl::encoding::DefaultFuchsiaResourceDialect,
2658            >,
2659            offset: usize,
2660            _depth: fidl::encoding::Depth,
2661        ) -> fidl::Result<()> {
2662            encoder.debug_check_bounds::<ControllerOpenSessionRequest>(offset);
2663            // Delegate to tuple encoding.
2664            fidl::encoding::Encode::<ControllerOpenSessionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2665                (
2666                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
2667                ),
2668                encoder, offset, _depth
2669            )
2670        }
2671    }
2672    unsafe impl<
2673            T0: fidl::encoding::Encode<
2674                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2675                fidl::encoding::DefaultFuchsiaResourceDialect,
2676            >,
2677        >
2678        fidl::encoding::Encode<
2679            ControllerOpenSessionRequest,
2680            fidl::encoding::DefaultFuchsiaResourceDialect,
2681        > for (T0,)
2682    {
2683        #[inline]
2684        unsafe fn encode(
2685            self,
2686            encoder: &mut fidl::encoding::Encoder<
2687                '_,
2688                fidl::encoding::DefaultFuchsiaResourceDialect,
2689            >,
2690            offset: usize,
2691            depth: fidl::encoding::Depth,
2692        ) -> fidl::Result<()> {
2693            encoder.debug_check_bounds::<ControllerOpenSessionRequest>(offset);
2694            // Zero out padding regions. There's no need to apply masks
2695            // because the unmasked parts will be overwritten by fields.
2696            // Write the fields.
2697            self.0.encode(encoder, offset + 0, depth)?;
2698            Ok(())
2699        }
2700    }
2701
2702    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2703        for ControllerOpenSessionRequest
2704    {
2705        #[inline(always)]
2706        fn new_empty() -> Self {
2707            Self {
2708                session: fidl::new_empty!(
2709                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2710                    fidl::encoding::DefaultFuchsiaResourceDialect
2711                ),
2712            }
2713        }
2714
2715        #[inline]
2716        unsafe fn decode(
2717            &mut self,
2718            decoder: &mut fidl::encoding::Decoder<
2719                '_,
2720                fidl::encoding::DefaultFuchsiaResourceDialect,
2721            >,
2722            offset: usize,
2723            _depth: fidl::encoding::Depth,
2724        ) -> fidl::Result<()> {
2725            decoder.debug_check_bounds::<Self>(offset);
2726            // Verify that padding bytes are zero.
2727            fidl::decode!(
2728                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2729                fidl::encoding::DefaultFuchsiaResourceDialect,
2730                &mut self.session,
2731                decoder,
2732                offset + 0,
2733                _depth
2734            )?;
2735            Ok(())
2736        }
2737    }
2738
2739    impl fidl::encoding::ResourceTypeMarker for DeviceGetDeviceReportsReaderRequest {
2740        type Borrowed<'a> = &'a mut Self;
2741        fn take_or_borrow<'a>(
2742            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2743        ) -> Self::Borrowed<'a> {
2744            value
2745        }
2746    }
2747
2748    unsafe impl fidl::encoding::TypeMarker for DeviceGetDeviceReportsReaderRequest {
2749        type Owned = Self;
2750
2751        #[inline(always)]
2752        fn inline_align(_context: fidl::encoding::Context) -> usize {
2753            4
2754        }
2755
2756        #[inline(always)]
2757        fn inline_size(_context: fidl::encoding::Context) -> usize {
2758            4
2759        }
2760    }
2761
2762    unsafe impl
2763        fidl::encoding::Encode<
2764            DeviceGetDeviceReportsReaderRequest,
2765            fidl::encoding::DefaultFuchsiaResourceDialect,
2766        > for &mut DeviceGetDeviceReportsReaderRequest
2767    {
2768        #[inline]
2769        unsafe fn encode(
2770            self,
2771            encoder: &mut fidl::encoding::Encoder<
2772                '_,
2773                fidl::encoding::DefaultFuchsiaResourceDialect,
2774            >,
2775            offset: usize,
2776            _depth: fidl::encoding::Depth,
2777        ) -> fidl::Result<()> {
2778            encoder.debug_check_bounds::<DeviceGetDeviceReportsReaderRequest>(offset);
2779            // Delegate to tuple encoding.
2780            fidl::encoding::Encode::<DeviceGetDeviceReportsReaderRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2781                (
2782                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.reader),
2783                ),
2784                encoder, offset, _depth
2785            )
2786        }
2787    }
2788    unsafe impl<
2789            T0: fidl::encoding::Encode<
2790                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>>,
2791                fidl::encoding::DefaultFuchsiaResourceDialect,
2792            >,
2793        >
2794        fidl::encoding::Encode<
2795            DeviceGetDeviceReportsReaderRequest,
2796            fidl::encoding::DefaultFuchsiaResourceDialect,
2797        > for (T0,)
2798    {
2799        #[inline]
2800        unsafe fn encode(
2801            self,
2802            encoder: &mut fidl::encoding::Encoder<
2803                '_,
2804                fidl::encoding::DefaultFuchsiaResourceDialect,
2805            >,
2806            offset: usize,
2807            depth: fidl::encoding::Depth,
2808        ) -> fidl::Result<()> {
2809            encoder.debug_check_bounds::<DeviceGetDeviceReportsReaderRequest>(offset);
2810            // Zero out padding regions. There's no need to apply masks
2811            // because the unmasked parts will be overwritten by fields.
2812            // Write the fields.
2813            self.0.encode(encoder, offset + 0, depth)?;
2814            Ok(())
2815        }
2816    }
2817
2818    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2819        for DeviceGetDeviceReportsReaderRequest
2820    {
2821        #[inline(always)]
2822        fn new_empty() -> Self {
2823            Self {
2824                reader: fidl::new_empty!(
2825                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>>,
2826                    fidl::encoding::DefaultFuchsiaResourceDialect
2827                ),
2828            }
2829        }
2830
2831        #[inline]
2832        unsafe fn decode(
2833            &mut self,
2834            decoder: &mut fidl::encoding::Decoder<
2835                '_,
2836                fidl::encoding::DefaultFuchsiaResourceDialect,
2837            >,
2838            offset: usize,
2839            _depth: fidl::encoding::Depth,
2840        ) -> fidl::Result<()> {
2841            decoder.debug_check_bounds::<Self>(offset);
2842            // Verify that padding bytes are zero.
2843            fidl::decode!(
2844                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceReportsReaderMarker>>,
2845                fidl::encoding::DefaultFuchsiaResourceDialect,
2846                &mut self.reader,
2847                decoder,
2848                offset + 0,
2849                _depth
2850            )?;
2851            Ok(())
2852        }
2853    }
2854
2855    impl fidl::encoding::ResourceTypeMarker for DeviceReportsReaderReadReportsResponse {
2856        type Borrowed<'a> = &'a mut Self;
2857        fn take_or_borrow<'a>(
2858            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2859        ) -> Self::Borrowed<'a> {
2860            value
2861        }
2862    }
2863
2864    unsafe impl fidl::encoding::TypeMarker for DeviceReportsReaderReadReportsResponse {
2865        type Owned = Self;
2866
2867        #[inline(always)]
2868        fn inline_align(_context: fidl::encoding::Context) -> usize {
2869            8
2870        }
2871
2872        #[inline(always)]
2873        fn inline_size(_context: fidl::encoding::Context) -> usize {
2874            16
2875        }
2876    }
2877
2878    unsafe impl
2879        fidl::encoding::Encode<
2880            DeviceReportsReaderReadReportsResponse,
2881            fidl::encoding::DefaultFuchsiaResourceDialect,
2882        > for &mut DeviceReportsReaderReadReportsResponse
2883    {
2884        #[inline]
2885        unsafe fn encode(
2886            self,
2887            encoder: &mut fidl::encoding::Encoder<
2888                '_,
2889                fidl::encoding::DefaultFuchsiaResourceDialect,
2890            >,
2891            offset: usize,
2892            _depth: fidl::encoding::Depth,
2893        ) -> fidl::Result<()> {
2894            encoder.debug_check_bounds::<DeviceReportsReaderReadReportsResponse>(offset);
2895            // Delegate to tuple encoding.
2896            fidl::encoding::Encode::<DeviceReportsReaderReadReportsResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2897                (
2898                    <fidl::encoding::Vector<fidl_fuchsia_hardware_hidbus::Report, 50> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.reports),
2899                ),
2900                encoder, offset, _depth
2901            )
2902        }
2903    }
2904    unsafe impl<
2905            T0: fidl::encoding::Encode<
2906                fidl::encoding::Vector<fidl_fuchsia_hardware_hidbus::Report, 50>,
2907                fidl::encoding::DefaultFuchsiaResourceDialect,
2908            >,
2909        >
2910        fidl::encoding::Encode<
2911            DeviceReportsReaderReadReportsResponse,
2912            fidl::encoding::DefaultFuchsiaResourceDialect,
2913        > for (T0,)
2914    {
2915        #[inline]
2916        unsafe fn encode(
2917            self,
2918            encoder: &mut fidl::encoding::Encoder<
2919                '_,
2920                fidl::encoding::DefaultFuchsiaResourceDialect,
2921            >,
2922            offset: usize,
2923            depth: fidl::encoding::Depth,
2924        ) -> fidl::Result<()> {
2925            encoder.debug_check_bounds::<DeviceReportsReaderReadReportsResponse>(offset);
2926            // Zero out padding regions. There's no need to apply masks
2927            // because the unmasked parts will be overwritten by fields.
2928            // Write the fields.
2929            self.0.encode(encoder, offset + 0, depth)?;
2930            Ok(())
2931        }
2932    }
2933
2934    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2935        for DeviceReportsReaderReadReportsResponse
2936    {
2937        #[inline(always)]
2938        fn new_empty() -> Self {
2939            Self {
2940                reports: fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_hardware_hidbus::Report, 50>, fidl::encoding::DefaultFuchsiaResourceDialect),
2941            }
2942        }
2943
2944        #[inline]
2945        unsafe fn decode(
2946            &mut self,
2947            decoder: &mut fidl::encoding::Decoder<
2948                '_,
2949                fidl::encoding::DefaultFuchsiaResourceDialect,
2950            >,
2951            offset: usize,
2952            _depth: fidl::encoding::Depth,
2953        ) -> fidl::Result<()> {
2954            decoder.debug_check_bounds::<Self>(offset);
2955            // Verify that padding bytes are zero.
2956            fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_hardware_hidbus::Report, 50>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reports, decoder, offset + 0, _depth)?;
2957            Ok(())
2958        }
2959    }
2960
2961    impl fidl::encoding::ResourceTypeMarker for DeviceGetReportsEventResponse {
2962        type Borrowed<'a> = &'a mut Self;
2963        fn take_or_borrow<'a>(
2964            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2965        ) -> Self::Borrowed<'a> {
2966            value
2967        }
2968    }
2969
2970    unsafe impl fidl::encoding::TypeMarker for DeviceGetReportsEventResponse {
2971        type Owned = Self;
2972
2973        #[inline(always)]
2974        fn inline_align(_context: fidl::encoding::Context) -> usize {
2975            4
2976        }
2977
2978        #[inline(always)]
2979        fn inline_size(_context: fidl::encoding::Context) -> usize {
2980            4
2981        }
2982    }
2983
2984    unsafe impl
2985        fidl::encoding::Encode<
2986            DeviceGetReportsEventResponse,
2987            fidl::encoding::DefaultFuchsiaResourceDialect,
2988        > for &mut DeviceGetReportsEventResponse
2989    {
2990        #[inline]
2991        unsafe fn encode(
2992            self,
2993            encoder: &mut fidl::encoding::Encoder<
2994                '_,
2995                fidl::encoding::DefaultFuchsiaResourceDialect,
2996            >,
2997            offset: usize,
2998            _depth: fidl::encoding::Depth,
2999        ) -> fidl::Result<()> {
3000            encoder.debug_check_bounds::<DeviceGetReportsEventResponse>(offset);
3001            // Delegate to tuple encoding.
3002            fidl::encoding::Encode::<
3003                DeviceGetReportsEventResponse,
3004                fidl::encoding::DefaultFuchsiaResourceDialect,
3005            >::encode(
3006                (<fidl::encoding::HandleType<
3007                    fidl::Event,
3008                    { fidl::ObjectType::EVENT.into_raw() },
3009                    2147483648,
3010                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3011                    &mut self.event
3012                ),),
3013                encoder,
3014                offset,
3015                _depth,
3016            )
3017        }
3018    }
3019    unsafe impl<
3020            T0: fidl::encoding::Encode<
3021                fidl::encoding::HandleType<
3022                    fidl::Event,
3023                    { fidl::ObjectType::EVENT.into_raw() },
3024                    2147483648,
3025                >,
3026                fidl::encoding::DefaultFuchsiaResourceDialect,
3027            >,
3028        >
3029        fidl::encoding::Encode<
3030            DeviceGetReportsEventResponse,
3031            fidl::encoding::DefaultFuchsiaResourceDialect,
3032        > for (T0,)
3033    {
3034        #[inline]
3035        unsafe fn encode(
3036            self,
3037            encoder: &mut fidl::encoding::Encoder<
3038                '_,
3039                fidl::encoding::DefaultFuchsiaResourceDialect,
3040            >,
3041            offset: usize,
3042            depth: fidl::encoding::Depth,
3043        ) -> fidl::Result<()> {
3044            encoder.debug_check_bounds::<DeviceGetReportsEventResponse>(offset);
3045            // Zero out padding regions. There's no need to apply masks
3046            // because the unmasked parts will be overwritten by fields.
3047            // Write the fields.
3048            self.0.encode(encoder, offset + 0, depth)?;
3049            Ok(())
3050        }
3051    }
3052
3053    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3054        for DeviceGetReportsEventResponse
3055    {
3056        #[inline(always)]
3057        fn new_empty() -> Self {
3058            Self {
3059                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3060            }
3061        }
3062
3063        #[inline]
3064        unsafe fn decode(
3065            &mut self,
3066            decoder: &mut fidl::encoding::Decoder<
3067                '_,
3068                fidl::encoding::DefaultFuchsiaResourceDialect,
3069            >,
3070            offset: usize,
3071            _depth: fidl::encoding::Depth,
3072        ) -> fidl::Result<()> {
3073            decoder.debug_check_bounds::<Self>(offset);
3074            // Verify that padding bytes are zero.
3075            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3076            Ok(())
3077        }
3078    }
3079}