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::NullableHandle {
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
1287    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1288        self.inner.shutdown_with_epitaph(status)
1289    }
1290
1291    fn is_closed(&self) -> bool {
1292        self.inner.channel().is_closed()
1293    }
1294    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1295        self.inner.channel().on_closed()
1296    }
1297
1298    #[cfg(target_os = "fuchsia")]
1299    fn signal_peer(
1300        &self,
1301        clear_mask: zx::Signals,
1302        set_mask: zx::Signals,
1303    ) -> Result<(), zx_status::Status> {
1304        use fidl::Peered;
1305        self.inner.channel().signal_peer(clear_mask, set_mask)
1306    }
1307}
1308
1309impl HidbusControlHandle {
1310    pub fn send_on_report_received(&self, mut payload: Report) -> Result<(), fidl::Error> {
1311        self.inner.send::<Report>(
1312            &mut payload,
1313            0,
1314            0x6093963f2efe1e56,
1315            fidl::encoding::DynamicFlags::empty(),
1316        )
1317    }
1318}
1319
1320#[must_use = "FIDL methods require a response to be sent"]
1321#[derive(Debug)]
1322pub struct HidbusQueryResponder {
1323    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1324    tx_id: u32,
1325}
1326
1327/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1328/// if the responder is dropped without sending a response, so that the client
1329/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1330impl std::ops::Drop for HidbusQueryResponder {
1331    fn drop(&mut self) {
1332        self.control_handle.shutdown();
1333        // Safety: drops once, never accessed again
1334        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1335    }
1336}
1337
1338impl fidl::endpoints::Responder for HidbusQueryResponder {
1339    type ControlHandle = HidbusControlHandle;
1340
1341    fn control_handle(&self) -> &HidbusControlHandle {
1342        &self.control_handle
1343    }
1344
1345    fn drop_without_shutdown(mut self) {
1346        // Safety: drops once, never accessed again due to mem::forget
1347        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1348        // Prevent Drop from running (which would shut down the channel)
1349        std::mem::forget(self);
1350    }
1351}
1352
1353impl HidbusQueryResponder {
1354    /// Sends a response to the FIDL transaction.
1355    ///
1356    /// Sets the channel to shutdown if an error occurs.
1357    pub fn send(self, mut result: Result<&HidInfo, i32>) -> Result<(), fidl::Error> {
1358        let _result = self.send_raw(result);
1359        if _result.is_err() {
1360            self.control_handle.shutdown();
1361        }
1362        self.drop_without_shutdown();
1363        _result
1364    }
1365
1366    /// Similar to "send" but does not shutdown the channel if an error occurs.
1367    pub fn send_no_shutdown_on_err(
1368        self,
1369        mut result: Result<&HidInfo, i32>,
1370    ) -> Result<(), fidl::Error> {
1371        let _result = self.send_raw(result);
1372        self.drop_without_shutdown();
1373        _result
1374    }
1375
1376    fn send_raw(&self, mut result: Result<&HidInfo, i32>) -> Result<(), fidl::Error> {
1377        self.control_handle.inner.send::<fidl::encoding::ResultType<HidbusQueryResponse, i32>>(
1378            result.map(|info| (info,)),
1379            self.tx_id,
1380            0x23eb61f83d06efa9,
1381            fidl::encoding::DynamicFlags::empty(),
1382        )
1383    }
1384}
1385
1386#[must_use = "FIDL methods require a response to be sent"]
1387#[derive(Debug)]
1388pub struct HidbusStartResponder {
1389    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1390    tx_id: u32,
1391}
1392
1393/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1394/// if the responder is dropped without sending a response, so that the client
1395/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1396impl std::ops::Drop for HidbusStartResponder {
1397    fn drop(&mut self) {
1398        self.control_handle.shutdown();
1399        // Safety: drops once, never accessed again
1400        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1401    }
1402}
1403
1404impl fidl::endpoints::Responder for HidbusStartResponder {
1405    type ControlHandle = HidbusControlHandle;
1406
1407    fn control_handle(&self) -> &HidbusControlHandle {
1408        &self.control_handle
1409    }
1410
1411    fn drop_without_shutdown(mut self) {
1412        // Safety: drops once, never accessed again due to mem::forget
1413        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1414        // Prevent Drop from running (which would shut down the channel)
1415        std::mem::forget(self);
1416    }
1417}
1418
1419impl HidbusStartResponder {
1420    /// Sends a response to the FIDL transaction.
1421    ///
1422    /// Sets the channel to shutdown if an error occurs.
1423    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1424        let _result = self.send_raw(result);
1425        if _result.is_err() {
1426            self.control_handle.shutdown();
1427        }
1428        self.drop_without_shutdown();
1429        _result
1430    }
1431
1432    /// Similar to "send" but does not shutdown the channel if an error occurs.
1433    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1434        let _result = self.send_raw(result);
1435        self.drop_without_shutdown();
1436        _result
1437    }
1438
1439    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1440        self.control_handle
1441            .inner
1442            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1443                result,
1444                self.tx_id,
1445                0x1ba15adf96bade4a,
1446                fidl::encoding::DynamicFlags::empty(),
1447            )
1448    }
1449}
1450
1451#[must_use = "FIDL methods require a response to be sent"]
1452#[derive(Debug)]
1453pub struct HidbusStopResponder {
1454    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1455    tx_id: u32,
1456}
1457
1458/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1459/// if the responder is dropped without sending a response, so that the client
1460/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1461impl std::ops::Drop for HidbusStopResponder {
1462    fn drop(&mut self) {
1463        self.control_handle.shutdown();
1464        // Safety: drops once, never accessed again
1465        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1466    }
1467}
1468
1469impl fidl::endpoints::Responder for HidbusStopResponder {
1470    type ControlHandle = HidbusControlHandle;
1471
1472    fn control_handle(&self) -> &HidbusControlHandle {
1473        &self.control_handle
1474    }
1475
1476    fn drop_without_shutdown(mut self) {
1477        // Safety: drops once, never accessed again due to mem::forget
1478        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1479        // Prevent Drop from running (which would shut down the channel)
1480        std::mem::forget(self);
1481    }
1482}
1483
1484impl HidbusStopResponder {
1485    /// Sends a response to the FIDL transaction.
1486    ///
1487    /// Sets the channel to shutdown if an error occurs.
1488    pub fn send(self) -> Result<(), fidl::Error> {
1489        let _result = self.send_raw();
1490        if _result.is_err() {
1491            self.control_handle.shutdown();
1492        }
1493        self.drop_without_shutdown();
1494        _result
1495    }
1496
1497    /// Similar to "send" but does not shutdown the channel if an error occurs.
1498    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1499        let _result = self.send_raw();
1500        self.drop_without_shutdown();
1501        _result
1502    }
1503
1504    fn send_raw(&self) -> Result<(), fidl::Error> {
1505        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1506            (),
1507            self.tx_id,
1508            0x61b973ecd69cfff8,
1509            fidl::encoding::DynamicFlags::empty(),
1510        )
1511    }
1512}
1513
1514#[must_use = "FIDL methods require a response to be sent"]
1515#[derive(Debug)]
1516pub struct HidbusGetDescriptorResponder {
1517    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1518    tx_id: u32,
1519}
1520
1521/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1522/// if the responder is dropped without sending a response, so that the client
1523/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1524impl std::ops::Drop for HidbusGetDescriptorResponder {
1525    fn drop(&mut self) {
1526        self.control_handle.shutdown();
1527        // Safety: drops once, never accessed again
1528        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1529    }
1530}
1531
1532impl fidl::endpoints::Responder for HidbusGetDescriptorResponder {
1533    type ControlHandle = HidbusControlHandle;
1534
1535    fn control_handle(&self) -> &HidbusControlHandle {
1536        &self.control_handle
1537    }
1538
1539    fn drop_without_shutdown(mut self) {
1540        // Safety: drops once, never accessed again due to mem::forget
1541        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1542        // Prevent Drop from running (which would shut down the channel)
1543        std::mem::forget(self);
1544    }
1545}
1546
1547impl HidbusGetDescriptorResponder {
1548    /// Sends a response to the FIDL transaction.
1549    ///
1550    /// Sets the channel to shutdown if an error occurs.
1551    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1552        let _result = self.send_raw(result);
1553        if _result.is_err() {
1554            self.control_handle.shutdown();
1555        }
1556        self.drop_without_shutdown();
1557        _result
1558    }
1559
1560    /// Similar to "send" but does not shutdown the channel if an error occurs.
1561    pub fn send_no_shutdown_on_err(
1562        self,
1563        mut result: Result<&[u8], i32>,
1564    ) -> Result<(), fidl::Error> {
1565        let _result = self.send_raw(result);
1566        self.drop_without_shutdown();
1567        _result
1568    }
1569
1570    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1571        self.control_handle
1572            .inner
1573            .send::<fidl::encoding::ResultType<HidbusGetDescriptorResponse, i32>>(
1574                result.map(|data| (data,)),
1575                self.tx_id,
1576                0x29343a1289ceb2e5,
1577                fidl::encoding::DynamicFlags::empty(),
1578            )
1579    }
1580}
1581
1582#[must_use = "FIDL methods require a response to be sent"]
1583#[derive(Debug)]
1584pub struct HidbusSetDescriptorResponder {
1585    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1586    tx_id: u32,
1587}
1588
1589/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1590/// if the responder is dropped without sending a response, so that the client
1591/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1592impl std::ops::Drop for HidbusSetDescriptorResponder {
1593    fn drop(&mut self) {
1594        self.control_handle.shutdown();
1595        // Safety: drops once, never accessed again
1596        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1597    }
1598}
1599
1600impl fidl::endpoints::Responder for HidbusSetDescriptorResponder {
1601    type ControlHandle = HidbusControlHandle;
1602
1603    fn control_handle(&self) -> &HidbusControlHandle {
1604        &self.control_handle
1605    }
1606
1607    fn drop_without_shutdown(mut self) {
1608        // Safety: drops once, never accessed again due to mem::forget
1609        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1610        // Prevent Drop from running (which would shut down the channel)
1611        std::mem::forget(self);
1612    }
1613}
1614
1615impl HidbusSetDescriptorResponder {
1616    /// Sends a response to the FIDL transaction.
1617    ///
1618    /// Sets the channel to shutdown if an error occurs.
1619    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1620        let _result = self.send_raw(result);
1621        if _result.is_err() {
1622            self.control_handle.shutdown();
1623        }
1624        self.drop_without_shutdown();
1625        _result
1626    }
1627
1628    /// Similar to "send" but does not shutdown the channel if an error occurs.
1629    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1630        let _result = self.send_raw(result);
1631        self.drop_without_shutdown();
1632        _result
1633    }
1634
1635    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1636        self.control_handle
1637            .inner
1638            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1639                result,
1640                self.tx_id,
1641                0x7567278eba076777,
1642                fidl::encoding::DynamicFlags::empty(),
1643            )
1644    }
1645}
1646
1647#[must_use = "FIDL methods require a response to be sent"]
1648#[derive(Debug)]
1649pub struct HidbusGetReportResponder {
1650    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1651    tx_id: u32,
1652}
1653
1654/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1655/// if the responder is dropped without sending a response, so that the client
1656/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1657impl std::ops::Drop for HidbusGetReportResponder {
1658    fn drop(&mut self) {
1659        self.control_handle.shutdown();
1660        // Safety: drops once, never accessed again
1661        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1662    }
1663}
1664
1665impl fidl::endpoints::Responder for HidbusGetReportResponder {
1666    type ControlHandle = HidbusControlHandle;
1667
1668    fn control_handle(&self) -> &HidbusControlHandle {
1669        &self.control_handle
1670    }
1671
1672    fn drop_without_shutdown(mut self) {
1673        // Safety: drops once, never accessed again due to mem::forget
1674        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1675        // Prevent Drop from running (which would shut down the channel)
1676        std::mem::forget(self);
1677    }
1678}
1679
1680impl HidbusGetReportResponder {
1681    /// Sends a response to the FIDL transaction.
1682    ///
1683    /// Sets the channel to shutdown if an error occurs.
1684    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1685        let _result = self.send_raw(result);
1686        if _result.is_err() {
1687            self.control_handle.shutdown();
1688        }
1689        self.drop_without_shutdown();
1690        _result
1691    }
1692
1693    /// Similar to "send" but does not shutdown the channel if an error occurs.
1694    pub fn send_no_shutdown_on_err(
1695        self,
1696        mut result: Result<&[u8], i32>,
1697    ) -> Result<(), fidl::Error> {
1698        let _result = self.send_raw(result);
1699        self.drop_without_shutdown();
1700        _result
1701    }
1702
1703    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1704        self.control_handle.inner.send::<fidl::encoding::ResultType<HidbusGetReportResponse, i32>>(
1705            result.map(|data| (data,)),
1706            self.tx_id,
1707            0x69b5538a28dc472c,
1708            fidl::encoding::DynamicFlags::empty(),
1709        )
1710    }
1711}
1712
1713#[must_use = "FIDL methods require a response to be sent"]
1714#[derive(Debug)]
1715pub struct HidbusSetReportResponder {
1716    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1717    tx_id: u32,
1718}
1719
1720/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1721/// if the responder is dropped without sending a response, so that the client
1722/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1723impl std::ops::Drop for HidbusSetReportResponder {
1724    fn drop(&mut self) {
1725        self.control_handle.shutdown();
1726        // Safety: drops once, never accessed again
1727        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1728    }
1729}
1730
1731impl fidl::endpoints::Responder for HidbusSetReportResponder {
1732    type ControlHandle = HidbusControlHandle;
1733
1734    fn control_handle(&self) -> &HidbusControlHandle {
1735        &self.control_handle
1736    }
1737
1738    fn drop_without_shutdown(mut self) {
1739        // Safety: drops once, never accessed again due to mem::forget
1740        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1741        // Prevent Drop from running (which would shut down the channel)
1742        std::mem::forget(self);
1743    }
1744}
1745
1746impl HidbusSetReportResponder {
1747    /// Sends a response to the FIDL transaction.
1748    ///
1749    /// Sets the channel to shutdown if an error occurs.
1750    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1751        let _result = self.send_raw(result);
1752        if _result.is_err() {
1753            self.control_handle.shutdown();
1754        }
1755        self.drop_without_shutdown();
1756        _result
1757    }
1758
1759    /// Similar to "send" but does not shutdown the channel if an error occurs.
1760    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1761        let _result = self.send_raw(result);
1762        self.drop_without_shutdown();
1763        _result
1764    }
1765
1766    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1767        self.control_handle
1768            .inner
1769            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1770                result,
1771                self.tx_id,
1772                0x1172863081673c55,
1773                fidl::encoding::DynamicFlags::empty(),
1774            )
1775    }
1776}
1777
1778#[must_use = "FIDL methods require a response to be sent"]
1779#[derive(Debug)]
1780pub struct HidbusGetIdleResponder {
1781    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1782    tx_id: u32,
1783}
1784
1785/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1786/// if the responder is dropped without sending a response, so that the client
1787/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1788impl std::ops::Drop for HidbusGetIdleResponder {
1789    fn drop(&mut self) {
1790        self.control_handle.shutdown();
1791        // Safety: drops once, never accessed again
1792        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1793    }
1794}
1795
1796impl fidl::endpoints::Responder for HidbusGetIdleResponder {
1797    type ControlHandle = HidbusControlHandle;
1798
1799    fn control_handle(&self) -> &HidbusControlHandle {
1800        &self.control_handle
1801    }
1802
1803    fn drop_without_shutdown(mut self) {
1804        // Safety: drops once, never accessed again due to mem::forget
1805        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1806        // Prevent Drop from running (which would shut down the channel)
1807        std::mem::forget(self);
1808    }
1809}
1810
1811impl HidbusGetIdleResponder {
1812    /// Sends a response to the FIDL transaction.
1813    ///
1814    /// Sets the channel to shutdown if an error occurs.
1815    pub fn send(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1816        let _result = self.send_raw(result);
1817        if _result.is_err() {
1818            self.control_handle.shutdown();
1819        }
1820        self.drop_without_shutdown();
1821        _result
1822    }
1823
1824    /// Similar to "send" but does not shutdown the channel if an error occurs.
1825    pub fn send_no_shutdown_on_err(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1826        let _result = self.send_raw(result);
1827        self.drop_without_shutdown();
1828        _result
1829    }
1830
1831    fn send_raw(&self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1832        self.control_handle.inner.send::<fidl::encoding::ResultType<HidbusGetIdleResponse, i32>>(
1833            result.map(|duration| (duration,)),
1834            self.tx_id,
1835            0xa95c2c504d9aa0b,
1836            fidl::encoding::DynamicFlags::empty(),
1837        )
1838    }
1839}
1840
1841#[must_use = "FIDL methods require a response to be sent"]
1842#[derive(Debug)]
1843pub struct HidbusSetIdleResponder {
1844    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1845    tx_id: u32,
1846}
1847
1848/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1849/// if the responder is dropped without sending a response, so that the client
1850/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1851impl std::ops::Drop for HidbusSetIdleResponder {
1852    fn drop(&mut self) {
1853        self.control_handle.shutdown();
1854        // Safety: drops once, never accessed again
1855        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1856    }
1857}
1858
1859impl fidl::endpoints::Responder for HidbusSetIdleResponder {
1860    type ControlHandle = HidbusControlHandle;
1861
1862    fn control_handle(&self) -> &HidbusControlHandle {
1863        &self.control_handle
1864    }
1865
1866    fn drop_without_shutdown(mut self) {
1867        // Safety: drops once, never accessed again due to mem::forget
1868        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1869        // Prevent Drop from running (which would shut down the channel)
1870        std::mem::forget(self);
1871    }
1872}
1873
1874impl HidbusSetIdleResponder {
1875    /// Sends a response to the FIDL transaction.
1876    ///
1877    /// Sets the channel to shutdown if an error occurs.
1878    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1879        let _result = self.send_raw(result);
1880        if _result.is_err() {
1881            self.control_handle.shutdown();
1882        }
1883        self.drop_without_shutdown();
1884        _result
1885    }
1886
1887    /// Similar to "send" but does not shutdown the channel if an error occurs.
1888    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1889        let _result = self.send_raw(result);
1890        self.drop_without_shutdown();
1891        _result
1892    }
1893
1894    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1895        self.control_handle
1896            .inner
1897            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1898                result,
1899                self.tx_id,
1900                0x7c387cbaa4c09b3c,
1901                fidl::encoding::DynamicFlags::empty(),
1902            )
1903    }
1904}
1905
1906#[must_use = "FIDL methods require a response to be sent"]
1907#[derive(Debug)]
1908pub struct HidbusGetProtocolResponder {
1909    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1910    tx_id: u32,
1911}
1912
1913/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1914/// if the responder is dropped without sending a response, so that the client
1915/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1916impl std::ops::Drop for HidbusGetProtocolResponder {
1917    fn drop(&mut self) {
1918        self.control_handle.shutdown();
1919        // Safety: drops once, never accessed again
1920        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1921    }
1922}
1923
1924impl fidl::endpoints::Responder for HidbusGetProtocolResponder {
1925    type ControlHandle = HidbusControlHandle;
1926
1927    fn control_handle(&self) -> &HidbusControlHandle {
1928        &self.control_handle
1929    }
1930
1931    fn drop_without_shutdown(mut self) {
1932        // Safety: drops once, never accessed again due to mem::forget
1933        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1934        // Prevent Drop from running (which would shut down the channel)
1935        std::mem::forget(self);
1936    }
1937}
1938
1939impl HidbusGetProtocolResponder {
1940    /// Sends a response to the FIDL transaction.
1941    ///
1942    /// Sets the channel to shutdown if an error occurs.
1943    pub fn send(self, mut result: Result<HidProtocol, i32>) -> Result<(), fidl::Error> {
1944        let _result = self.send_raw(result);
1945        if _result.is_err() {
1946            self.control_handle.shutdown();
1947        }
1948        self.drop_without_shutdown();
1949        _result
1950    }
1951
1952    /// Similar to "send" but does not shutdown the channel if an error occurs.
1953    pub fn send_no_shutdown_on_err(
1954        self,
1955        mut result: Result<HidProtocol, i32>,
1956    ) -> Result<(), fidl::Error> {
1957        let _result = self.send_raw(result);
1958        self.drop_without_shutdown();
1959        _result
1960    }
1961
1962    fn send_raw(&self, mut result: Result<HidProtocol, i32>) -> Result<(), fidl::Error> {
1963        self.control_handle
1964            .inner
1965            .send::<fidl::encoding::ResultType<HidbusGetProtocolResponse, i32>>(
1966                result.map(|protocol| (protocol,)),
1967                self.tx_id,
1968                0x3ec61a9b2d5c50eb,
1969                fidl::encoding::DynamicFlags::empty(),
1970            )
1971    }
1972}
1973
1974#[must_use = "FIDL methods require a response to be sent"]
1975#[derive(Debug)]
1976pub struct HidbusSetProtocolResponder {
1977    control_handle: std::mem::ManuallyDrop<HidbusControlHandle>,
1978    tx_id: u32,
1979}
1980
1981/// Set the the channel to be shutdown (see [`HidbusControlHandle::shutdown`])
1982/// if the responder is dropped without sending a response, so that the client
1983/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1984impl std::ops::Drop for HidbusSetProtocolResponder {
1985    fn drop(&mut self) {
1986        self.control_handle.shutdown();
1987        // Safety: drops once, never accessed again
1988        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1989    }
1990}
1991
1992impl fidl::endpoints::Responder for HidbusSetProtocolResponder {
1993    type ControlHandle = HidbusControlHandle;
1994
1995    fn control_handle(&self) -> &HidbusControlHandle {
1996        &self.control_handle
1997    }
1998
1999    fn drop_without_shutdown(mut self) {
2000        // Safety: drops once, never accessed again due to mem::forget
2001        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2002        // Prevent Drop from running (which would shut down the channel)
2003        std::mem::forget(self);
2004    }
2005}
2006
2007impl HidbusSetProtocolResponder {
2008    /// Sends a response to the FIDL transaction.
2009    ///
2010    /// Sets the channel to shutdown if an error occurs.
2011    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2012        let _result = self.send_raw(result);
2013        if _result.is_err() {
2014            self.control_handle.shutdown();
2015        }
2016        self.drop_without_shutdown();
2017        _result
2018    }
2019
2020    /// Similar to "send" but does not shutdown the channel if an error occurs.
2021    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2022        let _result = self.send_raw(result);
2023        self.drop_without_shutdown();
2024        _result
2025    }
2026
2027    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2028        self.control_handle
2029            .inner
2030            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2031                result,
2032                self.tx_id,
2033                0x1655cdfd0f316b0b,
2034                fidl::encoding::DynamicFlags::empty(),
2035            )
2036    }
2037}
2038
2039#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2040pub struct ServiceMarker;
2041
2042#[cfg(target_os = "fuchsia")]
2043impl fidl::endpoints::ServiceMarker for ServiceMarker {
2044    type Proxy = ServiceProxy;
2045    type Request = ServiceRequest;
2046    const SERVICE_NAME: &'static str = "fuchsia.hardware.hidbus.Service";
2047}
2048
2049/// A request for one of the member protocols of Service.
2050///
2051#[cfg(target_os = "fuchsia")]
2052pub enum ServiceRequest {
2053    Device(HidbusRequestStream),
2054}
2055
2056#[cfg(target_os = "fuchsia")]
2057impl fidl::endpoints::ServiceRequest for ServiceRequest {
2058    type Service = ServiceMarker;
2059
2060    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2061        match name {
2062            "device" => Self::Device(
2063                <HidbusRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2064            ),
2065            _ => panic!("no such member protocol name for service Service"),
2066        }
2067    }
2068
2069    fn member_names() -> &'static [&'static str] {
2070        &["device"]
2071    }
2072}
2073#[cfg(target_os = "fuchsia")]
2074pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2075
2076#[cfg(target_os = "fuchsia")]
2077impl fidl::endpoints::ServiceProxy for ServiceProxy {
2078    type Service = ServiceMarker;
2079
2080    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2081        Self(opener)
2082    }
2083}
2084
2085#[cfg(target_os = "fuchsia")]
2086impl ServiceProxy {
2087    pub fn connect_to_device(&self) -> Result<HidbusProxy, fidl::Error> {
2088        let (proxy, server_end) = fidl::endpoints::create_proxy::<HidbusMarker>();
2089        self.connect_channel_to_device(server_end)?;
2090        Ok(proxy)
2091    }
2092
2093    /// Like `connect_to_device`, but returns a sync proxy.
2094    /// See [`Self::connect_to_device`] for more details.
2095    pub fn connect_to_device_sync(&self) -> Result<HidbusSynchronousProxy, fidl::Error> {
2096        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<HidbusMarker>();
2097        self.connect_channel_to_device(server_end)?;
2098        Ok(proxy)
2099    }
2100
2101    /// Like `connect_to_device`, but accepts a server end.
2102    /// See [`Self::connect_to_device`] for more details.
2103    pub fn connect_channel_to_device(
2104        &self,
2105        server_end: fidl::endpoints::ServerEnd<HidbusMarker>,
2106    ) -> Result<(), fidl::Error> {
2107        self.0.open_member("device", server_end.into_channel())
2108    }
2109
2110    pub fn instance_name(&self) -> &str {
2111        self.0.instance_name()
2112    }
2113}
2114
2115mod internal {
2116    use super::*;
2117
2118    impl Report {
2119        #[inline(always)]
2120        fn max_ordinal_present(&self) -> u64 {
2121            if let Some(_) = self.wake_lease {
2122                return 3;
2123            }
2124            if let Some(_) = self.timestamp {
2125                return 2;
2126            }
2127            if let Some(_) = self.buf {
2128                return 1;
2129            }
2130            0
2131        }
2132    }
2133
2134    impl fidl::encoding::ResourceTypeMarker for Report {
2135        type Borrowed<'a> = &'a mut Self;
2136        fn take_or_borrow<'a>(
2137            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2138        ) -> Self::Borrowed<'a> {
2139            value
2140        }
2141    }
2142
2143    unsafe impl fidl::encoding::TypeMarker for Report {
2144        type Owned = Self;
2145
2146        #[inline(always)]
2147        fn inline_align(_context: fidl::encoding::Context) -> usize {
2148            8
2149        }
2150
2151        #[inline(always)]
2152        fn inline_size(_context: fidl::encoding::Context) -> usize {
2153            16
2154        }
2155    }
2156
2157    unsafe impl fidl::encoding::Encode<Report, fidl::encoding::DefaultFuchsiaResourceDialect>
2158        for &mut Report
2159    {
2160        unsafe fn encode(
2161            self,
2162            encoder: &mut fidl::encoding::Encoder<
2163                '_,
2164                fidl::encoding::DefaultFuchsiaResourceDialect,
2165            >,
2166            offset: usize,
2167            mut depth: fidl::encoding::Depth,
2168        ) -> fidl::Result<()> {
2169            encoder.debug_check_bounds::<Report>(offset);
2170            // Vector header
2171            let max_ordinal: u64 = self.max_ordinal_present();
2172            encoder.write_num(max_ordinal, offset);
2173            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2174            // Calling encoder.out_of_line_offset(0) is not allowed.
2175            if max_ordinal == 0 {
2176                return Ok(());
2177            }
2178            depth.increment()?;
2179            let envelope_size = 8;
2180            let bytes_len = max_ordinal as usize * envelope_size;
2181            #[allow(unused_variables)]
2182            let offset = encoder.out_of_line_offset(bytes_len);
2183            let mut _prev_end_offset: usize = 0;
2184            if 1 > max_ordinal {
2185                return Ok(());
2186            }
2187
2188            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2189            // are envelope_size bytes.
2190            let cur_offset: usize = (1 - 1) * envelope_size;
2191
2192            // Zero reserved fields.
2193            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2194
2195            // Safety:
2196            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2197            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2198            //   envelope_size bytes, there is always sufficient room.
2199            fidl::encoding::encode_in_envelope_optional::<
2200                fidl::encoding::Vector<u8, 8192>,
2201                fidl::encoding::DefaultFuchsiaResourceDialect,
2202            >(
2203                self.buf.as_ref().map(
2204                    <fidl::encoding::Vector<u8, 8192> as fidl::encoding::ValueTypeMarker>::borrow,
2205                ),
2206                encoder,
2207                offset + cur_offset,
2208                depth,
2209            )?;
2210
2211            _prev_end_offset = cur_offset + envelope_size;
2212            if 2 > max_ordinal {
2213                return Ok(());
2214            }
2215
2216            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2217            // are envelope_size bytes.
2218            let cur_offset: usize = (2 - 1) * envelope_size;
2219
2220            // Zero reserved fields.
2221            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2222
2223            // Safety:
2224            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2225            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2226            //   envelope_size bytes, there is always sufficient room.
2227            fidl::encoding::encode_in_envelope_optional::<
2228                i64,
2229                fidl::encoding::DefaultFuchsiaResourceDialect,
2230            >(
2231                self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
2232                encoder,
2233                offset + cur_offset,
2234                depth,
2235            )?;
2236
2237            _prev_end_offset = cur_offset + envelope_size;
2238            if 3 > max_ordinal {
2239                return Ok(());
2240            }
2241
2242            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2243            // are envelope_size bytes.
2244            let cur_offset: usize = (3 - 1) * envelope_size;
2245
2246            // Zero reserved fields.
2247            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2248
2249            // Safety:
2250            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2251            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2252            //   envelope_size bytes, there is always sufficient room.
2253            fidl::encoding::encode_in_envelope_optional::<
2254                fidl::encoding::HandleType<
2255                    fidl::EventPair,
2256                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2257                    2147483648,
2258                >,
2259                fidl::encoding::DefaultFuchsiaResourceDialect,
2260            >(
2261                self.wake_lease.as_mut().map(
2262                    <fidl::encoding::HandleType<
2263                        fidl::EventPair,
2264                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2265                        2147483648,
2266                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2267                ),
2268                encoder,
2269                offset + cur_offset,
2270                depth,
2271            )?;
2272
2273            _prev_end_offset = cur_offset + envelope_size;
2274
2275            Ok(())
2276        }
2277    }
2278
2279    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Report {
2280        #[inline(always)]
2281        fn new_empty() -> Self {
2282            Self::default()
2283        }
2284
2285        unsafe fn decode(
2286            &mut self,
2287            decoder: &mut fidl::encoding::Decoder<
2288                '_,
2289                fidl::encoding::DefaultFuchsiaResourceDialect,
2290            >,
2291            offset: usize,
2292            mut depth: fidl::encoding::Depth,
2293        ) -> fidl::Result<()> {
2294            decoder.debug_check_bounds::<Self>(offset);
2295            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2296                None => return Err(fidl::Error::NotNullable),
2297                Some(len) => len,
2298            };
2299            // Calling decoder.out_of_line_offset(0) is not allowed.
2300            if len == 0 {
2301                return Ok(());
2302            };
2303            depth.increment()?;
2304            let envelope_size = 8;
2305            let bytes_len = len * envelope_size;
2306            let offset = decoder.out_of_line_offset(bytes_len)?;
2307            // Decode the envelope for each type.
2308            let mut _next_ordinal_to_read = 0;
2309            let mut next_offset = offset;
2310            let end_offset = offset + bytes_len;
2311            _next_ordinal_to_read += 1;
2312            if next_offset >= end_offset {
2313                return Ok(());
2314            }
2315
2316            // Decode unknown envelopes for gaps in ordinals.
2317            while _next_ordinal_to_read < 1 {
2318                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2319                _next_ordinal_to_read += 1;
2320                next_offset += envelope_size;
2321            }
2322
2323            let next_out_of_line = decoder.next_out_of_line();
2324            let handles_before = decoder.remaining_handles();
2325            if let Some((inlined, num_bytes, num_handles)) =
2326                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2327            {
2328                let member_inline_size =
2329                    <fidl::encoding::Vector<u8, 8192> as fidl::encoding::TypeMarker>::inline_size(
2330                        decoder.context,
2331                    );
2332                if inlined != (member_inline_size <= 4) {
2333                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2334                }
2335                let inner_offset;
2336                let mut inner_depth = depth.clone();
2337                if inlined {
2338                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2339                    inner_offset = next_offset;
2340                } else {
2341                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2342                    inner_depth.increment()?;
2343                }
2344                let val_ref =
2345                self.buf.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 8192>, fidl::encoding::DefaultFuchsiaResourceDialect));
2346                fidl::decode!(fidl::encoding::Vector<u8, 8192>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2347                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2348                {
2349                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2350                }
2351                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2352                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2353                }
2354            }
2355
2356            next_offset += envelope_size;
2357            _next_ordinal_to_read += 1;
2358            if next_offset >= end_offset {
2359                return Ok(());
2360            }
2361
2362            // Decode unknown envelopes for gaps in ordinals.
2363            while _next_ordinal_to_read < 2 {
2364                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2365                _next_ordinal_to_read += 1;
2366                next_offset += envelope_size;
2367            }
2368
2369            let next_out_of_line = decoder.next_out_of_line();
2370            let handles_before = decoder.remaining_handles();
2371            if let Some((inlined, num_bytes, num_handles)) =
2372                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2373            {
2374                let member_inline_size =
2375                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2376                if inlined != (member_inline_size <= 4) {
2377                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2378                }
2379                let inner_offset;
2380                let mut inner_depth = depth.clone();
2381                if inlined {
2382                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2383                    inner_offset = next_offset;
2384                } else {
2385                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2386                    inner_depth.increment()?;
2387                }
2388                let val_ref = self.timestamp.get_or_insert_with(|| {
2389                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
2390                });
2391                fidl::decode!(
2392                    i64,
2393                    fidl::encoding::DefaultFuchsiaResourceDialect,
2394                    val_ref,
2395                    decoder,
2396                    inner_offset,
2397                    inner_depth
2398                )?;
2399                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2400                {
2401                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2402                }
2403                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2404                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2405                }
2406            }
2407
2408            next_offset += envelope_size;
2409            _next_ordinal_to_read += 1;
2410            if next_offset >= end_offset {
2411                return Ok(());
2412            }
2413
2414            // Decode unknown envelopes for gaps in ordinals.
2415            while _next_ordinal_to_read < 3 {
2416                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2417                _next_ordinal_to_read += 1;
2418                next_offset += envelope_size;
2419            }
2420
2421            let next_out_of_line = decoder.next_out_of_line();
2422            let handles_before = decoder.remaining_handles();
2423            if let Some((inlined, num_bytes, num_handles)) =
2424                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2425            {
2426                let member_inline_size = <fidl::encoding::HandleType<
2427                    fidl::EventPair,
2428                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2429                    2147483648,
2430                > as fidl::encoding::TypeMarker>::inline_size(
2431                    decoder.context
2432                );
2433                if inlined != (member_inline_size <= 4) {
2434                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2435                }
2436                let inner_offset;
2437                let mut inner_depth = depth.clone();
2438                if inlined {
2439                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2440                    inner_offset = next_offset;
2441                } else {
2442                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2443                    inner_depth.increment()?;
2444                }
2445                let val_ref =
2446                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2447                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2448                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2449                {
2450                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2451                }
2452                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2453                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2454                }
2455            }
2456
2457            next_offset += envelope_size;
2458
2459            // Decode the remaining unknown envelopes.
2460            while next_offset < end_offset {
2461                _next_ordinal_to_read += 1;
2462                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2463                next_offset += envelope_size;
2464            }
2465
2466            Ok(())
2467        }
2468    }
2469}