Skip to main content

fidl_fuchsia_hardware_hidbus/
fidl_fuchsia_hardware_hidbus.rs

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