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