fidl_fuchsia_hardware_hidbus/
fidl_fuchsia_hardware_hidbus.rs

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