Skip to main content

fidl_fuchsia_hardware_hidbus/
fidl_fuchsia_hardware_hidbus.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_hidbus__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct Report {
16    pub buf: Option<Vec<u8>>,
17    pub timestamp: Option<i64>,
18    pub wake_lease: Option<fidl::EventPair>,
19    #[doc(hidden)]
20    pub __source_breaking: fidl::marker::SourceBreaking,
21}
22
23impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Report {}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct HidbusMarker;
27
28impl fidl::endpoints::ProtocolMarker for HidbusMarker {
29    type Proxy = HidbusProxy;
30    type RequestStream = HidbusRequestStream;
31    #[cfg(target_os = "fuchsia")]
32    type SynchronousProxy = HidbusSynchronousProxy;
33
34    const DEBUG_NAME: &'static str = "(anonymous) Hidbus";
35}
36pub type HidbusQueryResult = Result<HidInfo, i32>;
37pub type HidbusStartResult = Result<(), i32>;
38pub type HidbusGetDescriptorResult = Result<Vec<u8>, i32>;
39pub type HidbusSetDescriptorResult = Result<(), i32>;
40pub type HidbusGetReportResult = Result<Vec<u8>, i32>;
41pub type HidbusSetReportResult = Result<(), i32>;
42pub type HidbusGetIdleResult = Result<i64, i32>;
43pub type HidbusSetIdleResult = Result<(), i32>;
44pub type HidbusGetProtocolResult = Result<HidProtocol, i32>;
45pub type HidbusSetProtocolResult = Result<(), i32>;
46
47pub trait HidbusProxyInterface: Send + Sync {
48    type QueryResponseFut: std::future::Future<Output = Result<HidbusQueryResult, fidl::Error>>
49        + Send;
50    fn r#query(&self) -> Self::QueryResponseFut;
51    type StartResponseFut: std::future::Future<Output = Result<HidbusStartResult, fidl::Error>>
52        + Send;
53    fn r#start(&self) -> Self::StartResponseFut;
54    type StopResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
55    fn r#stop(&self) -> Self::StopResponseFut;
56    type GetDescriptorResponseFut: std::future::Future<Output = Result<HidbusGetDescriptorResult, fidl::Error>>
57        + Send;
58    fn r#get_descriptor(&self, desc_type: HidDescriptorType) -> Self::GetDescriptorResponseFut;
59    type SetDescriptorResponseFut: std::future::Future<Output = Result<HidbusSetDescriptorResult, fidl::Error>>
60        + Send;
61    fn r#set_descriptor(
62        &self,
63        desc_type: HidDescriptorType,
64        data: &[u8],
65    ) -> Self::SetDescriptorResponseFut;
66    type GetReportResponseFut: std::future::Future<Output = Result<HidbusGetReportResult, fidl::Error>>
67        + Send;
68    fn r#get_report(
69        &self,
70        rpt_type: ReportType,
71        rpt_id: u8,
72        len: u64,
73    ) -> Self::GetReportResponseFut;
74    type SetReportResponseFut: std::future::Future<Output = Result<HidbusSetReportResult, fidl::Error>>
75        + Send;
76    fn r#set_report(
77        &self,
78        rpt_type: ReportType,
79        rpt_id: u8,
80        data: &[u8],
81    ) -> Self::SetReportResponseFut;
82    type GetIdleResponseFut: std::future::Future<Output = Result<HidbusGetIdleResult, fidl::Error>>
83        + Send;
84    fn r#get_idle(&self, rpt_id: u8) -> Self::GetIdleResponseFut;
85    type SetIdleResponseFut: std::future::Future<Output = Result<HidbusSetIdleResult, fidl::Error>>
86        + Send;
87    fn r#set_idle(&self, rpt_id: u8, duration: i64) -> Self::SetIdleResponseFut;
88    type GetProtocolResponseFut: std::future::Future<Output = Result<HidbusGetProtocolResult, fidl::Error>>
89        + Send;
90    fn r#get_protocol(&self) -> Self::GetProtocolResponseFut;
91    type SetProtocolResponseFut: std::future::Future<Output = Result<HidbusSetProtocolResult, fidl::Error>>
92        + Send;
93    fn r#set_protocol(&self, protocol: HidProtocol) -> Self::SetProtocolResponseFut;
94}
95#[derive(Debug)]
96#[cfg(target_os = "fuchsia")]
97pub struct HidbusSynchronousProxy {
98    client: fidl::client::sync::Client,
99}
100
101#[cfg(target_os = "fuchsia")]
102impl fidl::endpoints::SynchronousProxy for HidbusSynchronousProxy {
103    type Proxy = HidbusProxy;
104    type Protocol = HidbusMarker;
105
106    fn from_channel(inner: fidl::Channel) -> Self {
107        Self::new(inner)
108    }
109
110    fn into_channel(self) -> fidl::Channel {
111        self.client.into_channel()
112    }
113
114    fn as_channel(&self) -> &fidl::Channel {
115        self.client.as_channel()
116    }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl HidbusSynchronousProxy {
121    pub fn new(channel: fidl::Channel) -> Self {
122        Self { client: fidl::client::sync::Client::new(channel) }
123    }
124
125    pub fn into_channel(self) -> fidl::Channel {
126        self.client.into_channel()
127    }
128
129    /// Waits until an event arrives and returns it. It is safe for other
130    /// threads to make concurrent requests while waiting for an event.
131    pub fn wait_for_event(
132        &self,
133        deadline: zx::MonotonicInstant,
134    ) -> Result<HidbusEvent, fidl::Error> {
135        HidbusEvent::decode(self.client.wait_for_event::<HidbusMarker>(deadline)?)
136    }
137
138    /// Obtain information about the hidbus device and supported features.
139    /// Safe to call at any time.
140    pub fn r#query(
141        &self,
142        ___deadline: zx::MonotonicInstant,
143    ) -> Result<HidbusQueryResult, fidl::Error> {
144        let _response = self.client.send_query::<
145            fidl::encoding::EmptyPayload,
146            fidl::encoding::ResultType<HidbusQueryResponse, i32>,
147            HidbusMarker,
148        >(
149            (),
150            0x23eb61f83d06efa9,
151            fidl::encoding::DynamicFlags::empty(),
152            ___deadline,
153        )?;
154        Ok(_response.map(|x| x.info))
155    }
156
157    /// Start the hidbus device. The device may begin queueing hid reports via
158    /// OnReportReceived before this function returns. The hidbus device will
159    /// keep track of the number of times Start has been called and will only
160    /// be stopped when Stop has been called for each Start that has been
161    /// called. Theoretically, Start should not be called again by the same
162    /// client unless it has called Stop.
163    pub fn r#start(
164        &self,
165        ___deadline: zx::MonotonicInstant,
166    ) -> Result<HidbusStartResult, fidl::Error> {
167        let _response = self.client.send_query::<
168            fidl::encoding::EmptyPayload,
169            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
170            HidbusMarker,
171        >(
172            (),
173            0x1ba15adf96bade4a,
174            fidl::encoding::DynamicFlags::empty(),
175            ___deadline,
176        )?;
177        Ok(_response.map(|x| x))
178    }
179
180    /// Stop the hidbus device.
181    pub fn r#stop(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
182        let _response = self
183            .client
184            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload, HidbusMarker>(
185                (),
186                0x61b973ecd69cfff8,
187                fidl::encoding::DynamicFlags::empty(),
188                ___deadline,
189            )?;
190        Ok(_response)
191    }
192
193    /// Methods matching HID spec 1.11 Chapter 7 Requests
194    /// 7.1.1 Get_Descriptor
195    pub fn r#get_descriptor(
196        &self,
197        mut desc_type: HidDescriptorType,
198        ___deadline: zx::MonotonicInstant,
199    ) -> Result<HidbusGetDescriptorResult, fidl::Error> {
200        let _response = self.client.send_query::<
201            HidbusGetDescriptorRequest,
202            fidl::encoding::ResultType<HidbusGetDescriptorResponse, i32>,
203            HidbusMarker,
204        >(
205            (desc_type,),
206            0x29343a1289ceb2e5,
207            fidl::encoding::DynamicFlags::empty(),
208            ___deadline,
209        )?;
210        Ok(_response.map(|x| x.data))
211    }
212
213    /// 7.1.2 Set_Descriptor (optional)
214    pub fn r#set_descriptor(
215        &self,
216        mut desc_type: HidDescriptorType,
217        mut data: &[u8],
218        ___deadline: zx::MonotonicInstant,
219    ) -> Result<HidbusSetDescriptorResult, fidl::Error> {
220        let _response = self.client.send_query::<
221            HidbusSetDescriptorRequest,
222            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
223            HidbusMarker,
224        >(
225            (desc_type, data,),
226            0x7567278eba076777,
227            fidl::encoding::DynamicFlags::empty(),
228            ___deadline,
229        )?;
230        Ok(_response.map(|x| x))
231    }
232
233    /// 7.2.1 Get_Report
234    pub fn r#get_report(
235        &self,
236        mut rpt_type: ReportType,
237        mut rpt_id: u8,
238        mut len: u64,
239        ___deadline: zx::MonotonicInstant,
240    ) -> Result<HidbusGetReportResult, fidl::Error> {
241        let _response = self.client.send_query::<
242            HidbusGetReportRequest,
243            fidl::encoding::ResultType<HidbusGetReportResponse, i32>,
244            HidbusMarker,
245        >(
246            (rpt_type, rpt_id, len,),
247            0x69b5538a28dc472c,
248            fidl::encoding::DynamicFlags::empty(),
249            ___deadline,
250        )?;
251        Ok(_response.map(|x| x.data))
252    }
253
254    /// 7.2.2 Set_Report
255    pub fn r#set_report(
256        &self,
257        mut rpt_type: ReportType,
258        mut rpt_id: u8,
259        mut data: &[u8],
260        ___deadline: zx::MonotonicInstant,
261    ) -> Result<HidbusSetReportResult, fidl::Error> {
262        let _response = self.client.send_query::<
263            HidbusSetReportRequest,
264            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
265            HidbusMarker,
266        >(
267            (rpt_type, rpt_id, data,),
268            0x1172863081673c55,
269            fidl::encoding::DynamicFlags::empty(),
270            ___deadline,
271        )?;
272        Ok(_response.map(|x| x))
273    }
274
275    /// 7.2.3 Get_Idle
276    pub fn r#get_idle(
277        &self,
278        mut rpt_id: u8,
279        ___deadline: zx::MonotonicInstant,
280    ) -> Result<HidbusGetIdleResult, fidl::Error> {
281        let _response = self.client.send_query::<
282            HidbusGetIdleRequest,
283            fidl::encoding::ResultType<HidbusGetIdleResponse, i32>,
284            HidbusMarker,
285        >(
286            (rpt_id,),
287            0xa95c2c504d9aa0b,
288            fidl::encoding::DynamicFlags::empty(),
289            ___deadline,
290        )?;
291        Ok(_response.map(|x| x.duration))
292    }
293
294    /// 7.2.4 Set_Idle
295    pub fn r#set_idle(
296        &self,
297        mut rpt_id: u8,
298        mut duration: i64,
299        ___deadline: zx::MonotonicInstant,
300    ) -> Result<HidbusSetIdleResult, fidl::Error> {
301        let _response = self.client.send_query::<
302            HidbusSetIdleRequest,
303            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
304            HidbusMarker,
305        >(
306            (rpt_id, duration,),
307            0x7c387cbaa4c09b3c,
308            fidl::encoding::DynamicFlags::empty(),
309            ___deadline,
310        )?;
311        Ok(_response.map(|x| x))
312    }
313
314    /// 7.2.5 Get_Protocol
315    pub fn r#get_protocol(
316        &self,
317        ___deadline: zx::MonotonicInstant,
318    ) -> Result<HidbusGetProtocolResult, fidl::Error> {
319        let _response = self.client.send_query::<
320            fidl::encoding::EmptyPayload,
321            fidl::encoding::ResultType<HidbusGetProtocolResponse, i32>,
322            HidbusMarker,
323        >(
324            (),
325            0x3ec61a9b2d5c50eb,
326            fidl::encoding::DynamicFlags::empty(),
327            ___deadline,
328        )?;
329        Ok(_response.map(|x| x.protocol))
330    }
331
332    /// 7.2.6 Set_Protocol
333    pub fn r#set_protocol(
334        &self,
335        mut protocol: HidProtocol,
336        ___deadline: zx::MonotonicInstant,
337    ) -> Result<HidbusSetProtocolResult, fidl::Error> {
338        let _response = self.client.send_query::<
339            HidbusSetProtocolRequest,
340            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
341            HidbusMarker,
342        >(
343            (protocol,),
344            0x1655cdfd0f316b0b,
345            fidl::encoding::DynamicFlags::empty(),
346            ___deadline,
347        )?;
348        Ok(_response.map(|x| x))
349    }
350}
351
352#[cfg(target_os = "fuchsia")]
353impl From<HidbusSynchronousProxy> for zx::NullableHandle {
354    fn from(value: HidbusSynchronousProxy) -> Self {
355        value.into_channel().into()
356    }
357}
358
359#[cfg(target_os = "fuchsia")]
360impl From<fidl::Channel> for HidbusSynchronousProxy {
361    fn from(value: fidl::Channel) -> Self {
362        Self::new(value)
363    }
364}
365
366#[cfg(target_os = "fuchsia")]
367impl fidl::endpoints::FromClient for HidbusSynchronousProxy {
368    type Protocol = HidbusMarker;
369
370    fn from_client(value: fidl::endpoints::ClientEnd<HidbusMarker>) -> Self {
371        Self::new(value.into_channel())
372    }
373}
374
375#[derive(Debug, Clone)]
376pub struct HidbusProxy {
377    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
378}
379
380impl fidl::endpoints::Proxy for HidbusProxy {
381    type Protocol = HidbusMarker;
382
383    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
384        Self::new(inner)
385    }
386
387    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
388        self.client.into_channel().map_err(|client| Self { client })
389    }
390
391    fn as_channel(&self) -> &::fidl::AsyncChannel {
392        self.client.as_channel()
393    }
394}
395
396impl HidbusProxy {
397    /// Create a new Proxy for fuchsia.hardware.hidbus/Hidbus.
398    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
399        let protocol_name = <HidbusMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
400        Self { client: fidl::client::Client::new(channel, protocol_name) }
401    }
402
403    /// Get a Stream of events from the remote end of the protocol.
404    ///
405    /// # Panics
406    ///
407    /// Panics if the event stream was already taken.
408    pub fn take_event_stream(&self) -> HidbusEventStream {
409        HidbusEventStream { event_receiver: self.client.take_event_receiver() }
410    }
411
412    /// Obtain information about the hidbus device and supported features.
413    /// Safe to call at any time.
414    pub fn r#query(
415        &self,
416    ) -> fidl::client::QueryResponseFut<
417        HidbusQueryResult,
418        fidl::encoding::DefaultFuchsiaResourceDialect,
419    > {
420        HidbusProxyInterface::r#query(self)
421    }
422
423    /// Start the hidbus device. The device may begin queueing hid reports via
424    /// OnReportReceived before this function returns. The hidbus device will
425    /// keep track of the number of times Start has been called and will only
426    /// be stopped when Stop has been called for each Start that has been
427    /// called. Theoretically, Start should not be called again by the same
428    /// client unless it has called Stop.
429    pub fn r#start(
430        &self,
431    ) -> fidl::client::QueryResponseFut<
432        HidbusStartResult,
433        fidl::encoding::DefaultFuchsiaResourceDialect,
434    > {
435        HidbusProxyInterface::r#start(self)
436    }
437
438    /// Stop the hidbus device.
439    pub fn r#stop(
440        &self,
441    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
442        HidbusProxyInterface::r#stop(self)
443    }
444
445    /// Methods matching HID spec 1.11 Chapter 7 Requests
446    /// 7.1.1 Get_Descriptor
447    pub fn r#get_descriptor(
448        &self,
449        mut desc_type: HidDescriptorType,
450    ) -> fidl::client::QueryResponseFut<
451        HidbusGetDescriptorResult,
452        fidl::encoding::DefaultFuchsiaResourceDialect,
453    > {
454        HidbusProxyInterface::r#get_descriptor(self, desc_type)
455    }
456
457    /// 7.1.2 Set_Descriptor (optional)
458    pub fn r#set_descriptor(
459        &self,
460        mut desc_type: HidDescriptorType,
461        mut data: &[u8],
462    ) -> fidl::client::QueryResponseFut<
463        HidbusSetDescriptorResult,
464        fidl::encoding::DefaultFuchsiaResourceDialect,
465    > {
466        HidbusProxyInterface::r#set_descriptor(self, desc_type, data)
467    }
468
469    /// 7.2.1 Get_Report
470    pub fn r#get_report(
471        &self,
472        mut rpt_type: ReportType,
473        mut rpt_id: u8,
474        mut len: u64,
475    ) -> fidl::client::QueryResponseFut<
476        HidbusGetReportResult,
477        fidl::encoding::DefaultFuchsiaResourceDialect,
478    > {
479        HidbusProxyInterface::r#get_report(self, rpt_type, rpt_id, len)
480    }
481
482    /// 7.2.2 Set_Report
483    pub fn r#set_report(
484        &self,
485        mut rpt_type: ReportType,
486        mut rpt_id: u8,
487        mut data: &[u8],
488    ) -> fidl::client::QueryResponseFut<
489        HidbusSetReportResult,
490        fidl::encoding::DefaultFuchsiaResourceDialect,
491    > {
492        HidbusProxyInterface::r#set_report(self, rpt_type, rpt_id, data)
493    }
494
495    /// 7.2.3 Get_Idle
496    pub fn r#get_idle(
497        &self,
498        mut rpt_id: u8,
499    ) -> fidl::client::QueryResponseFut<
500        HidbusGetIdleResult,
501        fidl::encoding::DefaultFuchsiaResourceDialect,
502    > {
503        HidbusProxyInterface::r#get_idle(self, rpt_id)
504    }
505
506    /// 7.2.4 Set_Idle
507    pub fn r#set_idle(
508        &self,
509        mut rpt_id: u8,
510        mut duration: i64,
511    ) -> fidl::client::QueryResponseFut<
512        HidbusSetIdleResult,
513        fidl::encoding::DefaultFuchsiaResourceDialect,
514    > {
515        HidbusProxyInterface::r#set_idle(self, rpt_id, duration)
516    }
517
518    /// 7.2.5 Get_Protocol
519    pub fn r#get_protocol(
520        &self,
521    ) -> fidl::client::QueryResponseFut<
522        HidbusGetProtocolResult,
523        fidl::encoding::DefaultFuchsiaResourceDialect,
524    > {
525        HidbusProxyInterface::r#get_protocol(self)
526    }
527
528    /// 7.2.6 Set_Protocol
529    pub fn r#set_protocol(
530        &self,
531        mut protocol: HidProtocol,
532    ) -> fidl::client::QueryResponseFut<
533        HidbusSetProtocolResult,
534        fidl::encoding::DefaultFuchsiaResourceDialect,
535    > {
536        HidbusProxyInterface::r#set_protocol(self, protocol)
537    }
538}
539
540impl HidbusProxyInterface for HidbusProxy {
541    type QueryResponseFut = fidl::client::QueryResponseFut<
542        HidbusQueryResult,
543        fidl::encoding::DefaultFuchsiaResourceDialect,
544    >;
545    fn r#query(&self) -> Self::QueryResponseFut {
546        fn _decode(
547            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
548        ) -> Result<HidbusQueryResult, fidl::Error> {
549            let _response = fidl::client::decode_transaction_body::<
550                fidl::encoding::ResultType<HidbusQueryResponse, i32>,
551                fidl::encoding::DefaultFuchsiaResourceDialect,
552                0x23eb61f83d06efa9,
553            >(_buf?)?;
554            Ok(_response.map(|x| x.info))
555        }
556        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, HidbusQueryResult>(
557            (),
558            0x23eb61f83d06efa9,
559            fidl::encoding::DynamicFlags::empty(),
560            _decode,
561        )
562    }
563
564    type StartResponseFut = fidl::client::QueryResponseFut<
565        HidbusStartResult,
566        fidl::encoding::DefaultFuchsiaResourceDialect,
567    >;
568    fn r#start(&self) -> Self::StartResponseFut {
569        fn _decode(
570            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
571        ) -> Result<HidbusStartResult, fidl::Error> {
572            let _response = fidl::client::decode_transaction_body::<
573                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
574                fidl::encoding::DefaultFuchsiaResourceDialect,
575                0x1ba15adf96bade4a,
576            >(_buf?)?;
577            Ok(_response.map(|x| x))
578        }
579        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, HidbusStartResult>(
580            (),
581            0x1ba15adf96bade4a,
582            fidl::encoding::DynamicFlags::empty(),
583            _decode,
584        )
585    }
586
587    type StopResponseFut =
588        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
589    fn r#stop(&self) -> Self::StopResponseFut {
590        fn _decode(
591            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
592        ) -> Result<(), fidl::Error> {
593            let _response = fidl::client::decode_transaction_body::<
594                fidl::encoding::EmptyPayload,
595                fidl::encoding::DefaultFuchsiaResourceDialect,
596                0x61b973ecd69cfff8,
597            >(_buf?)?;
598            Ok(_response)
599        }
600        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
601            (),
602            0x61b973ecd69cfff8,
603            fidl::encoding::DynamicFlags::empty(),
604            _decode,
605        )
606    }
607
608    type GetDescriptorResponseFut = fidl::client::QueryResponseFut<
609        HidbusGetDescriptorResult,
610        fidl::encoding::DefaultFuchsiaResourceDialect,
611    >;
612    fn r#get_descriptor(&self, mut desc_type: HidDescriptorType) -> Self::GetDescriptorResponseFut {
613        fn _decode(
614            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
615        ) -> Result<HidbusGetDescriptorResult, fidl::Error> {
616            let _response = fidl::client::decode_transaction_body::<
617                fidl::encoding::ResultType<HidbusGetDescriptorResponse, i32>,
618                fidl::encoding::DefaultFuchsiaResourceDialect,
619                0x29343a1289ceb2e5,
620            >(_buf?)?;
621            Ok(_response.map(|x| x.data))
622        }
623        self.client.send_query_and_decode::<HidbusGetDescriptorRequest, HidbusGetDescriptorResult>(
624            (desc_type,),
625            0x29343a1289ceb2e5,
626            fidl::encoding::DynamicFlags::empty(),
627            _decode,
628        )
629    }
630
631    type SetDescriptorResponseFut = fidl::client::QueryResponseFut<
632        HidbusSetDescriptorResult,
633        fidl::encoding::DefaultFuchsiaResourceDialect,
634    >;
635    fn r#set_descriptor(
636        &self,
637        mut desc_type: HidDescriptorType,
638        mut data: &[u8],
639    ) -> Self::SetDescriptorResponseFut {
640        fn _decode(
641            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
642        ) -> Result<HidbusSetDescriptorResult, fidl::Error> {
643            let _response = fidl::client::decode_transaction_body::<
644                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
645                fidl::encoding::DefaultFuchsiaResourceDialect,
646                0x7567278eba076777,
647            >(_buf?)?;
648            Ok(_response.map(|x| x))
649        }
650        self.client.send_query_and_decode::<HidbusSetDescriptorRequest, HidbusSetDescriptorResult>(
651            (desc_type, data),
652            0x7567278eba076777,
653            fidl::encoding::DynamicFlags::empty(),
654            _decode,
655        )
656    }
657
658    type GetReportResponseFut = fidl::client::QueryResponseFut<
659        HidbusGetReportResult,
660        fidl::encoding::DefaultFuchsiaResourceDialect,
661    >;
662    fn r#get_report(
663        &self,
664        mut rpt_type: ReportType,
665        mut rpt_id: u8,
666        mut len: u64,
667    ) -> Self::GetReportResponseFut {
668        fn _decode(
669            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
670        ) -> Result<HidbusGetReportResult, fidl::Error> {
671            let _response = fidl::client::decode_transaction_body::<
672                fidl::encoding::ResultType<HidbusGetReportResponse, i32>,
673                fidl::encoding::DefaultFuchsiaResourceDialect,
674                0x69b5538a28dc472c,
675            >(_buf?)?;
676            Ok(_response.map(|x| x.data))
677        }
678        self.client.send_query_and_decode::<HidbusGetReportRequest, HidbusGetReportResult>(
679            (rpt_type, rpt_id, len),
680            0x69b5538a28dc472c,
681            fidl::encoding::DynamicFlags::empty(),
682            _decode,
683        )
684    }
685
686    type SetReportResponseFut = fidl::client::QueryResponseFut<
687        HidbusSetReportResult,
688        fidl::encoding::DefaultFuchsiaResourceDialect,
689    >;
690    fn r#set_report(
691        &self,
692        mut rpt_type: ReportType,
693        mut rpt_id: u8,
694        mut data: &[u8],
695    ) -> Self::SetReportResponseFut {
696        fn _decode(
697            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
698        ) -> Result<HidbusSetReportResult, fidl::Error> {
699            let _response = fidl::client::decode_transaction_body::<
700                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
701                fidl::encoding::DefaultFuchsiaResourceDialect,
702                0x1172863081673c55,
703            >(_buf?)?;
704            Ok(_response.map(|x| x))
705        }
706        self.client.send_query_and_decode::<HidbusSetReportRequest, HidbusSetReportResult>(
707            (rpt_type, rpt_id, data),
708            0x1172863081673c55,
709            fidl::encoding::DynamicFlags::empty(),
710            _decode,
711        )
712    }
713
714    type GetIdleResponseFut = fidl::client::QueryResponseFut<
715        HidbusGetIdleResult,
716        fidl::encoding::DefaultFuchsiaResourceDialect,
717    >;
718    fn r#get_idle(&self, mut rpt_id: u8) -> Self::GetIdleResponseFut {
719        fn _decode(
720            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
721        ) -> Result<HidbusGetIdleResult, fidl::Error> {
722            let _response = fidl::client::decode_transaction_body::<
723                fidl::encoding::ResultType<HidbusGetIdleResponse, i32>,
724                fidl::encoding::DefaultFuchsiaResourceDialect,
725                0xa95c2c504d9aa0b,
726            >(_buf?)?;
727            Ok(_response.map(|x| x.duration))
728        }
729        self.client.send_query_and_decode::<HidbusGetIdleRequest, HidbusGetIdleResult>(
730            (rpt_id,),
731            0xa95c2c504d9aa0b,
732            fidl::encoding::DynamicFlags::empty(),
733            _decode,
734        )
735    }
736
737    type SetIdleResponseFut = fidl::client::QueryResponseFut<
738        HidbusSetIdleResult,
739        fidl::encoding::DefaultFuchsiaResourceDialect,
740    >;
741    fn r#set_idle(&self, mut rpt_id: u8, mut duration: i64) -> Self::SetIdleResponseFut {
742        fn _decode(
743            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
744        ) -> Result<HidbusSetIdleResult, fidl::Error> {
745            let _response = fidl::client::decode_transaction_body::<
746                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
747                fidl::encoding::DefaultFuchsiaResourceDialect,
748                0x7c387cbaa4c09b3c,
749            >(_buf?)?;
750            Ok(_response.map(|x| x))
751        }
752        self.client.send_query_and_decode::<HidbusSetIdleRequest, HidbusSetIdleResult>(
753            (rpt_id, duration),
754            0x7c387cbaa4c09b3c,
755            fidl::encoding::DynamicFlags::empty(),
756            _decode,
757        )
758    }
759
760    type GetProtocolResponseFut = fidl::client::QueryResponseFut<
761        HidbusGetProtocolResult,
762        fidl::encoding::DefaultFuchsiaResourceDialect,
763    >;
764    fn r#get_protocol(&self) -> Self::GetProtocolResponseFut {
765        fn _decode(
766            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
767        ) -> Result<HidbusGetProtocolResult, fidl::Error> {
768            let _response = fidl::client::decode_transaction_body::<
769                fidl::encoding::ResultType<HidbusGetProtocolResponse, i32>,
770                fidl::encoding::DefaultFuchsiaResourceDialect,
771                0x3ec61a9b2d5c50eb,
772            >(_buf?)?;
773            Ok(_response.map(|x| x.protocol))
774        }
775        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, HidbusGetProtocolResult>(
776            (),
777            0x3ec61a9b2d5c50eb,
778            fidl::encoding::DynamicFlags::empty(),
779            _decode,
780        )
781    }
782
783    type SetProtocolResponseFut = fidl::client::QueryResponseFut<
784        HidbusSetProtocolResult,
785        fidl::encoding::DefaultFuchsiaResourceDialect,
786    >;
787    fn r#set_protocol(&self, mut protocol: HidProtocol) -> Self::SetProtocolResponseFut {
788        fn _decode(
789            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
790        ) -> Result<HidbusSetProtocolResult, fidl::Error> {
791            let _response = fidl::client::decode_transaction_body::<
792                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
793                fidl::encoding::DefaultFuchsiaResourceDialect,
794                0x1655cdfd0f316b0b,
795            >(_buf?)?;
796            Ok(_response.map(|x| x))
797        }
798        self.client.send_query_and_decode::<HidbusSetProtocolRequest, HidbusSetProtocolResult>(
799            (protocol,),
800            0x1655cdfd0f316b0b,
801            fidl::encoding::DynamicFlags::empty(),
802            _decode,
803        )
804    }
805}
806
807pub struct HidbusEventStream {
808    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
809}
810
811impl std::marker::Unpin for HidbusEventStream {}
812
813impl futures::stream::FusedStream for HidbusEventStream {
814    fn is_terminated(&self) -> bool {
815        self.event_receiver.is_terminated()
816    }
817}
818
819impl futures::Stream for HidbusEventStream {
820    type Item = Result<HidbusEvent, fidl::Error>;
821
822    fn poll_next(
823        mut self: std::pin::Pin<&mut Self>,
824        cx: &mut std::task::Context<'_>,
825    ) -> std::task::Poll<Option<Self::Item>> {
826        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
827            &mut self.event_receiver,
828            cx
829        )?) {
830            Some(buf) => std::task::Poll::Ready(Some(HidbusEvent::decode(buf))),
831            None => std::task::Poll::Ready(None),
832        }
833    }
834}
835
836#[derive(Debug)]
837pub enum HidbusEvent {
838    OnReportReceived { payload: Report },
839}
840
841impl HidbusEvent {
842    #[allow(irrefutable_let_patterns)]
843    pub fn into_on_report_received(self) -> Option<Report> {
844        if let HidbusEvent::OnReportReceived { payload } = self { Some((payload)) } else { None }
845    }
846
847    /// Decodes a message buffer as a [`HidbusEvent`].
848    fn decode(
849        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
850    ) -> Result<HidbusEvent, fidl::Error> {
851        let (bytes, _handles) = buf.split_mut();
852        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
853        debug_assert_eq!(tx_header.tx_id, 0);
854        match tx_header.ordinal {
855            0x6093963f2efe1e56 => {
856                let mut out =
857                    fidl::new_empty!(Report, fidl::encoding::DefaultFuchsiaResourceDialect);
858                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Report>(&tx_header, _body_bytes, _handles, &mut out)?;
859                Ok((HidbusEvent::OnReportReceived { payload: out }))
860            }
861            _ => Err(fidl::Error::UnknownOrdinal {
862                ordinal: tx_header.ordinal,
863                protocol_name: <HidbusMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
864            }),
865        }
866    }
867}
868
869/// A Stream of incoming requests for fuchsia.hardware.hidbus/Hidbus.
870pub struct HidbusRequestStream {
871    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
872    is_terminated: bool,
873}
874
875impl std::marker::Unpin for HidbusRequestStream {}
876
877impl futures::stream::FusedStream for HidbusRequestStream {
878    fn is_terminated(&self) -> bool {
879        self.is_terminated
880    }
881}
882
883impl fidl::endpoints::RequestStream for HidbusRequestStream {
884    type Protocol = HidbusMarker;
885    type ControlHandle = HidbusControlHandle;
886
887    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
888        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
889    }
890
891    fn control_handle(&self) -> Self::ControlHandle {
892        HidbusControlHandle { inner: self.inner.clone() }
893    }
894
895    fn into_inner(
896        self,
897    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
898    {
899        (self.inner, self.is_terminated)
900    }
901
902    fn from_inner(
903        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
904        is_terminated: bool,
905    ) -> Self {
906        Self { inner, is_terminated }
907    }
908}
909
910impl futures::Stream for HidbusRequestStream {
911    type Item = Result<HidbusRequest, fidl::Error>;
912
913    fn poll_next(
914        mut self: std::pin::Pin<&mut Self>,
915        cx: &mut std::task::Context<'_>,
916    ) -> std::task::Poll<Option<Self::Item>> {
917        let this = &mut *self;
918        if this.inner.check_shutdown(cx) {
919            this.is_terminated = true;
920            return std::task::Poll::Ready(None);
921        }
922        if this.is_terminated {
923            panic!("polled HidbusRequestStream after completion");
924        }
925        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
926            |bytes, handles| {
927                match this.inner.channel().read_etc(cx, bytes, handles) {
928                    std::task::Poll::Ready(Ok(())) => {}
929                    std::task::Poll::Pending => return std::task::Poll::Pending,
930                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
931                        this.is_terminated = true;
932                        return std::task::Poll::Ready(None);
933                    }
934                    std::task::Poll::Ready(Err(e)) => {
935                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
936                            e.into(),
937                        ))));
938                    }
939                }
940
941                // A message has been received from the channel
942                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
943
944                std::task::Poll::Ready(Some(match header.ordinal {
945                    0x23eb61f83d06efa9 => {
946                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
947                        let mut req = fidl::new_empty!(
948                            fidl::encoding::EmptyPayload,
949                            fidl::encoding::DefaultFuchsiaResourceDialect
950                        );
951                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
952                        let control_handle = HidbusControlHandle { inner: this.inner.clone() };
953                        Ok(HidbusRequest::Query {
954                            responder: HidbusQueryResponder {
955                                control_handle: std::mem::ManuallyDrop::new(control_handle),
956                                tx_id: header.tx_id,
957                            },
958                        })
959                    }
960                    0x1ba15adf96bade4a => {
961                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
962                        let mut req = fidl::new_empty!(
963                            fidl::encoding::EmptyPayload,
964                            fidl::encoding::DefaultFuchsiaResourceDialect
965                        );
966                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
967                        let control_handle = HidbusControlHandle { inner: this.inner.clone() };
968                        Ok(HidbusRequest::Start {
969                            responder: HidbusStartResponder {
970                                control_handle: std::mem::ManuallyDrop::new(control_handle),
971                                tx_id: header.tx_id,
972                            },
973                        })
974                    }
975                    0x61b973ecd69cfff8 => {
976                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
977                        let mut req = fidl::new_empty!(
978                            fidl::encoding::EmptyPayload,
979                            fidl::encoding::DefaultFuchsiaResourceDialect
980                        );
981                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
982                        let control_handle = HidbusControlHandle { inner: this.inner.clone() };
983                        Ok(HidbusRequest::Stop {
984                            responder: HidbusStopResponder {
985                                control_handle: std::mem::ManuallyDrop::new(control_handle),
986                                tx_id: header.tx_id,
987                            },
988                        })
989                    }
990                    0x29343a1289ceb2e5 => {
991                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
992                        let mut req = fidl::new_empty!(
993                            HidbusGetDescriptorRequest,
994                            fidl::encoding::DefaultFuchsiaResourceDialect
995                        );
996                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HidbusGetDescriptorRequest>(&header, _body_bytes, handles, &mut req)?;
997                        let control_handle = HidbusControlHandle { inner: this.inner.clone() };
998                        Ok(HidbusRequest::GetDescriptor {
999                            desc_type: req.desc_type,
1000
1001                            responder: HidbusGetDescriptorResponder {
1002                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1003                                tx_id: header.tx_id,
1004                            },
1005                        })
1006                    }
1007                    0x7567278eba076777 => {
1008                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1009                        let mut req = fidl::new_empty!(
1010                            HidbusSetDescriptorRequest,
1011                            fidl::encoding::DefaultFuchsiaResourceDialect
1012                        );
1013                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HidbusSetDescriptorRequest>(&header, _body_bytes, handles, &mut req)?;
1014                        let control_handle = HidbusControlHandle { inner: this.inner.clone() };
1015                        Ok(HidbusRequest::SetDescriptor {
1016                            desc_type: req.desc_type,
1017                            data: req.data,
1018
1019                            responder: HidbusSetDescriptorResponder {
1020                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1021                                tx_id: header.tx_id,
1022                            },
1023                        })
1024                    }
1025                    0x69b5538a28dc472c => {
1026                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1027                        let mut req = fidl::new_empty!(
1028                            HidbusGetReportRequest,
1029                            fidl::encoding::DefaultFuchsiaResourceDialect
1030                        );
1031                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HidbusGetReportRequest>(&header, _body_bytes, handles, &mut req)?;
1032                        let control_handle = HidbusControlHandle { inner: this.inner.clone() };
1033                        Ok(HidbusRequest::GetReport {
1034                            rpt_type: req.rpt_type,
1035                            rpt_id: req.rpt_id,
1036                            len: req.len,
1037
1038                            responder: HidbusGetReportResponder {
1039                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1040                                tx_id: header.tx_id,
1041                            },
1042                        })
1043                    }
1044                    0x1172863081673c55 => {
1045                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1046                        let mut req = fidl::new_empty!(
1047                            HidbusSetReportRequest,
1048                            fidl::encoding::DefaultFuchsiaResourceDialect
1049                        );
1050                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HidbusSetReportRequest>(&header, _body_bytes, handles, &mut req)?;
1051                        let control_handle = HidbusControlHandle { inner: this.inner.clone() };
1052                        Ok(HidbusRequest::SetReport {
1053                            rpt_type: req.rpt_type,
1054                            rpt_id: req.rpt_id,
1055                            data: req.data,
1056
1057                            responder: HidbusSetReportResponder {
1058                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1059                                tx_id: header.tx_id,
1060                            },
1061                        })
1062                    }
1063                    0xa95c2c504d9aa0b => {
1064                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1065                        let mut req = fidl::new_empty!(
1066                            HidbusGetIdleRequest,
1067                            fidl::encoding::DefaultFuchsiaResourceDialect
1068                        );
1069                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HidbusGetIdleRequest>(&header, _body_bytes, handles, &mut req)?;
1070                        let control_handle = HidbusControlHandle { inner: this.inner.clone() };
1071                        Ok(HidbusRequest::GetIdle {
1072                            rpt_id: req.rpt_id,
1073
1074                            responder: HidbusGetIdleResponder {
1075                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1076                                tx_id: header.tx_id,
1077                            },
1078                        })
1079                    }
1080                    0x7c387cbaa4c09b3c => {
1081                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1082                        let mut req = fidl::new_empty!(
1083                            HidbusSetIdleRequest,
1084                            fidl::encoding::DefaultFuchsiaResourceDialect
1085                        );
1086                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HidbusSetIdleRequest>(&header, _body_bytes, handles, &mut req)?;
1087                        let control_handle = HidbusControlHandle { inner: this.inner.clone() };
1088                        Ok(HidbusRequest::SetIdle {
1089                            rpt_id: req.rpt_id,
1090                            duration: req.duration,
1091
1092                            responder: HidbusSetIdleResponder {
1093                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1094                                tx_id: header.tx_id,
1095                            },
1096                        })
1097                    }
1098                    0x3ec61a9b2d5c50eb => {
1099                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1100                        let mut req = fidl::new_empty!(
1101                            fidl::encoding::EmptyPayload,
1102                            fidl::encoding::DefaultFuchsiaResourceDialect
1103                        );
1104                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1105                        let control_handle = HidbusControlHandle { inner: this.inner.clone() };
1106                        Ok(HidbusRequest::GetProtocol {
1107                            responder: HidbusGetProtocolResponder {
1108                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1109                                tx_id: header.tx_id,
1110                            },
1111                        })
1112                    }
1113                    0x1655cdfd0f316b0b => {
1114                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1115                        let mut req = fidl::new_empty!(
1116                            HidbusSetProtocolRequest,
1117                            fidl::encoding::DefaultFuchsiaResourceDialect
1118                        );
1119                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HidbusSetProtocolRequest>(&header, _body_bytes, handles, &mut req)?;
1120                        let control_handle = HidbusControlHandle { inner: this.inner.clone() };
1121                        Ok(HidbusRequest::SetProtocol {
1122                            protocol: req.protocol,
1123
1124                            responder: HidbusSetProtocolResponder {
1125                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1126                                tx_id: header.tx_id,
1127                            },
1128                        })
1129                    }
1130                    _ => Err(fidl::Error::UnknownOrdinal {
1131                        ordinal: header.ordinal,
1132                        protocol_name:
1133                            <HidbusMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1134                    }),
1135                }))
1136            },
1137        )
1138    }
1139}
1140
1141#[derive(Debug)]
1142pub enum HidbusRequest {
1143    /// Obtain information about the hidbus device and supported features.
1144    /// Safe to call at any time.
1145    Query { responder: HidbusQueryResponder },
1146    /// Start the hidbus device. The device may begin queueing hid reports via
1147    /// OnReportReceived before this function returns. The hidbus device will
1148    /// keep track of the number of times Start has been called and will only
1149    /// be stopped when Stop has been called for each Start that has been
1150    /// called. Theoretically, Start should not be called again by the same
1151    /// client unless it has called Stop.
1152    Start { responder: HidbusStartResponder },
1153    /// Stop the hidbus device.
1154    Stop { responder: HidbusStopResponder },
1155    /// Methods matching HID spec 1.11 Chapter 7 Requests
1156    /// 7.1.1 Get_Descriptor
1157    GetDescriptor { desc_type: HidDescriptorType, responder: HidbusGetDescriptorResponder },
1158    /// 7.1.2 Set_Descriptor (optional)
1159    SetDescriptor {
1160        desc_type: HidDescriptorType,
1161        data: Vec<u8>,
1162        responder: HidbusSetDescriptorResponder,
1163    },
1164    /// 7.2.1 Get_Report
1165    GetReport { rpt_type: ReportType, rpt_id: u8, len: u64, responder: HidbusGetReportResponder },
1166    /// 7.2.2 Set_Report
1167    SetReport {
1168        rpt_type: ReportType,
1169        rpt_id: u8,
1170        data: Vec<u8>,
1171        responder: HidbusSetReportResponder,
1172    },
1173    /// 7.2.3 Get_Idle
1174    GetIdle { rpt_id: u8, responder: HidbusGetIdleResponder },
1175    /// 7.2.4 Set_Idle
1176    SetIdle { rpt_id: u8, duration: i64, responder: HidbusSetIdleResponder },
1177    /// 7.2.5 Get_Protocol
1178    GetProtocol { responder: HidbusGetProtocolResponder },
1179    /// 7.2.6 Set_Protocol
1180    SetProtocol { protocol: HidProtocol, responder: HidbusSetProtocolResponder },
1181}
1182
1183impl HidbusRequest {
1184    #[allow(irrefutable_let_patterns)]
1185    pub fn into_query(self) -> Option<(HidbusQueryResponder)> {
1186        if let HidbusRequest::Query { responder } = self { Some((responder)) } else { None }
1187    }
1188
1189    #[allow(irrefutable_let_patterns)]
1190    pub fn into_start(self) -> Option<(HidbusStartResponder)> {
1191        if let HidbusRequest::Start { responder } = self { Some((responder)) } else { None }
1192    }
1193
1194    #[allow(irrefutable_let_patterns)]
1195    pub fn into_stop(self) -> Option<(HidbusStopResponder)> {
1196        if let HidbusRequest::Stop { responder } = self { Some((responder)) } else { None }
1197    }
1198
1199    #[allow(irrefutable_let_patterns)]
1200    pub fn into_get_descriptor(self) -> Option<(HidDescriptorType, HidbusGetDescriptorResponder)> {
1201        if let HidbusRequest::GetDescriptor { desc_type, responder } = self {
1202            Some((desc_type, responder))
1203        } else {
1204            None
1205        }
1206    }
1207
1208    #[allow(irrefutable_let_patterns)]
1209    pub fn into_set_descriptor(
1210        self,
1211    ) -> Option<(HidDescriptorType, Vec<u8>, HidbusSetDescriptorResponder)> {
1212        if let HidbusRequest::SetDescriptor { desc_type, data, responder } = self {
1213            Some((desc_type, data, responder))
1214        } else {
1215            None
1216        }
1217    }
1218
1219    #[allow(irrefutable_let_patterns)]
1220    pub fn into_get_report(self) -> Option<(ReportType, u8, u64, HidbusGetReportResponder)> {
1221        if let HidbusRequest::GetReport { rpt_type, rpt_id, len, responder } = self {
1222            Some((rpt_type, rpt_id, len, responder))
1223        } else {
1224            None
1225        }
1226    }
1227
1228    #[allow(irrefutable_let_patterns)]
1229    pub fn into_set_report(self) -> Option<(ReportType, u8, Vec<u8>, HidbusSetReportResponder)> {
1230        if let HidbusRequest::SetReport { rpt_type, rpt_id, data, responder } = self {
1231            Some((rpt_type, rpt_id, data, responder))
1232        } else {
1233            None
1234        }
1235    }
1236
1237    #[allow(irrefutable_let_patterns)]
1238    pub fn into_get_idle(self) -> Option<(u8, HidbusGetIdleResponder)> {
1239        if let HidbusRequest::GetIdle { rpt_id, responder } = self {
1240            Some((rpt_id, responder))
1241        } else {
1242            None
1243        }
1244    }
1245
1246    #[allow(irrefutable_let_patterns)]
1247    pub fn into_set_idle(self) -> Option<(u8, i64, HidbusSetIdleResponder)> {
1248        if let HidbusRequest::SetIdle { rpt_id, duration, responder } = self {
1249            Some((rpt_id, duration, responder))
1250        } else {
1251            None
1252        }
1253    }
1254
1255    #[allow(irrefutable_let_patterns)]
1256    pub fn into_get_protocol(self) -> Option<(HidbusGetProtocolResponder)> {
1257        if let HidbusRequest::GetProtocol { responder } = self { Some((responder)) } else { None }
1258    }
1259
1260    #[allow(irrefutable_let_patterns)]
1261    pub fn into_set_protocol(self) -> Option<(HidProtocol, HidbusSetProtocolResponder)> {
1262        if let HidbusRequest::SetProtocol { protocol, responder } = self {
1263            Some((protocol, responder))
1264        } else {
1265            None
1266        }
1267    }
1268
1269    /// Name of the method defined in FIDL
1270    pub fn method_name(&self) -> &'static str {
1271        match *self {
1272            HidbusRequest::Query { .. } => "query",
1273            HidbusRequest::Start { .. } => "start",
1274            HidbusRequest::Stop { .. } => "stop",
1275            HidbusRequest::GetDescriptor { .. } => "get_descriptor",
1276            HidbusRequest::SetDescriptor { .. } => "set_descriptor",
1277            HidbusRequest::GetReport { .. } => "get_report",
1278            HidbusRequest::SetReport { .. } => "set_report",
1279            HidbusRequest::GetIdle { .. } => "get_idle",
1280            HidbusRequest::SetIdle { .. } => "set_idle",
1281            HidbusRequest::GetProtocol { .. } => "get_protocol",
1282            HidbusRequest::SetProtocol { .. } => "set_protocol",
1283        }
1284    }
1285}
1286
1287#[derive(Debug, Clone)]
1288pub struct HidbusControlHandle {
1289    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1290}
1291
1292impl fidl::endpoints::ControlHandle for HidbusControlHandle {
1293    fn shutdown(&self) {
1294        self.inner.shutdown()
1295    }
1296
1297    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1298        self.inner.shutdown_with_epitaph(status)
1299    }
1300
1301    fn is_closed(&self) -> bool {
1302        self.inner.channel().is_closed()
1303    }
1304    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1305        self.inner.channel().on_closed()
1306    }
1307
1308    #[cfg(target_os = "fuchsia")]
1309    fn signal_peer(
1310        &self,
1311        clear_mask: zx::Signals,
1312        set_mask: zx::Signals,
1313    ) -> Result<(), zx_status::Status> {
1314        use fidl::Peered;
1315        self.inner.channel().signal_peer(clear_mask, set_mask)
1316    }
1317}
1318
1319impl HidbusControlHandle {
1320    pub fn send_on_report_received(&self, mut payload: Report) -> Result<(), fidl::Error> {
1321        self.inner.send::<Report>(
1322            &mut payload,
1323            0,
1324            0x6093963f2efe1e56,
1325            fidl::encoding::DynamicFlags::empty(),
1326        )
1327    }
1328}
1329
1330#[must_use = "FIDL methods require a response to be sent"]
1331#[derive(Debug)]
1332pub struct HidbusQueryResponder {
1333    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1334    tx_id: u32,
1335}
1336
1337/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1338/// if the responder is dropped without sending a response, so that the client
1339/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1340impl std::ops::Drop for HidbusQueryResponder {
1341    fn drop(&mut self) {
1342        self.control_handle.shutdown();
1343        // Safety: drops once, never accessed again
1344        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1345    }
1346}
1347
1348impl fidl::endpoints::Responder for HidbusQueryResponder {
1349    type ControlHandle = HidbusControlHandle;
1350
1351    fn control_handle(&self) -> &HidbusControlHandle {
1352        &self.control_handle
1353    }
1354
1355    fn drop_without_shutdown(mut self) {
1356        // Safety: drops once, never accessed again due to mem::forget
1357        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1358        // Prevent Drop from running (which would shut down the channel)
1359        std::mem::forget(self);
1360    }
1361}
1362
1363impl HidbusQueryResponder {
1364    /// Sends a response to the FIDL transaction.
1365    ///
1366    /// Sets the channel to shutdown if an error occurs.
1367    pub fn send(self, mut result: Result<&HidInfo, i32>) -> Result<(), fidl::Error> {
1368        let _result = self.send_raw(result);
1369        if _result.is_err() {
1370            self.control_handle.shutdown();
1371        }
1372        self.drop_without_shutdown();
1373        _result
1374    }
1375
1376    /// Similar to "send" but does not shutdown the channel if an error occurs.
1377    pub fn send_no_shutdown_on_err(
1378        self,
1379        mut result: Result<&HidInfo, i32>,
1380    ) -> Result<(), fidl::Error> {
1381        let _result = self.send_raw(result);
1382        self.drop_without_shutdown();
1383        _result
1384    }
1385
1386    fn send_raw(&self, mut result: Result<&HidInfo, i32>) -> Result<(), fidl::Error> {
1387        self.control_handle.inner.send::<fidl::encoding::ResultType<HidbusQueryResponse, i32>>(
1388            result.map(|info| (info,)),
1389            self.tx_id,
1390            0x23eb61f83d06efa9,
1391            fidl::encoding::DynamicFlags::empty(),
1392        )
1393    }
1394}
1395
1396#[must_use = "FIDL methods require a response to be sent"]
1397#[derive(Debug)]
1398pub struct HidbusStartResponder {
1399    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1400    tx_id: u32,
1401}
1402
1403/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1404/// if the responder is dropped without sending a response, so that the client
1405/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1406impl std::ops::Drop for HidbusStartResponder {
1407    fn drop(&mut self) {
1408        self.control_handle.shutdown();
1409        // Safety: drops once, never accessed again
1410        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1411    }
1412}
1413
1414impl fidl::endpoints::Responder for HidbusStartResponder {
1415    type ControlHandle = HidbusControlHandle;
1416
1417    fn control_handle(&self) -> &HidbusControlHandle {
1418        &self.control_handle
1419    }
1420
1421    fn drop_without_shutdown(mut self) {
1422        // Safety: drops once, never accessed again due to mem::forget
1423        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1424        // Prevent Drop from running (which would shut down the channel)
1425        std::mem::forget(self);
1426    }
1427}
1428
1429impl HidbusStartResponder {
1430    /// Sends a response to the FIDL transaction.
1431    ///
1432    /// Sets the channel to shutdown if an error occurs.
1433    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1434        let _result = self.send_raw(result);
1435        if _result.is_err() {
1436            self.control_handle.shutdown();
1437        }
1438        self.drop_without_shutdown();
1439        _result
1440    }
1441
1442    /// Similar to "send" but does not shutdown the channel if an error occurs.
1443    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1444        let _result = self.send_raw(result);
1445        self.drop_without_shutdown();
1446        _result
1447    }
1448
1449    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1450        self.control_handle
1451            .inner
1452            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1453                result,
1454                self.tx_id,
1455                0x1ba15adf96bade4a,
1456                fidl::encoding::DynamicFlags::empty(),
1457            )
1458    }
1459}
1460
1461#[must_use = "FIDL methods require a response to be sent"]
1462#[derive(Debug)]
1463pub struct HidbusStopResponder {
1464    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1465    tx_id: u32,
1466}
1467
1468/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1469/// if the responder is dropped without sending a response, so that the client
1470/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1471impl std::ops::Drop for HidbusStopResponder {
1472    fn drop(&mut self) {
1473        self.control_handle.shutdown();
1474        // Safety: drops once, never accessed again
1475        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1476    }
1477}
1478
1479impl fidl::endpoints::Responder for HidbusStopResponder {
1480    type ControlHandle = HidbusControlHandle;
1481
1482    fn control_handle(&self) -> &HidbusControlHandle {
1483        &self.control_handle
1484    }
1485
1486    fn drop_without_shutdown(mut self) {
1487        // Safety: drops once, never accessed again due to mem::forget
1488        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1489        // Prevent Drop from running (which would shut down the channel)
1490        std::mem::forget(self);
1491    }
1492}
1493
1494impl HidbusStopResponder {
1495    /// Sends a response to the FIDL transaction.
1496    ///
1497    /// Sets the channel to shutdown if an error occurs.
1498    pub fn send(self) -> Result<(), fidl::Error> {
1499        let _result = self.send_raw();
1500        if _result.is_err() {
1501            self.control_handle.shutdown();
1502        }
1503        self.drop_without_shutdown();
1504        _result
1505    }
1506
1507    /// Similar to "send" but does not shutdown the channel if an error occurs.
1508    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1509        let _result = self.send_raw();
1510        self.drop_without_shutdown();
1511        _result
1512    }
1513
1514    fn send_raw(&self) -> Result<(), fidl::Error> {
1515        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1516            (),
1517            self.tx_id,
1518            0x61b973ecd69cfff8,
1519            fidl::encoding::DynamicFlags::empty(),
1520        )
1521    }
1522}
1523
1524#[must_use = "FIDL methods require a response to be sent"]
1525#[derive(Debug)]
1526pub struct HidbusGetDescriptorResponder {
1527    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1528    tx_id: u32,
1529}
1530
1531/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1532/// if the responder is dropped without sending a response, so that the client
1533/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1534impl std::ops::Drop for HidbusGetDescriptorResponder {
1535    fn drop(&mut self) {
1536        self.control_handle.shutdown();
1537        // Safety: drops once, never accessed again
1538        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1539    }
1540}
1541
1542impl fidl::endpoints::Responder for HidbusGetDescriptorResponder {
1543    type ControlHandle = HidbusControlHandle;
1544
1545    fn control_handle(&self) -> &HidbusControlHandle {
1546        &self.control_handle
1547    }
1548
1549    fn drop_without_shutdown(mut self) {
1550        // Safety: drops once, never accessed again due to mem::forget
1551        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1552        // Prevent Drop from running (which would shut down the channel)
1553        std::mem::forget(self);
1554    }
1555}
1556
1557impl HidbusGetDescriptorResponder {
1558    /// Sends a response to the FIDL transaction.
1559    ///
1560    /// Sets the channel to shutdown if an error occurs.
1561    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1562        let _result = self.send_raw(result);
1563        if _result.is_err() {
1564            self.control_handle.shutdown();
1565        }
1566        self.drop_without_shutdown();
1567        _result
1568    }
1569
1570    /// Similar to "send" but does not shutdown the channel if an error occurs.
1571    pub fn send_no_shutdown_on_err(
1572        self,
1573        mut result: Result<&[u8], i32>,
1574    ) -> Result<(), fidl::Error> {
1575        let _result = self.send_raw(result);
1576        self.drop_without_shutdown();
1577        _result
1578    }
1579
1580    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1581        self.control_handle
1582            .inner
1583            .send::<fidl::encoding::ResultType<HidbusGetDescriptorResponse, i32>>(
1584                result.map(|data| (data,)),
1585                self.tx_id,
1586                0x29343a1289ceb2e5,
1587                fidl::encoding::DynamicFlags::empty(),
1588            )
1589    }
1590}
1591
1592#[must_use = "FIDL methods require a response to be sent"]
1593#[derive(Debug)]
1594pub struct HidbusSetDescriptorResponder {
1595    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1596    tx_id: u32,
1597}
1598
1599/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1600/// if the responder is dropped without sending a response, so that the client
1601/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1602impl std::ops::Drop for HidbusSetDescriptorResponder {
1603    fn drop(&mut self) {
1604        self.control_handle.shutdown();
1605        // Safety: drops once, never accessed again
1606        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1607    }
1608}
1609
1610impl fidl::endpoints::Responder for HidbusSetDescriptorResponder {
1611    type ControlHandle = HidbusControlHandle;
1612
1613    fn control_handle(&self) -> &HidbusControlHandle {
1614        &self.control_handle
1615    }
1616
1617    fn drop_without_shutdown(mut self) {
1618        // Safety: drops once, never accessed again due to mem::forget
1619        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1620        // Prevent Drop from running (which would shut down the channel)
1621        std::mem::forget(self);
1622    }
1623}
1624
1625impl HidbusSetDescriptorResponder {
1626    /// Sends a response to the FIDL transaction.
1627    ///
1628    /// Sets the channel to shutdown if an error occurs.
1629    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1630        let _result = self.send_raw(result);
1631        if _result.is_err() {
1632            self.control_handle.shutdown();
1633        }
1634        self.drop_without_shutdown();
1635        _result
1636    }
1637
1638    /// Similar to "send" but does not shutdown the channel if an error occurs.
1639    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1640        let _result = self.send_raw(result);
1641        self.drop_without_shutdown();
1642        _result
1643    }
1644
1645    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1646        self.control_handle
1647            .inner
1648            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1649                result,
1650                self.tx_id,
1651                0x7567278eba076777,
1652                fidl::encoding::DynamicFlags::empty(),
1653            )
1654    }
1655}
1656
1657#[must_use = "FIDL methods require a response to be sent"]
1658#[derive(Debug)]
1659pub struct HidbusGetReportResponder {
1660    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1661    tx_id: u32,
1662}
1663
1664/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1665/// if the responder is dropped without sending a response, so that the client
1666/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1667impl std::ops::Drop for HidbusGetReportResponder {
1668    fn drop(&mut self) {
1669        self.control_handle.shutdown();
1670        // Safety: drops once, never accessed again
1671        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1672    }
1673}
1674
1675impl fidl::endpoints::Responder for HidbusGetReportResponder {
1676    type ControlHandle = HidbusControlHandle;
1677
1678    fn control_handle(&self) -> &HidbusControlHandle {
1679        &self.control_handle
1680    }
1681
1682    fn drop_without_shutdown(mut self) {
1683        // Safety: drops once, never accessed again due to mem::forget
1684        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1685        // Prevent Drop from running (which would shut down the channel)
1686        std::mem::forget(self);
1687    }
1688}
1689
1690impl HidbusGetReportResponder {
1691    /// Sends a response to the FIDL transaction.
1692    ///
1693    /// Sets the channel to shutdown if an error occurs.
1694    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1695        let _result = self.send_raw(result);
1696        if _result.is_err() {
1697            self.control_handle.shutdown();
1698        }
1699        self.drop_without_shutdown();
1700        _result
1701    }
1702
1703    /// Similar to "send" but does not shutdown the channel if an error occurs.
1704    pub fn send_no_shutdown_on_err(
1705        self,
1706        mut result: Result<&[u8], i32>,
1707    ) -> Result<(), fidl::Error> {
1708        let _result = self.send_raw(result);
1709        self.drop_without_shutdown();
1710        _result
1711    }
1712
1713    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1714        self.control_handle.inner.send::<fidl::encoding::ResultType<HidbusGetReportResponse, i32>>(
1715            result.map(|data| (data,)),
1716            self.tx_id,
1717            0x69b5538a28dc472c,
1718            fidl::encoding::DynamicFlags::empty(),
1719        )
1720    }
1721}
1722
1723#[must_use = "FIDL methods require a response to be sent"]
1724#[derive(Debug)]
1725pub struct HidbusSetReportResponder {
1726    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1727    tx_id: u32,
1728}
1729
1730/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1731/// if the responder is dropped without sending a response, so that the client
1732/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1733impl std::ops::Drop for HidbusSetReportResponder {
1734    fn drop(&mut self) {
1735        self.control_handle.shutdown();
1736        // Safety: drops once, never accessed again
1737        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1738    }
1739}
1740
1741impl fidl::endpoints::Responder for HidbusSetReportResponder {
1742    type ControlHandle = HidbusControlHandle;
1743
1744    fn control_handle(&self) -> &HidbusControlHandle {
1745        &self.control_handle
1746    }
1747
1748    fn drop_without_shutdown(mut self) {
1749        // Safety: drops once, never accessed again due to mem::forget
1750        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1751        // Prevent Drop from running (which would shut down the channel)
1752        std::mem::forget(self);
1753    }
1754}
1755
1756impl HidbusSetReportResponder {
1757    /// Sends a response to the FIDL transaction.
1758    ///
1759    /// Sets the channel to shutdown if an error occurs.
1760    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1761        let _result = self.send_raw(result);
1762        if _result.is_err() {
1763            self.control_handle.shutdown();
1764        }
1765        self.drop_without_shutdown();
1766        _result
1767    }
1768
1769    /// Similar to "send" but does not shutdown the channel if an error occurs.
1770    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1771        let _result = self.send_raw(result);
1772        self.drop_without_shutdown();
1773        _result
1774    }
1775
1776    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1777        self.control_handle
1778            .inner
1779            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1780                result,
1781                self.tx_id,
1782                0x1172863081673c55,
1783                fidl::encoding::DynamicFlags::empty(),
1784            )
1785    }
1786}
1787
1788#[must_use = "FIDL methods require a response to be sent"]
1789#[derive(Debug)]
1790pub struct HidbusGetIdleResponder {
1791    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1792    tx_id: u32,
1793}
1794
1795/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1796/// if the responder is dropped without sending a response, so that the client
1797/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1798impl std::ops::Drop for HidbusGetIdleResponder {
1799    fn drop(&mut self) {
1800        self.control_handle.shutdown();
1801        // Safety: drops once, never accessed again
1802        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1803    }
1804}
1805
1806impl fidl::endpoints::Responder for HidbusGetIdleResponder {
1807    type ControlHandle = HidbusControlHandle;
1808
1809    fn control_handle(&self) -> &HidbusControlHandle {
1810        &self.control_handle
1811    }
1812
1813    fn drop_without_shutdown(mut self) {
1814        // Safety: drops once, never accessed again due to mem::forget
1815        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1816        // Prevent Drop from running (which would shut down the channel)
1817        std::mem::forget(self);
1818    }
1819}
1820
1821impl HidbusGetIdleResponder {
1822    /// Sends a response to the FIDL transaction.
1823    ///
1824    /// Sets the channel to shutdown if an error occurs.
1825    pub fn send(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1826        let _result = self.send_raw(result);
1827        if _result.is_err() {
1828            self.control_handle.shutdown();
1829        }
1830        self.drop_without_shutdown();
1831        _result
1832    }
1833
1834    /// Similar to "send" but does not shutdown the channel if an error occurs.
1835    pub fn send_no_shutdown_on_err(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1836        let _result = self.send_raw(result);
1837        self.drop_without_shutdown();
1838        _result
1839    }
1840
1841    fn send_raw(&self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1842        self.control_handle.inner.send::<fidl::encoding::ResultType<HidbusGetIdleResponse, i32>>(
1843            result.map(|duration| (duration,)),
1844            self.tx_id,
1845            0xa95c2c504d9aa0b,
1846            fidl::encoding::DynamicFlags::empty(),
1847        )
1848    }
1849}
1850
1851#[must_use = "FIDL methods require a response to be sent"]
1852#[derive(Debug)]
1853pub struct HidbusSetIdleResponder {
1854    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1855    tx_id: u32,
1856}
1857
1858/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1859/// if the responder is dropped without sending a response, so that the client
1860/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1861impl std::ops::Drop for HidbusSetIdleResponder {
1862    fn drop(&mut self) {
1863        self.control_handle.shutdown();
1864        // Safety: drops once, never accessed again
1865        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1866    }
1867}
1868
1869impl fidl::endpoints::Responder for HidbusSetIdleResponder {
1870    type ControlHandle = HidbusControlHandle;
1871
1872    fn control_handle(&self) -> &HidbusControlHandle {
1873        &self.control_handle
1874    }
1875
1876    fn drop_without_shutdown(mut self) {
1877        // Safety: drops once, never accessed again due to mem::forget
1878        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1879        // Prevent Drop from running (which would shut down the channel)
1880        std::mem::forget(self);
1881    }
1882}
1883
1884impl HidbusSetIdleResponder {
1885    /// Sends a response to the FIDL transaction.
1886    ///
1887    /// Sets the channel to shutdown if an error occurs.
1888    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1889        let _result = self.send_raw(result);
1890        if _result.is_err() {
1891            self.control_handle.shutdown();
1892        }
1893        self.drop_without_shutdown();
1894        _result
1895    }
1896
1897    /// Similar to "send" but does not shutdown the channel if an error occurs.
1898    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1899        let _result = self.send_raw(result);
1900        self.drop_without_shutdown();
1901        _result
1902    }
1903
1904    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1905        self.control_handle
1906            .inner
1907            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1908                result,
1909                self.tx_id,
1910                0x7c387cbaa4c09b3c,
1911                fidl::encoding::DynamicFlags::empty(),
1912            )
1913    }
1914}
1915
1916#[must_use = "FIDL methods require a response to be sent"]
1917#[derive(Debug)]
1918pub struct HidbusGetProtocolResponder {
1919    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1920    tx_id: u32,
1921}
1922
1923/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1924/// if the responder is dropped without sending a response, so that the client
1925/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1926impl std::ops::Drop for HidbusGetProtocolResponder {
1927    fn drop(&mut self) {
1928        self.control_handle.shutdown();
1929        // Safety: drops once, never accessed again
1930        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1931    }
1932}
1933
1934impl fidl::endpoints::Responder for HidbusGetProtocolResponder {
1935    type ControlHandle = HidbusControlHandle;
1936
1937    fn control_handle(&self) -> &HidbusControlHandle {
1938        &self.control_handle
1939    }
1940
1941    fn drop_without_shutdown(mut self) {
1942        // Safety: drops once, never accessed again due to mem::forget
1943        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1944        // Prevent Drop from running (which would shut down the channel)
1945        std::mem::forget(self);
1946    }
1947}
1948
1949impl HidbusGetProtocolResponder {
1950    /// Sends a response to the FIDL transaction.
1951    ///
1952    /// Sets the channel to shutdown if an error occurs.
1953    pub fn send(self, mut result: Result<HidProtocol, i32>) -> Result<(), fidl::Error> {
1954        let _result = self.send_raw(result);
1955        if _result.is_err() {
1956            self.control_handle.shutdown();
1957        }
1958        self.drop_without_shutdown();
1959        _result
1960    }
1961
1962    /// Similar to "send" but does not shutdown the channel if an error occurs.
1963    pub fn send_no_shutdown_on_err(
1964        self,
1965        mut result: Result<HidProtocol, i32>,
1966    ) -> Result<(), fidl::Error> {
1967        let _result = self.send_raw(result);
1968        self.drop_without_shutdown();
1969        _result
1970    }
1971
1972    fn send_raw(&self, mut result: Result<HidProtocol, i32>) -> Result<(), fidl::Error> {
1973        self.control_handle
1974            .inner
1975            .send::<fidl::encoding::ResultType<HidbusGetProtocolResponse, i32>>(
1976                result.map(|protocol| (protocol,)),
1977                self.tx_id,
1978                0x3ec61a9b2d5c50eb,
1979                fidl::encoding::DynamicFlags::empty(),
1980            )
1981    }
1982}
1983
1984#[must_use = "FIDL methods require a response to be sent"]
1985#[derive(Debug)]
1986pub struct HidbusSetProtocolResponder {
1987    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1988    tx_id: u32,
1989}
1990
1991/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1992/// if the responder is dropped without sending a response, so that the client
1993/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1994impl std::ops::Drop for HidbusSetProtocolResponder {
1995    fn drop(&mut self) {
1996        self.control_handle.shutdown();
1997        // Safety: drops once, never accessed again
1998        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1999    }
2000}
2001
2002impl fidl::endpoints::Responder for HidbusSetProtocolResponder {
2003    type ControlHandle = HidbusControlHandle;
2004
2005    fn control_handle(&self) -> &HidbusControlHandle {
2006        &self.control_handle
2007    }
2008
2009    fn drop_without_shutdown(mut self) {
2010        // Safety: drops once, never accessed again due to mem::forget
2011        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2012        // Prevent Drop from running (which would shut down the channel)
2013        std::mem::forget(self);
2014    }
2015}
2016
2017impl HidbusSetProtocolResponder {
2018    /// Sends a response to the FIDL transaction.
2019    ///
2020    /// Sets the channel to shutdown if an error occurs.
2021    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2022        let _result = self.send_raw(result);
2023        if _result.is_err() {
2024            self.control_handle.shutdown();
2025        }
2026        self.drop_without_shutdown();
2027        _result
2028    }
2029
2030    /// Similar to "send" but does not shutdown the channel if an error occurs.
2031    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2032        let _result = self.send_raw(result);
2033        self.drop_without_shutdown();
2034        _result
2035    }
2036
2037    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2038        self.control_handle
2039            .inner
2040            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2041                result,
2042                self.tx_id,
2043                0x1655cdfd0f316b0b,
2044                fidl::encoding::DynamicFlags::empty(),
2045            )
2046    }
2047}
2048
2049#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2050pub struct ServiceMarker;
2051
2052#[cfg(target_os = "fuchsia")]
2053impl fidl::endpoints::ServiceMarker for ServiceMarker {
2054    type Proxy = ServiceProxy;
2055    type Request = ServiceRequest;
2056    const SERVICE_NAME: &'static str = "fuchsia.hardware.hidbus.Service";
2057}
2058
2059/// A request for one of the member protocols of Service.
2060///
2061#[cfg(target_os = "fuchsia")]
2062pub enum ServiceRequest {
2063    Device(HidbusRequestStream),
2064}
2065
2066#[cfg(target_os = "fuchsia")]
2067impl fidl::endpoints::ServiceRequest for ServiceRequest {
2068    type Service = ServiceMarker;
2069
2070    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2071        match name {
2072            "device" => Self::Device(
2073                <HidbusRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2074            ),
2075            _ => panic!("no such member protocol name for service Service"),
2076        }
2077    }
2078
2079    fn member_names() -> &'static [&'static str] {
2080        &["device"]
2081    }
2082}
2083#[cfg(target_os = "fuchsia")]
2084pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2085
2086#[cfg(target_os = "fuchsia")]
2087impl fidl::endpoints::ServiceProxy for ServiceProxy {
2088    type Service = ServiceMarker;
2089
2090    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2091        Self(opener)
2092    }
2093}
2094
2095#[cfg(target_os = "fuchsia")]
2096impl ServiceProxy {
2097    pub fn connect_to_device(&self) -> Result<HidbusProxy, fidl::Error> {
2098        let (proxy, server_end) = fidl::endpoints::create_proxy::<HidbusMarker>();
2099        self.connect_channel_to_device(server_end)?;
2100        Ok(proxy)
2101    }
2102
2103    /// Like `connect_to_device`, but returns a sync proxy.
2104    /// See [`Self::connect_to_device`] for more details.
2105    pub fn connect_to_device_sync(&self) -> Result<HidbusSynchronousProxy, fidl::Error> {
2106        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<HidbusMarker>();
2107        self.connect_channel_to_device(server_end)?;
2108        Ok(proxy)
2109    }
2110
2111    /// Like `connect_to_device`, but accepts a server end.
2112    /// See [`Self::connect_to_device`] for more details.
2113    pub fn connect_channel_to_device(
2114        &self,
2115        server_end: fidl::endpoints::ServerEnd<HidbusMarker>,
2116    ) -> Result<(), fidl::Error> {
2117        self.0.open_member("device", server_end.into_channel())
2118    }
2119
2120    pub fn instance_name(&self) -> &str {
2121        self.0.instance_name()
2122    }
2123}
2124
2125mod internal {
2126    use super::*;
2127
2128    impl Report {
2129        #[inline(always)]
2130        fn max_ordinal_present(&self) -> u64 {
2131            if let Some(_) = self.wake_lease {
2132                return 3;
2133            }
2134            if let Some(_) = self.timestamp {
2135                return 2;
2136            }
2137            if let Some(_) = self.buf {
2138                return 1;
2139            }
2140            0
2141        }
2142    }
2143
2144    impl fidl::encoding::ResourceTypeMarker for Report {
2145        type Borrowed<'a> = &'a mut Self;
2146        fn take_or_borrow<'a>(
2147            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2148        ) -> Self::Borrowed<'a> {
2149            value
2150        }
2151    }
2152
2153    unsafe impl fidl::encoding::TypeMarker for Report {
2154        type Owned = Self;
2155
2156        #[inline(always)]
2157        fn inline_align(_context: fidl::encoding::Context) -> usize {
2158            8
2159        }
2160
2161        #[inline(always)]
2162        fn inline_size(_context: fidl::encoding::Context) -> usize {
2163            16
2164        }
2165    }
2166
2167    unsafe impl fidl::encoding::Encode<Report, fidl::encoding::DefaultFuchsiaResourceDialect>
2168        for &mut Report
2169    {
2170        unsafe fn encode(
2171            self,
2172            encoder: &mut fidl::encoding::Encoder<
2173                '_,
2174                fidl::encoding::DefaultFuchsiaResourceDialect,
2175            >,
2176            offset: usize,
2177            mut depth: fidl::encoding::Depth,
2178        ) -> fidl::Result<()> {
2179            encoder.debug_check_bounds::<Report>(offset);
2180            // Vector header
2181            let max_ordinal: u64 = self.max_ordinal_present();
2182            encoder.write_num(max_ordinal, offset);
2183            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2184            // Calling encoder.out_of_line_offset(0) is not allowed.
2185            if max_ordinal == 0 {
2186                return Ok(());
2187            }
2188            depth.increment()?;
2189            let envelope_size = 8;
2190            let bytes_len = max_ordinal as usize * envelope_size;
2191            #[allow(unused_variables)]
2192            let offset = encoder.out_of_line_offset(bytes_len);
2193            let mut _prev_end_offset: usize = 0;
2194            if 1 > max_ordinal {
2195                return Ok(());
2196            }
2197
2198            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2199            // are envelope_size bytes.
2200            let cur_offset: usize = (1 - 1) * envelope_size;
2201
2202            // Zero reserved fields.
2203            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2204
2205            // Safety:
2206            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2207            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2208            //   envelope_size bytes, there is always sufficient room.
2209            fidl::encoding::encode_in_envelope_optional::<
2210                fidl::encoding::Vector<u8, 8192>,
2211                fidl::encoding::DefaultFuchsiaResourceDialect,
2212            >(
2213                self.buf.as_ref().map(
2214                    <fidl::encoding::Vector<u8, 8192> as fidl::encoding::ValueTypeMarker>::borrow,
2215                ),
2216                encoder,
2217                offset + cur_offset,
2218                depth,
2219            )?;
2220
2221            _prev_end_offset = cur_offset + envelope_size;
2222            if 2 > max_ordinal {
2223                return Ok(());
2224            }
2225
2226            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2227            // are envelope_size bytes.
2228            let cur_offset: usize = (2 - 1) * envelope_size;
2229
2230            // Zero reserved fields.
2231            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2232
2233            // Safety:
2234            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2235            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2236            //   envelope_size bytes, there is always sufficient room.
2237            fidl::encoding::encode_in_envelope_optional::<
2238                i64,
2239                fidl::encoding::DefaultFuchsiaResourceDialect,
2240            >(
2241                self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
2242                encoder,
2243                offset + cur_offset,
2244                depth,
2245            )?;
2246
2247            _prev_end_offset = cur_offset + envelope_size;
2248            if 3 > max_ordinal {
2249                return Ok(());
2250            }
2251
2252            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2253            // are envelope_size bytes.
2254            let cur_offset: usize = (3 - 1) * envelope_size;
2255
2256            // Zero reserved fields.
2257            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2258
2259            // Safety:
2260            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2261            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2262            //   envelope_size bytes, there is always sufficient room.
2263            fidl::encoding::encode_in_envelope_optional::<
2264                fidl::encoding::HandleType<
2265                    fidl::EventPair,
2266                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2267                    2147483648,
2268                >,
2269                fidl::encoding::DefaultFuchsiaResourceDialect,
2270            >(
2271                self.wake_lease.as_mut().map(
2272                    <fidl::encoding::HandleType<
2273                        fidl::EventPair,
2274                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2275                        2147483648,
2276                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2277                ),
2278                encoder,
2279                offset + cur_offset,
2280                depth,
2281            )?;
2282
2283            _prev_end_offset = cur_offset + envelope_size;
2284
2285            Ok(())
2286        }
2287    }
2288
2289    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Report {
2290        #[inline(always)]
2291        fn new_empty() -> Self {
2292            Self::default()
2293        }
2294
2295        unsafe fn decode(
2296            &mut self,
2297            decoder: &mut fidl::encoding::Decoder<
2298                '_,
2299                fidl::encoding::DefaultFuchsiaResourceDialect,
2300            >,
2301            offset: usize,
2302            mut depth: fidl::encoding::Depth,
2303        ) -> fidl::Result<()> {
2304            decoder.debug_check_bounds::<Self>(offset);
2305            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2306                None => return Err(fidl::Error::NotNullable),
2307                Some(len) => len,
2308            };
2309            // Calling decoder.out_of_line_offset(0) is not allowed.
2310            if len == 0 {
2311                return Ok(());
2312            };
2313            depth.increment()?;
2314            let envelope_size = 8;
2315            let bytes_len = len * envelope_size;
2316            let offset = decoder.out_of_line_offset(bytes_len)?;
2317            // Decode the envelope for each type.
2318            let mut _next_ordinal_to_read = 0;
2319            let mut next_offset = offset;
2320            let end_offset = offset + bytes_len;
2321            _next_ordinal_to_read += 1;
2322            if next_offset >= end_offset {
2323                return Ok(());
2324            }
2325
2326            // Decode unknown envelopes for gaps in ordinals.
2327            while _next_ordinal_to_read < 1 {
2328                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2329                _next_ordinal_to_read += 1;
2330                next_offset += envelope_size;
2331            }
2332
2333            let next_out_of_line = decoder.next_out_of_line();
2334            let handles_before = decoder.remaining_handles();
2335            if let Some((inlined, num_bytes, num_handles)) =
2336                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2337            {
2338                let member_inline_size =
2339                    <fidl::encoding::Vector<u8, 8192> as fidl::encoding::TypeMarker>::inline_size(
2340                        decoder.context,
2341                    );
2342                if inlined != (member_inline_size <= 4) {
2343                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2344                }
2345                let inner_offset;
2346                let mut inner_depth = depth.clone();
2347                if inlined {
2348                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2349                    inner_offset = next_offset;
2350                } else {
2351                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2352                    inner_depth.increment()?;
2353                }
2354                let val_ref =
2355                self.buf.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 8192>, fidl::encoding::DefaultFuchsiaResourceDialect));
2356                fidl::decode!(fidl::encoding::Vector<u8, 8192>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2357                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2358                {
2359                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2360                }
2361                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2362                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2363                }
2364            }
2365
2366            next_offset += envelope_size;
2367            _next_ordinal_to_read += 1;
2368            if next_offset >= end_offset {
2369                return Ok(());
2370            }
2371
2372            // Decode unknown envelopes for gaps in ordinals.
2373            while _next_ordinal_to_read < 2 {
2374                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2375                _next_ordinal_to_read += 1;
2376                next_offset += envelope_size;
2377            }
2378
2379            let next_out_of_line = decoder.next_out_of_line();
2380            let handles_before = decoder.remaining_handles();
2381            if let Some((inlined, num_bytes, num_handles)) =
2382                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2383            {
2384                let member_inline_size =
2385                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2386                if inlined != (member_inline_size <= 4) {
2387                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2388                }
2389                let inner_offset;
2390                let mut inner_depth = depth.clone();
2391                if inlined {
2392                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2393                    inner_offset = next_offset;
2394                } else {
2395                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2396                    inner_depth.increment()?;
2397                }
2398                let val_ref = self.timestamp.get_or_insert_with(|| {
2399                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
2400                });
2401                fidl::decode!(
2402                    i64,
2403                    fidl::encoding::DefaultFuchsiaResourceDialect,
2404                    val_ref,
2405                    decoder,
2406                    inner_offset,
2407                    inner_depth
2408                )?;
2409                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2410                {
2411                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2412                }
2413                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2414                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2415                }
2416            }
2417
2418            next_offset += envelope_size;
2419            _next_ordinal_to_read += 1;
2420            if next_offset >= end_offset {
2421                return Ok(());
2422            }
2423
2424            // Decode unknown envelopes for gaps in ordinals.
2425            while _next_ordinal_to_read < 3 {
2426                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2427                _next_ordinal_to_read += 1;
2428                next_offset += envelope_size;
2429            }
2430
2431            let next_out_of_line = decoder.next_out_of_line();
2432            let handles_before = decoder.remaining_handles();
2433            if let Some((inlined, num_bytes, num_handles)) =
2434                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2435            {
2436                let member_inline_size = <fidl::encoding::HandleType<
2437                    fidl::EventPair,
2438                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2439                    2147483648,
2440                > as fidl::encoding::TypeMarker>::inline_size(
2441                    decoder.context
2442                );
2443                if inlined != (member_inline_size <= 4) {
2444                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2445                }
2446                let inner_offset;
2447                let mut inner_depth = depth.clone();
2448                if inlined {
2449                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2450                    inner_offset = next_offset;
2451                } else {
2452                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2453                    inner_depth.increment()?;
2454                }
2455                let val_ref =
2456                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2457                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2458                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2459                {
2460                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2461                }
2462                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2463                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2464                }
2465            }
2466
2467            next_offset += envelope_size;
2468
2469            // Decode the remaining unknown envelopes.
2470            while next_offset < end_offset {
2471                _next_ordinal_to_read += 1;
2472                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2473                next_offset += envelope_size;
2474            }
2475
2476            Ok(())
2477        }
2478    }
2479}