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