Skip to main content

fidl_fuchsia_hardware_input/
fidl_fuchsia_hardware_input.rs

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