Skip to main content

fidl_fuchsia_hardware_usb_device/
fidl_fuchsia_hardware_usb_device.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_usb_device__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DeviceMarker;
16
17impl fidl::endpoints::ProtocolMarker for DeviceMarker {
18    type Proxy = DeviceProxy;
19    type RequestStream = DeviceRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = DeviceSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) Device";
24}
25
26pub trait DeviceProxyInterface: Send + Sync {
27    type GetDeviceSpeedResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
28    fn r#get_device_speed(&self) -> Self::GetDeviceSpeedResponseFut;
29    type GetDeviceDescriptorResponseFut: std::future::Future<Output = Result<[u8; 18], fidl::Error>>
30        + Send;
31    fn r#get_device_descriptor(&self) -> Self::GetDeviceDescriptorResponseFut;
32    type GetConfigurationDescriptorSizeResponseFut: std::future::Future<Output = Result<(i32, u16), fidl::Error>>
33        + Send;
34    fn r#get_configuration_descriptor_size(
35        &self,
36        config: u8,
37    ) -> Self::GetConfigurationDescriptorSizeResponseFut;
38    type GetConfigurationDescriptorResponseFut: std::future::Future<Output = Result<(i32, Vec<u8>), fidl::Error>>
39        + Send;
40    fn r#get_configuration_descriptor(
41        &self,
42        config: u8,
43    ) -> Self::GetConfigurationDescriptorResponseFut;
44    type GetStringDescriptorResponseFut: std::future::Future<Output = Result<(i32, String, u16), fidl::Error>>
45        + Send;
46    fn r#get_string_descriptor(
47        &self,
48        desc_id: u8,
49        lang_id: u16,
50    ) -> Self::GetStringDescriptorResponseFut;
51    type SetInterfaceResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
52    fn r#set_interface(
53        &self,
54        interface_number: u8,
55        alt_setting: u8,
56    ) -> Self::SetInterfaceResponseFut;
57    type GetDeviceIdResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
58    fn r#get_device_id(&self) -> Self::GetDeviceIdResponseFut;
59    type GetHubDeviceIdResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
60    fn r#get_hub_device_id(&self) -> Self::GetHubDeviceIdResponseFut;
61    type GetConfigurationResponseFut: std::future::Future<Output = Result<u8, fidl::Error>> + Send;
62    fn r#get_configuration(&self) -> Self::GetConfigurationResponseFut;
63    type SetConfigurationResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
64    fn r#set_configuration(&self, configuration: u8) -> Self::SetConfigurationResponseFut;
65}
66#[derive(Debug)]
67#[cfg(target_os = "fuchsia")]
68pub struct DeviceSynchronousProxy {
69    client: fidl::client::sync::Client,
70}
71
72#[cfg(target_os = "fuchsia")]
73impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
74    type Proxy = DeviceProxy;
75    type Protocol = DeviceMarker;
76
77    fn from_channel(inner: fidl::Channel) -> Self {
78        Self::new(inner)
79    }
80
81    fn into_channel(self) -> fidl::Channel {
82        self.client.into_channel()
83    }
84
85    fn as_channel(&self) -> &fidl::Channel {
86        self.client.as_channel()
87    }
88}
89
90#[cfg(target_os = "fuchsia")]
91impl DeviceSynchronousProxy {
92    pub fn new(channel: fidl::Channel) -> Self {
93        Self { client: fidl::client::sync::Client::new(channel) }
94    }
95
96    pub fn into_channel(self) -> fidl::Channel {
97        self.client.into_channel()
98    }
99
100    /// Waits until an event arrives and returns it. It is safe for other
101    /// threads to make concurrent requests while waiting for an event.
102    pub fn wait_for_event(
103        &self,
104        deadline: zx::MonotonicInstant,
105    ) -> Result<DeviceEvent, fidl::Error> {
106        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
107    }
108
109    /// Returns the speed of the USB device as a usb_speed_t value.
110    pub fn r#get_device_speed(
111        &self,
112        ___deadline: zx::MonotonicInstant,
113    ) -> Result<u32, fidl::Error> {
114        let _response = self
115            .client
116            .send_query::<fidl::encoding::EmptyPayload, DeviceGetDeviceSpeedResponse, DeviceMarker>(
117                (),
118                0x623cd7927fb449de,
119                fidl::encoding::DynamicFlags::empty(),
120                ___deadline,
121            )?;
122        Ok(_response.speed)
123    }
124
125    /// Returns the device's USB device descriptor.
126    pub fn r#get_device_descriptor(
127        &self,
128        ___deadline: zx::MonotonicInstant,
129    ) -> Result<[u8; 18], fidl::Error> {
130        let _response = self.client.send_query::<
131            fidl::encoding::EmptyPayload,
132            DeviceGetDeviceDescriptorResponse,
133            DeviceMarker,
134        >(
135            (),
136            0x5f761371f4b9f34a,
137            fidl::encoding::DynamicFlags::empty(),
138            ___deadline,
139        )?;
140        Ok(_response.desc)
141    }
142
143    /// Returns the total size of the USB configuration descriptor for the given configuration.
144    pub fn r#get_configuration_descriptor_size(
145        &self,
146        mut config: u8,
147        ___deadline: zx::MonotonicInstant,
148    ) -> Result<(i32, u16), fidl::Error> {
149        let _response = self.client.send_query::<
150            DeviceGetConfigurationDescriptorSizeRequest,
151            DeviceGetConfigurationDescriptorSizeResponse,
152            DeviceMarker,
153        >(
154            (config,),
155            0x65912d7d5e3a07c8,
156            fidl::encoding::DynamicFlags::empty(),
157            ___deadline,
158        )?;
159        Ok((_response.s, _response.size))
160    }
161
162    /// Returns the device's USB configuration descriptor for the given configuration.
163    pub fn r#get_configuration_descriptor(
164        &self,
165        mut config: u8,
166        ___deadline: zx::MonotonicInstant,
167    ) -> Result<(i32, Vec<u8>), fidl::Error> {
168        let _response = self.client.send_query::<
169            DeviceGetConfigurationDescriptorRequest,
170            DeviceGetConfigurationDescriptorResponse,
171            DeviceMarker,
172        >(
173            (config,),
174            0x1859a4e4421d2036,
175            fidl::encoding::DynamicFlags::empty(),
176            ___deadline,
177        )?;
178        Ok((_response.s, _response.desc))
179    }
180
181    /// Fetches a string descriptor from the USB device.
182    ///
183    /// desc_id          :   The ID of the string descriptor to fetch, or 0 to fetch
184    ///                      the language table instead.
185    ///
186    /// lang_id          :   The language ID of the string descriptor to fetch.
187    ///                      If no matching language ID is present in the device's language
188    ///                      ID table, the first entry of the language ID table will
189    ///                      be substituted.
190    /// actual_lang_id   :   The actual language ID of the string fetched, or 0 for
191    ///                      the language ID table.
192    ///
193    /// The worst case size for the payload of a language ID table should be 252
194    /// bytes, meaning that a 256 byte buffer should always be enough to hold any
195    /// language ID table.
196    ///
197    /// The worst case size for a UTF-8 encoded string descriptor payload should be
198    /// 378 bytes (126 UTF-16 code units with a worst case expansion factor of 3)
199    pub fn r#get_string_descriptor(
200        &self,
201        mut desc_id: u8,
202        mut lang_id: u16,
203        ___deadline: zx::MonotonicInstant,
204    ) -> Result<(i32, String, u16), fidl::Error> {
205        let _response = self.client.send_query::<
206            DeviceGetStringDescriptorRequest,
207            DeviceGetStringDescriptorResponse,
208            DeviceMarker,
209        >(
210            (desc_id, lang_id,),
211            0x5ff601b3b6891337,
212            fidl::encoding::DynamicFlags::empty(),
213            ___deadline,
214        )?;
215        Ok((_response.s, _response.desc, _response.actual_lang_id))
216    }
217
218    /// Selects an alternate setting for an interface on a USB device.
219    pub fn r#set_interface(
220        &self,
221        mut interface_number: u8,
222        mut alt_setting: u8,
223        ___deadline: zx::MonotonicInstant,
224    ) -> Result<i32, fidl::Error> {
225        let _response = self
226            .client
227            .send_query::<DeviceSetInterfaceRequest, DeviceSetInterfaceResponse, DeviceMarker>(
228                (interface_number, alt_setting),
229                0x45348c50850b641d,
230                fidl::encoding::DynamicFlags::empty(),
231                ___deadline,
232            )?;
233        Ok(_response.s)
234    }
235
236    /// Returns an implementation specific device ID for a USB device.
237    /// For informational purposes only.
238    pub fn r#get_device_id(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
239        let _response = self
240            .client
241            .send_query::<fidl::encoding::EmptyPayload, DeviceGetDeviceIdResponse, DeviceMarker>(
242                (),
243                0x34a73eef491c2ce0,
244                fidl::encoding::DynamicFlags::empty(),
245                ___deadline,
246            )?;
247        Ok(_response.device_id)
248    }
249
250    /// Returns the implementation specific device ID for the hub that a USB device is connected to.
251    /// For informational purposes only.
252    pub fn r#get_hub_device_id(
253        &self,
254        ___deadline: zx::MonotonicInstant,
255    ) -> Result<u32, fidl::Error> {
256        let _response = self
257            .client
258            .send_query::<fidl::encoding::EmptyPayload, DeviceGetHubDeviceIdResponse, DeviceMarker>(
259                (),
260                0xce263c86f7bbbcd,
261                fidl::encoding::DynamicFlags::empty(),
262                ___deadline,
263            )?;
264        Ok(_response.hub_device_id)
265    }
266
267    /// Returns the device's current configuration.
268    pub fn r#get_configuration(
269        &self,
270        ___deadline: zx::MonotonicInstant,
271    ) -> Result<u8, fidl::Error> {
272        let _response = self.client.send_query::<
273            fidl::encoding::EmptyPayload,
274            DeviceGetConfigurationResponse,
275            DeviceMarker,
276        >(
277            (),
278            0x73f644382a2335fd,
279            fidl::encoding::DynamicFlags::empty(),
280            ___deadline,
281        )?;
282        Ok(_response.configuration)
283    }
284
285    /// Sets the device's current configuration.
286    pub fn r#set_configuration(
287        &self,
288        mut configuration: u8,
289        ___deadline: zx::MonotonicInstant,
290    ) -> Result<i32, fidl::Error> {
291        let _response = self.client.send_query::<
292            DeviceSetConfigurationRequest,
293            DeviceSetConfigurationResponse,
294            DeviceMarker,
295        >(
296            (configuration,),
297            0x12bf6e43b045ee9d,
298            fidl::encoding::DynamicFlags::empty(),
299            ___deadline,
300        )?;
301        Ok(_response.s)
302    }
303}
304
305#[cfg(target_os = "fuchsia")]
306impl From<DeviceSynchronousProxy> for zx::NullableHandle {
307    fn from(value: DeviceSynchronousProxy) -> Self {
308        value.into_channel().into()
309    }
310}
311
312#[cfg(target_os = "fuchsia")]
313impl From<fidl::Channel> for DeviceSynchronousProxy {
314    fn from(value: fidl::Channel) -> Self {
315        Self::new(value)
316    }
317}
318
319#[cfg(target_os = "fuchsia")]
320impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
321    type Protocol = DeviceMarker;
322
323    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
324        Self::new(value.into_channel())
325    }
326}
327
328#[derive(Debug, Clone)]
329pub struct DeviceProxy {
330    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
331}
332
333impl fidl::endpoints::Proxy for DeviceProxy {
334    type Protocol = DeviceMarker;
335
336    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
337        Self::new(inner)
338    }
339
340    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
341        self.client.into_channel().map_err(|client| Self { client })
342    }
343
344    fn as_channel(&self) -> &::fidl::AsyncChannel {
345        self.client.as_channel()
346    }
347}
348
349impl DeviceProxy {
350    /// Create a new Proxy for fuchsia.hardware.usb.device/Device.
351    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
352        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
353        Self { client: fidl::client::Client::new(channel, protocol_name) }
354    }
355
356    /// Get a Stream of events from the remote end of the protocol.
357    ///
358    /// # Panics
359    ///
360    /// Panics if the event stream was already taken.
361    pub fn take_event_stream(&self) -> DeviceEventStream {
362        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
363    }
364
365    /// Returns the speed of the USB device as a usb_speed_t value.
366    pub fn r#get_device_speed(
367        &self,
368    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
369        DeviceProxyInterface::r#get_device_speed(self)
370    }
371
372    /// Returns the device's USB device descriptor.
373    pub fn r#get_device_descriptor(
374        &self,
375    ) -> fidl::client::QueryResponseFut<[u8; 18], fidl::encoding::DefaultFuchsiaResourceDialect>
376    {
377        DeviceProxyInterface::r#get_device_descriptor(self)
378    }
379
380    /// Returns the total size of the USB configuration descriptor for the given configuration.
381    pub fn r#get_configuration_descriptor_size(
382        &self,
383        mut config: u8,
384    ) -> fidl::client::QueryResponseFut<(i32, u16), fidl::encoding::DefaultFuchsiaResourceDialect>
385    {
386        DeviceProxyInterface::r#get_configuration_descriptor_size(self, config)
387    }
388
389    /// Returns the device's USB configuration descriptor for the given configuration.
390    pub fn r#get_configuration_descriptor(
391        &self,
392        mut config: u8,
393    ) -> fidl::client::QueryResponseFut<(i32, Vec<u8>), fidl::encoding::DefaultFuchsiaResourceDialect>
394    {
395        DeviceProxyInterface::r#get_configuration_descriptor(self, config)
396    }
397
398    /// Fetches a string descriptor from the USB device.
399    ///
400    /// desc_id          :   The ID of the string descriptor to fetch, or 0 to fetch
401    ///                      the language table instead.
402    ///
403    /// lang_id          :   The language ID of the string descriptor to fetch.
404    ///                      If no matching language ID is present in the device's language
405    ///                      ID table, the first entry of the language ID table will
406    ///                      be substituted.
407    /// actual_lang_id   :   The actual language ID of the string fetched, or 0 for
408    ///                      the language ID table.
409    ///
410    /// The worst case size for the payload of a language ID table should be 252
411    /// bytes, meaning that a 256 byte buffer should always be enough to hold any
412    /// language ID table.
413    ///
414    /// The worst case size for a UTF-8 encoded string descriptor payload should be
415    /// 378 bytes (126 UTF-16 code units with a worst case expansion factor of 3)
416    pub fn r#get_string_descriptor(
417        &self,
418        mut desc_id: u8,
419        mut lang_id: u16,
420    ) -> fidl::client::QueryResponseFut<
421        (i32, String, u16),
422        fidl::encoding::DefaultFuchsiaResourceDialect,
423    > {
424        DeviceProxyInterface::r#get_string_descriptor(self, desc_id, lang_id)
425    }
426
427    /// Selects an alternate setting for an interface on a USB device.
428    pub fn r#set_interface(
429        &self,
430        mut interface_number: u8,
431        mut alt_setting: u8,
432    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
433        DeviceProxyInterface::r#set_interface(self, interface_number, alt_setting)
434    }
435
436    /// Returns an implementation specific device ID for a USB device.
437    /// For informational purposes only.
438    pub fn r#get_device_id(
439        &self,
440    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
441        DeviceProxyInterface::r#get_device_id(self)
442    }
443
444    /// Returns the implementation specific device ID for the hub that a USB device is connected to.
445    /// For informational purposes only.
446    pub fn r#get_hub_device_id(
447        &self,
448    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
449        DeviceProxyInterface::r#get_hub_device_id(self)
450    }
451
452    /// Returns the device's current configuration.
453    pub fn r#get_configuration(
454        &self,
455    ) -> fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect> {
456        DeviceProxyInterface::r#get_configuration(self)
457    }
458
459    /// Sets the device's current configuration.
460    pub fn r#set_configuration(
461        &self,
462        mut configuration: u8,
463    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
464        DeviceProxyInterface::r#set_configuration(self, configuration)
465    }
466}
467
468impl DeviceProxyInterface for DeviceProxy {
469    type GetDeviceSpeedResponseFut =
470        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
471    fn r#get_device_speed(&self) -> Self::GetDeviceSpeedResponseFut {
472        fn _decode(
473            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
474        ) -> Result<u32, fidl::Error> {
475            let _response = fidl::client::decode_transaction_body::<
476                DeviceGetDeviceSpeedResponse,
477                fidl::encoding::DefaultFuchsiaResourceDialect,
478                0x623cd7927fb449de,
479            >(_buf?)?;
480            Ok(_response.speed)
481        }
482        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
483            (),
484            0x623cd7927fb449de,
485            fidl::encoding::DynamicFlags::empty(),
486            _decode,
487        )
488    }
489
490    type GetDeviceDescriptorResponseFut =
491        fidl::client::QueryResponseFut<[u8; 18], fidl::encoding::DefaultFuchsiaResourceDialect>;
492    fn r#get_device_descriptor(&self) -> Self::GetDeviceDescriptorResponseFut {
493        fn _decode(
494            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
495        ) -> Result<[u8; 18], fidl::Error> {
496            let _response = fidl::client::decode_transaction_body::<
497                DeviceGetDeviceDescriptorResponse,
498                fidl::encoding::DefaultFuchsiaResourceDialect,
499                0x5f761371f4b9f34a,
500            >(_buf?)?;
501            Ok(_response.desc)
502        }
503        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, [u8; 18]>(
504            (),
505            0x5f761371f4b9f34a,
506            fidl::encoding::DynamicFlags::empty(),
507            _decode,
508        )
509    }
510
511    type GetConfigurationDescriptorSizeResponseFut =
512        fidl::client::QueryResponseFut<(i32, u16), fidl::encoding::DefaultFuchsiaResourceDialect>;
513    fn r#get_configuration_descriptor_size(
514        &self,
515        mut config: u8,
516    ) -> Self::GetConfigurationDescriptorSizeResponseFut {
517        fn _decode(
518            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
519        ) -> Result<(i32, u16), fidl::Error> {
520            let _response = fidl::client::decode_transaction_body::<
521                DeviceGetConfigurationDescriptorSizeResponse,
522                fidl::encoding::DefaultFuchsiaResourceDialect,
523                0x65912d7d5e3a07c8,
524            >(_buf?)?;
525            Ok((_response.s, _response.size))
526        }
527        self.client
528            .send_query_and_decode::<DeviceGetConfigurationDescriptorSizeRequest, (i32, u16)>(
529                (config,),
530                0x65912d7d5e3a07c8,
531                fidl::encoding::DynamicFlags::empty(),
532                _decode,
533            )
534    }
535
536    type GetConfigurationDescriptorResponseFut = fidl::client::QueryResponseFut<
537        (i32, Vec<u8>),
538        fidl::encoding::DefaultFuchsiaResourceDialect,
539    >;
540    fn r#get_configuration_descriptor(
541        &self,
542        mut config: u8,
543    ) -> Self::GetConfigurationDescriptorResponseFut {
544        fn _decode(
545            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
546        ) -> Result<(i32, Vec<u8>), fidl::Error> {
547            let _response = fidl::client::decode_transaction_body::<
548                DeviceGetConfigurationDescriptorResponse,
549                fidl::encoding::DefaultFuchsiaResourceDialect,
550                0x1859a4e4421d2036,
551            >(_buf?)?;
552            Ok((_response.s, _response.desc))
553        }
554        self.client
555            .send_query_and_decode::<DeviceGetConfigurationDescriptorRequest, (i32, Vec<u8>)>(
556                (config,),
557                0x1859a4e4421d2036,
558                fidl::encoding::DynamicFlags::empty(),
559                _decode,
560            )
561    }
562
563    type GetStringDescriptorResponseFut = fidl::client::QueryResponseFut<
564        (i32, String, u16),
565        fidl::encoding::DefaultFuchsiaResourceDialect,
566    >;
567    fn r#get_string_descriptor(
568        &self,
569        mut desc_id: u8,
570        mut lang_id: u16,
571    ) -> Self::GetStringDescriptorResponseFut {
572        fn _decode(
573            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
574        ) -> Result<(i32, String, u16), fidl::Error> {
575            let _response = fidl::client::decode_transaction_body::<
576                DeviceGetStringDescriptorResponse,
577                fidl::encoding::DefaultFuchsiaResourceDialect,
578                0x5ff601b3b6891337,
579            >(_buf?)?;
580            Ok((_response.s, _response.desc, _response.actual_lang_id))
581        }
582        self.client.send_query_and_decode::<DeviceGetStringDescriptorRequest, (i32, String, u16)>(
583            (desc_id, lang_id),
584            0x5ff601b3b6891337,
585            fidl::encoding::DynamicFlags::empty(),
586            _decode,
587        )
588    }
589
590    type SetInterfaceResponseFut =
591        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
592    fn r#set_interface(
593        &self,
594        mut interface_number: u8,
595        mut alt_setting: u8,
596    ) -> Self::SetInterfaceResponseFut {
597        fn _decode(
598            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
599        ) -> Result<i32, fidl::Error> {
600            let _response = fidl::client::decode_transaction_body::<
601                DeviceSetInterfaceResponse,
602                fidl::encoding::DefaultFuchsiaResourceDialect,
603                0x45348c50850b641d,
604            >(_buf?)?;
605            Ok(_response.s)
606        }
607        self.client.send_query_and_decode::<DeviceSetInterfaceRequest, i32>(
608            (interface_number, alt_setting),
609            0x45348c50850b641d,
610            fidl::encoding::DynamicFlags::empty(),
611            _decode,
612        )
613    }
614
615    type GetDeviceIdResponseFut =
616        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
617    fn r#get_device_id(&self) -> Self::GetDeviceIdResponseFut {
618        fn _decode(
619            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
620        ) -> Result<u32, fidl::Error> {
621            let _response = fidl::client::decode_transaction_body::<
622                DeviceGetDeviceIdResponse,
623                fidl::encoding::DefaultFuchsiaResourceDialect,
624                0x34a73eef491c2ce0,
625            >(_buf?)?;
626            Ok(_response.device_id)
627        }
628        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
629            (),
630            0x34a73eef491c2ce0,
631            fidl::encoding::DynamicFlags::empty(),
632            _decode,
633        )
634    }
635
636    type GetHubDeviceIdResponseFut =
637        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
638    fn r#get_hub_device_id(&self) -> Self::GetHubDeviceIdResponseFut {
639        fn _decode(
640            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
641        ) -> Result<u32, fidl::Error> {
642            let _response = fidl::client::decode_transaction_body::<
643                DeviceGetHubDeviceIdResponse,
644                fidl::encoding::DefaultFuchsiaResourceDialect,
645                0xce263c86f7bbbcd,
646            >(_buf?)?;
647            Ok(_response.hub_device_id)
648        }
649        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
650            (),
651            0xce263c86f7bbbcd,
652            fidl::encoding::DynamicFlags::empty(),
653            _decode,
654        )
655    }
656
657    type GetConfigurationResponseFut =
658        fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect>;
659    fn r#get_configuration(&self) -> Self::GetConfigurationResponseFut {
660        fn _decode(
661            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
662        ) -> Result<u8, fidl::Error> {
663            let _response = fidl::client::decode_transaction_body::<
664                DeviceGetConfigurationResponse,
665                fidl::encoding::DefaultFuchsiaResourceDialect,
666                0x73f644382a2335fd,
667            >(_buf?)?;
668            Ok(_response.configuration)
669        }
670        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u8>(
671            (),
672            0x73f644382a2335fd,
673            fidl::encoding::DynamicFlags::empty(),
674            _decode,
675        )
676    }
677
678    type SetConfigurationResponseFut =
679        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
680    fn r#set_configuration(&self, mut configuration: u8) -> Self::SetConfigurationResponseFut {
681        fn _decode(
682            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
683        ) -> Result<i32, fidl::Error> {
684            let _response = fidl::client::decode_transaction_body::<
685                DeviceSetConfigurationResponse,
686                fidl::encoding::DefaultFuchsiaResourceDialect,
687                0x12bf6e43b045ee9d,
688            >(_buf?)?;
689            Ok(_response.s)
690        }
691        self.client.send_query_and_decode::<DeviceSetConfigurationRequest, i32>(
692            (configuration,),
693            0x12bf6e43b045ee9d,
694            fidl::encoding::DynamicFlags::empty(),
695            _decode,
696        )
697    }
698}
699
700pub struct DeviceEventStream {
701    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
702}
703
704impl std::marker::Unpin for DeviceEventStream {}
705
706impl futures::stream::FusedStream for DeviceEventStream {
707    fn is_terminated(&self) -> bool {
708        self.event_receiver.is_terminated()
709    }
710}
711
712impl futures::Stream for DeviceEventStream {
713    type Item = Result<DeviceEvent, fidl::Error>;
714
715    fn poll_next(
716        mut self: std::pin::Pin<&mut Self>,
717        cx: &mut std::task::Context<'_>,
718    ) -> std::task::Poll<Option<Self::Item>> {
719        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
720            &mut self.event_receiver,
721            cx
722        )?) {
723            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
724            None => std::task::Poll::Ready(None),
725        }
726    }
727}
728
729#[derive(Debug)]
730pub enum DeviceEvent {}
731
732impl DeviceEvent {
733    /// Decodes a message buffer as a [`DeviceEvent`].
734    fn decode(
735        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
736    ) -> Result<DeviceEvent, fidl::Error> {
737        let (bytes, _handles) = buf.split_mut();
738        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
739        debug_assert_eq!(tx_header.tx_id, 0);
740        match tx_header.ordinal {
741            _ => Err(fidl::Error::UnknownOrdinal {
742                ordinal: tx_header.ordinal,
743                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
744            }),
745        }
746    }
747}
748
749/// A Stream of incoming requests for fuchsia.hardware.usb.device/Device.
750pub struct DeviceRequestStream {
751    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
752    is_terminated: bool,
753}
754
755impl std::marker::Unpin for DeviceRequestStream {}
756
757impl futures::stream::FusedStream for DeviceRequestStream {
758    fn is_terminated(&self) -> bool {
759        self.is_terminated
760    }
761}
762
763impl fidl::endpoints::RequestStream for DeviceRequestStream {
764    type Protocol = DeviceMarker;
765    type ControlHandle = DeviceControlHandle;
766
767    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
768        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
769    }
770
771    fn control_handle(&self) -> Self::ControlHandle {
772        DeviceControlHandle { inner: self.inner.clone() }
773    }
774
775    fn into_inner(
776        self,
777    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
778    {
779        (self.inner, self.is_terminated)
780    }
781
782    fn from_inner(
783        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
784        is_terminated: bool,
785    ) -> Self {
786        Self { inner, is_terminated }
787    }
788}
789
790impl futures::Stream for DeviceRequestStream {
791    type Item = Result<DeviceRequest, fidl::Error>;
792
793    fn poll_next(
794        mut self: std::pin::Pin<&mut Self>,
795        cx: &mut std::task::Context<'_>,
796    ) -> std::task::Poll<Option<Self::Item>> {
797        let this = &mut *self;
798        if this.inner.check_shutdown(cx) {
799            this.is_terminated = true;
800            return std::task::Poll::Ready(None);
801        }
802        if this.is_terminated {
803            panic!("polled DeviceRequestStream after completion");
804        }
805        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
806            |bytes, handles| {
807                match this.inner.channel().read_etc(cx, bytes, handles) {
808                    std::task::Poll::Ready(Ok(())) => {}
809                    std::task::Poll::Pending => return std::task::Poll::Pending,
810                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
811                        this.is_terminated = true;
812                        return std::task::Poll::Ready(None);
813                    }
814                    std::task::Poll::Ready(Err(e)) => {
815                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
816                            e.into(),
817                        ))));
818                    }
819                }
820
821                // A message has been received from the channel
822                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
823
824                std::task::Poll::Ready(Some(match header.ordinal {
825                    0x623cd7927fb449de => {
826                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
827                        let mut req = fidl::new_empty!(
828                            fidl::encoding::EmptyPayload,
829                            fidl::encoding::DefaultFuchsiaResourceDialect
830                        );
831                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
832                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
833                        Ok(DeviceRequest::GetDeviceSpeed {
834                            responder: DeviceGetDeviceSpeedResponder {
835                                control_handle: std::mem::ManuallyDrop::new(control_handle),
836                                tx_id: header.tx_id,
837                            },
838                        })
839                    }
840                    0x5f761371f4b9f34a => {
841                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
842                        let mut req = fidl::new_empty!(
843                            fidl::encoding::EmptyPayload,
844                            fidl::encoding::DefaultFuchsiaResourceDialect
845                        );
846                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
847                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
848                        Ok(DeviceRequest::GetDeviceDescriptor {
849                            responder: DeviceGetDeviceDescriptorResponder {
850                                control_handle: std::mem::ManuallyDrop::new(control_handle),
851                                tx_id: header.tx_id,
852                            },
853                        })
854                    }
855                    0x65912d7d5e3a07c8 => {
856                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
857                        let mut req = fidl::new_empty!(
858                            DeviceGetConfigurationDescriptorSizeRequest,
859                            fidl::encoding::DefaultFuchsiaResourceDialect
860                        );
861                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetConfigurationDescriptorSizeRequest>(&header, _body_bytes, handles, &mut req)?;
862                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
863                        Ok(DeviceRequest::GetConfigurationDescriptorSize {
864                            config: req.config,
865
866                            responder: DeviceGetConfigurationDescriptorSizeResponder {
867                                control_handle: std::mem::ManuallyDrop::new(control_handle),
868                                tx_id: header.tx_id,
869                            },
870                        })
871                    }
872                    0x1859a4e4421d2036 => {
873                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
874                        let mut req = fidl::new_empty!(
875                            DeviceGetConfigurationDescriptorRequest,
876                            fidl::encoding::DefaultFuchsiaResourceDialect
877                        );
878                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetConfigurationDescriptorRequest>(&header, _body_bytes, handles, &mut req)?;
879                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
880                        Ok(DeviceRequest::GetConfigurationDescriptor {
881                            config: req.config,
882
883                            responder: DeviceGetConfigurationDescriptorResponder {
884                                control_handle: std::mem::ManuallyDrop::new(control_handle),
885                                tx_id: header.tx_id,
886                            },
887                        })
888                    }
889                    0x5ff601b3b6891337 => {
890                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
891                        let mut req = fidl::new_empty!(
892                            DeviceGetStringDescriptorRequest,
893                            fidl::encoding::DefaultFuchsiaResourceDialect
894                        );
895                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetStringDescriptorRequest>(&header, _body_bytes, handles, &mut req)?;
896                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
897                        Ok(DeviceRequest::GetStringDescriptor {
898                            desc_id: req.desc_id,
899                            lang_id: req.lang_id,
900
901                            responder: DeviceGetStringDescriptorResponder {
902                                control_handle: std::mem::ManuallyDrop::new(control_handle),
903                                tx_id: header.tx_id,
904                            },
905                        })
906                    }
907                    0x45348c50850b641d => {
908                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
909                        let mut req = fidl::new_empty!(
910                            DeviceSetInterfaceRequest,
911                            fidl::encoding::DefaultFuchsiaResourceDialect
912                        );
913                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetInterfaceRequest>(&header, _body_bytes, handles, &mut req)?;
914                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
915                        Ok(DeviceRequest::SetInterface {
916                            interface_number: req.interface_number,
917                            alt_setting: req.alt_setting,
918
919                            responder: DeviceSetInterfaceResponder {
920                                control_handle: std::mem::ManuallyDrop::new(control_handle),
921                                tx_id: header.tx_id,
922                            },
923                        })
924                    }
925                    0x34a73eef491c2ce0 => {
926                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
927                        let mut req = fidl::new_empty!(
928                            fidl::encoding::EmptyPayload,
929                            fidl::encoding::DefaultFuchsiaResourceDialect
930                        );
931                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
932                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
933                        Ok(DeviceRequest::GetDeviceId {
934                            responder: DeviceGetDeviceIdResponder {
935                                control_handle: std::mem::ManuallyDrop::new(control_handle),
936                                tx_id: header.tx_id,
937                            },
938                        })
939                    }
940                    0xce263c86f7bbbcd => {
941                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
942                        let mut req = fidl::new_empty!(
943                            fidl::encoding::EmptyPayload,
944                            fidl::encoding::DefaultFuchsiaResourceDialect
945                        );
946                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
947                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
948                        Ok(DeviceRequest::GetHubDeviceId {
949                            responder: DeviceGetHubDeviceIdResponder {
950                                control_handle: std::mem::ManuallyDrop::new(control_handle),
951                                tx_id: header.tx_id,
952                            },
953                        })
954                    }
955                    0x73f644382a2335fd => {
956                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
957                        let mut req = fidl::new_empty!(
958                            fidl::encoding::EmptyPayload,
959                            fidl::encoding::DefaultFuchsiaResourceDialect
960                        );
961                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
962                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
963                        Ok(DeviceRequest::GetConfiguration {
964                            responder: DeviceGetConfigurationResponder {
965                                control_handle: std::mem::ManuallyDrop::new(control_handle),
966                                tx_id: header.tx_id,
967                            },
968                        })
969                    }
970                    0x12bf6e43b045ee9d => {
971                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
972                        let mut req = fidl::new_empty!(
973                            DeviceSetConfigurationRequest,
974                            fidl::encoding::DefaultFuchsiaResourceDialect
975                        );
976                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
977                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
978                        Ok(DeviceRequest::SetConfiguration {
979                            configuration: req.configuration,
980
981                            responder: DeviceSetConfigurationResponder {
982                                control_handle: std::mem::ManuallyDrop::new(control_handle),
983                                tx_id: header.tx_id,
984                            },
985                        })
986                    }
987                    _ => Err(fidl::Error::UnknownOrdinal {
988                        ordinal: header.ordinal,
989                        protocol_name:
990                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
991                    }),
992                }))
993            },
994        )
995    }
996}
997
998#[derive(Debug)]
999pub enum DeviceRequest {
1000    /// Returns the speed of the USB device as a usb_speed_t value.
1001    GetDeviceSpeed { responder: DeviceGetDeviceSpeedResponder },
1002    /// Returns the device's USB device descriptor.
1003    GetDeviceDescriptor { responder: DeviceGetDeviceDescriptorResponder },
1004    /// Returns the total size of the USB configuration descriptor for the given configuration.
1005    GetConfigurationDescriptorSize {
1006        config: u8,
1007        responder: DeviceGetConfigurationDescriptorSizeResponder,
1008    },
1009    /// Returns the device's USB configuration descriptor for the given configuration.
1010    GetConfigurationDescriptor { config: u8, responder: DeviceGetConfigurationDescriptorResponder },
1011    /// Fetches a string descriptor from the USB device.
1012    ///
1013    /// desc_id          :   The ID of the string descriptor to fetch, or 0 to fetch
1014    ///                      the language table instead.
1015    ///
1016    /// lang_id          :   The language ID of the string descriptor to fetch.
1017    ///                      If no matching language ID is present in the device's language
1018    ///                      ID table, the first entry of the language ID table will
1019    ///                      be substituted.
1020    /// actual_lang_id   :   The actual language ID of the string fetched, or 0 for
1021    ///                      the language ID table.
1022    ///
1023    /// The worst case size for the payload of a language ID table should be 252
1024    /// bytes, meaning that a 256 byte buffer should always be enough to hold any
1025    /// language ID table.
1026    ///
1027    /// The worst case size for a UTF-8 encoded string descriptor payload should be
1028    /// 378 bytes (126 UTF-16 code units with a worst case expansion factor of 3)
1029    GetStringDescriptor { desc_id: u8, lang_id: u16, responder: DeviceGetStringDescriptorResponder },
1030    /// Selects an alternate setting for an interface on a USB device.
1031    SetInterface { interface_number: u8, alt_setting: u8, responder: DeviceSetInterfaceResponder },
1032    /// Returns an implementation specific device ID for a USB device.
1033    /// For informational purposes only.
1034    GetDeviceId { responder: DeviceGetDeviceIdResponder },
1035    /// Returns the implementation specific device ID for the hub that a USB device is connected to.
1036    /// For informational purposes only.
1037    GetHubDeviceId { responder: DeviceGetHubDeviceIdResponder },
1038    /// Returns the device's current configuration.
1039    GetConfiguration { responder: DeviceGetConfigurationResponder },
1040    /// Sets the device's current configuration.
1041    SetConfiguration { configuration: u8, responder: DeviceSetConfigurationResponder },
1042}
1043
1044impl DeviceRequest {
1045    #[allow(irrefutable_let_patterns)]
1046    pub fn into_get_device_speed(self) -> Option<(DeviceGetDeviceSpeedResponder)> {
1047        if let DeviceRequest::GetDeviceSpeed { responder } = self {
1048            Some((responder))
1049        } else {
1050            None
1051        }
1052    }
1053
1054    #[allow(irrefutable_let_patterns)]
1055    pub fn into_get_device_descriptor(self) -> Option<(DeviceGetDeviceDescriptorResponder)> {
1056        if let DeviceRequest::GetDeviceDescriptor { responder } = self {
1057            Some((responder))
1058        } else {
1059            None
1060        }
1061    }
1062
1063    #[allow(irrefutable_let_patterns)]
1064    pub fn into_get_configuration_descriptor_size(
1065        self,
1066    ) -> Option<(u8, DeviceGetConfigurationDescriptorSizeResponder)> {
1067        if let DeviceRequest::GetConfigurationDescriptorSize { config, responder } = self {
1068            Some((config, responder))
1069        } else {
1070            None
1071        }
1072    }
1073
1074    #[allow(irrefutable_let_patterns)]
1075    pub fn into_get_configuration_descriptor(
1076        self,
1077    ) -> Option<(u8, DeviceGetConfigurationDescriptorResponder)> {
1078        if let DeviceRequest::GetConfigurationDescriptor { config, responder } = self {
1079            Some((config, responder))
1080        } else {
1081            None
1082        }
1083    }
1084
1085    #[allow(irrefutable_let_patterns)]
1086    pub fn into_get_string_descriptor(
1087        self,
1088    ) -> Option<(u8, u16, DeviceGetStringDescriptorResponder)> {
1089        if let DeviceRequest::GetStringDescriptor { desc_id, lang_id, responder } = self {
1090            Some((desc_id, lang_id, responder))
1091        } else {
1092            None
1093        }
1094    }
1095
1096    #[allow(irrefutable_let_patterns)]
1097    pub fn into_set_interface(self) -> Option<(u8, u8, DeviceSetInterfaceResponder)> {
1098        if let DeviceRequest::SetInterface { interface_number, alt_setting, responder } = self {
1099            Some((interface_number, alt_setting, responder))
1100        } else {
1101            None
1102        }
1103    }
1104
1105    #[allow(irrefutable_let_patterns)]
1106    pub fn into_get_device_id(self) -> Option<(DeviceGetDeviceIdResponder)> {
1107        if let DeviceRequest::GetDeviceId { responder } = self { Some((responder)) } else { None }
1108    }
1109
1110    #[allow(irrefutable_let_patterns)]
1111    pub fn into_get_hub_device_id(self) -> Option<(DeviceGetHubDeviceIdResponder)> {
1112        if let DeviceRequest::GetHubDeviceId { responder } = self {
1113            Some((responder))
1114        } else {
1115            None
1116        }
1117    }
1118
1119    #[allow(irrefutable_let_patterns)]
1120    pub fn into_get_configuration(self) -> Option<(DeviceGetConfigurationResponder)> {
1121        if let DeviceRequest::GetConfiguration { responder } = self {
1122            Some((responder))
1123        } else {
1124            None
1125        }
1126    }
1127
1128    #[allow(irrefutable_let_patterns)]
1129    pub fn into_set_configuration(self) -> Option<(u8, DeviceSetConfigurationResponder)> {
1130        if let DeviceRequest::SetConfiguration { configuration, responder } = self {
1131            Some((configuration, responder))
1132        } else {
1133            None
1134        }
1135    }
1136
1137    /// Name of the method defined in FIDL
1138    pub fn method_name(&self) -> &'static str {
1139        match *self {
1140            DeviceRequest::GetDeviceSpeed { .. } => "get_device_speed",
1141            DeviceRequest::GetDeviceDescriptor { .. } => "get_device_descriptor",
1142            DeviceRequest::GetConfigurationDescriptorSize { .. } => {
1143                "get_configuration_descriptor_size"
1144            }
1145            DeviceRequest::GetConfigurationDescriptor { .. } => "get_configuration_descriptor",
1146            DeviceRequest::GetStringDescriptor { .. } => "get_string_descriptor",
1147            DeviceRequest::SetInterface { .. } => "set_interface",
1148            DeviceRequest::GetDeviceId { .. } => "get_device_id",
1149            DeviceRequest::GetHubDeviceId { .. } => "get_hub_device_id",
1150            DeviceRequest::GetConfiguration { .. } => "get_configuration",
1151            DeviceRequest::SetConfiguration { .. } => "set_configuration",
1152        }
1153    }
1154}
1155
1156#[derive(Debug, Clone)]
1157pub struct DeviceControlHandle {
1158    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1159}
1160
1161impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1162    fn shutdown(&self) {
1163        self.inner.shutdown()
1164    }
1165
1166    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1167        self.inner.shutdown_with_epitaph(status)
1168    }
1169
1170    fn is_closed(&self) -> bool {
1171        self.inner.channel().is_closed()
1172    }
1173    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1174        self.inner.channel().on_closed()
1175    }
1176
1177    #[cfg(target_os = "fuchsia")]
1178    fn signal_peer(
1179        &self,
1180        clear_mask: zx::Signals,
1181        set_mask: zx::Signals,
1182    ) -> Result<(), zx_status::Status> {
1183        use fidl::Peered;
1184        self.inner.channel().signal_peer(clear_mask, set_mask)
1185    }
1186}
1187
1188impl DeviceControlHandle {}
1189
1190#[must_use = "FIDL methods require a response to be sent"]
1191#[derive(Debug)]
1192pub struct DeviceGetDeviceSpeedResponder {
1193    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1194    tx_id: u32,
1195}
1196
1197/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1198/// if the responder is dropped without sending a response, so that the client
1199/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1200impl std::ops::Drop for DeviceGetDeviceSpeedResponder {
1201    fn drop(&mut self) {
1202        self.control_handle.shutdown();
1203        // Safety: drops once, never accessed again
1204        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1205    }
1206}
1207
1208impl fidl::endpoints::Responder for DeviceGetDeviceSpeedResponder {
1209    type ControlHandle = DeviceControlHandle;
1210
1211    fn control_handle(&self) -> &DeviceControlHandle {
1212        &self.control_handle
1213    }
1214
1215    fn drop_without_shutdown(mut self) {
1216        // Safety: drops once, never accessed again due to mem::forget
1217        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1218        // Prevent Drop from running (which would shut down the channel)
1219        std::mem::forget(self);
1220    }
1221}
1222
1223impl DeviceGetDeviceSpeedResponder {
1224    /// Sends a response to the FIDL transaction.
1225    ///
1226    /// Sets the channel to shutdown if an error occurs.
1227    pub fn send(self, mut speed: u32) -> Result<(), fidl::Error> {
1228        let _result = self.send_raw(speed);
1229        if _result.is_err() {
1230            self.control_handle.shutdown();
1231        }
1232        self.drop_without_shutdown();
1233        _result
1234    }
1235
1236    /// Similar to "send" but does not shutdown the channel if an error occurs.
1237    pub fn send_no_shutdown_on_err(self, mut speed: u32) -> Result<(), fidl::Error> {
1238        let _result = self.send_raw(speed);
1239        self.drop_without_shutdown();
1240        _result
1241    }
1242
1243    fn send_raw(&self, mut speed: u32) -> Result<(), fidl::Error> {
1244        self.control_handle.inner.send::<DeviceGetDeviceSpeedResponse>(
1245            (speed,),
1246            self.tx_id,
1247            0x623cd7927fb449de,
1248            fidl::encoding::DynamicFlags::empty(),
1249        )
1250    }
1251}
1252
1253#[must_use = "FIDL methods require a response to be sent"]
1254#[derive(Debug)]
1255pub struct DeviceGetDeviceDescriptorResponder {
1256    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1257    tx_id: u32,
1258}
1259
1260/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1261/// if the responder is dropped without sending a response, so that the client
1262/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1263impl std::ops::Drop for DeviceGetDeviceDescriptorResponder {
1264    fn drop(&mut self) {
1265        self.control_handle.shutdown();
1266        // Safety: drops once, never accessed again
1267        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1268    }
1269}
1270
1271impl fidl::endpoints::Responder for DeviceGetDeviceDescriptorResponder {
1272    type ControlHandle = DeviceControlHandle;
1273
1274    fn control_handle(&self) -> &DeviceControlHandle {
1275        &self.control_handle
1276    }
1277
1278    fn drop_without_shutdown(mut self) {
1279        // Safety: drops once, never accessed again due to mem::forget
1280        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1281        // Prevent Drop from running (which would shut down the channel)
1282        std::mem::forget(self);
1283    }
1284}
1285
1286impl DeviceGetDeviceDescriptorResponder {
1287    /// Sends a response to the FIDL transaction.
1288    ///
1289    /// Sets the channel to shutdown if an error occurs.
1290    pub fn send(self, mut desc: &[u8; 18]) -> Result<(), fidl::Error> {
1291        let _result = self.send_raw(desc);
1292        if _result.is_err() {
1293            self.control_handle.shutdown();
1294        }
1295        self.drop_without_shutdown();
1296        _result
1297    }
1298
1299    /// Similar to "send" but does not shutdown the channel if an error occurs.
1300    pub fn send_no_shutdown_on_err(self, mut desc: &[u8; 18]) -> Result<(), fidl::Error> {
1301        let _result = self.send_raw(desc);
1302        self.drop_without_shutdown();
1303        _result
1304    }
1305
1306    fn send_raw(&self, mut desc: &[u8; 18]) -> Result<(), fidl::Error> {
1307        self.control_handle.inner.send::<DeviceGetDeviceDescriptorResponse>(
1308            (desc,),
1309            self.tx_id,
1310            0x5f761371f4b9f34a,
1311            fidl::encoding::DynamicFlags::empty(),
1312        )
1313    }
1314}
1315
1316#[must_use = "FIDL methods require a response to be sent"]
1317#[derive(Debug)]
1318pub struct DeviceGetConfigurationDescriptorSizeResponder {
1319    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1320    tx_id: u32,
1321}
1322
1323/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1324/// if the responder is dropped without sending a response, so that the client
1325/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1326impl std::ops::Drop for DeviceGetConfigurationDescriptorSizeResponder {
1327    fn drop(&mut self) {
1328        self.control_handle.shutdown();
1329        // Safety: drops once, never accessed again
1330        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1331    }
1332}
1333
1334impl fidl::endpoints::Responder for DeviceGetConfigurationDescriptorSizeResponder {
1335    type ControlHandle = DeviceControlHandle;
1336
1337    fn control_handle(&self) -> &DeviceControlHandle {
1338        &self.control_handle
1339    }
1340
1341    fn drop_without_shutdown(mut self) {
1342        // Safety: drops once, never accessed again due to mem::forget
1343        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1344        // Prevent Drop from running (which would shut down the channel)
1345        std::mem::forget(self);
1346    }
1347}
1348
1349impl DeviceGetConfigurationDescriptorSizeResponder {
1350    /// Sends a response to the FIDL transaction.
1351    ///
1352    /// Sets the channel to shutdown if an error occurs.
1353    pub fn send(self, mut s: i32, mut size: u16) -> Result<(), fidl::Error> {
1354        let _result = self.send_raw(s, size);
1355        if _result.is_err() {
1356            self.control_handle.shutdown();
1357        }
1358        self.drop_without_shutdown();
1359        _result
1360    }
1361
1362    /// Similar to "send" but does not shutdown the channel if an error occurs.
1363    pub fn send_no_shutdown_on_err(self, mut s: i32, mut size: u16) -> Result<(), fidl::Error> {
1364        let _result = self.send_raw(s, size);
1365        self.drop_without_shutdown();
1366        _result
1367    }
1368
1369    fn send_raw(&self, mut s: i32, mut size: u16) -> Result<(), fidl::Error> {
1370        self.control_handle.inner.send::<DeviceGetConfigurationDescriptorSizeResponse>(
1371            (s, size),
1372            self.tx_id,
1373            0x65912d7d5e3a07c8,
1374            fidl::encoding::DynamicFlags::empty(),
1375        )
1376    }
1377}
1378
1379#[must_use = "FIDL methods require a response to be sent"]
1380#[derive(Debug)]
1381pub struct DeviceGetConfigurationDescriptorResponder {
1382    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1383    tx_id: u32,
1384}
1385
1386/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1387/// if the responder is dropped without sending a response, so that the client
1388/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1389impl std::ops::Drop for DeviceGetConfigurationDescriptorResponder {
1390    fn drop(&mut self) {
1391        self.control_handle.shutdown();
1392        // Safety: drops once, never accessed again
1393        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1394    }
1395}
1396
1397impl fidl::endpoints::Responder for DeviceGetConfigurationDescriptorResponder {
1398    type ControlHandle = DeviceControlHandle;
1399
1400    fn control_handle(&self) -> &DeviceControlHandle {
1401        &self.control_handle
1402    }
1403
1404    fn drop_without_shutdown(mut self) {
1405        // Safety: drops once, never accessed again due to mem::forget
1406        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1407        // Prevent Drop from running (which would shut down the channel)
1408        std::mem::forget(self);
1409    }
1410}
1411
1412impl DeviceGetConfigurationDescriptorResponder {
1413    /// Sends a response to the FIDL transaction.
1414    ///
1415    /// Sets the channel to shutdown if an error occurs.
1416    pub fn send(self, mut s: i32, mut desc: &[u8]) -> Result<(), fidl::Error> {
1417        let _result = self.send_raw(s, desc);
1418        if _result.is_err() {
1419            self.control_handle.shutdown();
1420        }
1421        self.drop_without_shutdown();
1422        _result
1423    }
1424
1425    /// Similar to "send" but does not shutdown the channel if an error occurs.
1426    pub fn send_no_shutdown_on_err(self, mut s: i32, mut desc: &[u8]) -> Result<(), fidl::Error> {
1427        let _result = self.send_raw(s, desc);
1428        self.drop_without_shutdown();
1429        _result
1430    }
1431
1432    fn send_raw(&self, mut s: i32, mut desc: &[u8]) -> Result<(), fidl::Error> {
1433        self.control_handle.inner.send::<DeviceGetConfigurationDescriptorResponse>(
1434            (s, desc),
1435            self.tx_id,
1436            0x1859a4e4421d2036,
1437            fidl::encoding::DynamicFlags::empty(),
1438        )
1439    }
1440}
1441
1442#[must_use = "FIDL methods require a response to be sent"]
1443#[derive(Debug)]
1444pub struct DeviceGetStringDescriptorResponder {
1445    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1446    tx_id: u32,
1447}
1448
1449/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1450/// if the responder is dropped without sending a response, so that the client
1451/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1452impl std::ops::Drop for DeviceGetStringDescriptorResponder {
1453    fn drop(&mut self) {
1454        self.control_handle.shutdown();
1455        // Safety: drops once, never accessed again
1456        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1457    }
1458}
1459
1460impl fidl::endpoints::Responder for DeviceGetStringDescriptorResponder {
1461    type ControlHandle = DeviceControlHandle;
1462
1463    fn control_handle(&self) -> &DeviceControlHandle {
1464        &self.control_handle
1465    }
1466
1467    fn drop_without_shutdown(mut self) {
1468        // Safety: drops once, never accessed again due to mem::forget
1469        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1470        // Prevent Drop from running (which would shut down the channel)
1471        std::mem::forget(self);
1472    }
1473}
1474
1475impl DeviceGetStringDescriptorResponder {
1476    /// Sends a response to the FIDL transaction.
1477    ///
1478    /// Sets the channel to shutdown if an error occurs.
1479    pub fn send(
1480        self,
1481        mut s: i32,
1482        mut desc: &str,
1483        mut actual_lang_id: u16,
1484    ) -> Result<(), fidl::Error> {
1485        let _result = self.send_raw(s, desc, actual_lang_id);
1486        if _result.is_err() {
1487            self.control_handle.shutdown();
1488        }
1489        self.drop_without_shutdown();
1490        _result
1491    }
1492
1493    /// Similar to "send" but does not shutdown the channel if an error occurs.
1494    pub fn send_no_shutdown_on_err(
1495        self,
1496        mut s: i32,
1497        mut desc: &str,
1498        mut actual_lang_id: u16,
1499    ) -> Result<(), fidl::Error> {
1500        let _result = self.send_raw(s, desc, actual_lang_id);
1501        self.drop_without_shutdown();
1502        _result
1503    }
1504
1505    fn send_raw(
1506        &self,
1507        mut s: i32,
1508        mut desc: &str,
1509        mut actual_lang_id: u16,
1510    ) -> Result<(), fidl::Error> {
1511        self.control_handle.inner.send::<DeviceGetStringDescriptorResponse>(
1512            (s, desc, actual_lang_id),
1513            self.tx_id,
1514            0x5ff601b3b6891337,
1515            fidl::encoding::DynamicFlags::empty(),
1516        )
1517    }
1518}
1519
1520#[must_use = "FIDL methods require a response to be sent"]
1521#[derive(Debug)]
1522pub struct DeviceSetInterfaceResponder {
1523    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1524    tx_id: u32,
1525}
1526
1527/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1528/// if the responder is dropped without sending a response, so that the client
1529/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1530impl std::ops::Drop for DeviceSetInterfaceResponder {
1531    fn drop(&mut self) {
1532        self.control_handle.shutdown();
1533        // Safety: drops once, never accessed again
1534        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1535    }
1536}
1537
1538impl fidl::endpoints::Responder for DeviceSetInterfaceResponder {
1539    type ControlHandle = DeviceControlHandle;
1540
1541    fn control_handle(&self) -> &DeviceControlHandle {
1542        &self.control_handle
1543    }
1544
1545    fn drop_without_shutdown(mut self) {
1546        // Safety: drops once, never accessed again due to mem::forget
1547        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1548        // Prevent Drop from running (which would shut down the channel)
1549        std::mem::forget(self);
1550    }
1551}
1552
1553impl DeviceSetInterfaceResponder {
1554    /// Sends a response to the FIDL transaction.
1555    ///
1556    /// Sets the channel to shutdown if an error occurs.
1557    pub fn send(self, mut s: i32) -> Result<(), fidl::Error> {
1558        let _result = self.send_raw(s);
1559        if _result.is_err() {
1560            self.control_handle.shutdown();
1561        }
1562        self.drop_without_shutdown();
1563        _result
1564    }
1565
1566    /// Similar to "send" but does not shutdown the channel if an error occurs.
1567    pub fn send_no_shutdown_on_err(self, mut s: i32) -> Result<(), fidl::Error> {
1568        let _result = self.send_raw(s);
1569        self.drop_without_shutdown();
1570        _result
1571    }
1572
1573    fn send_raw(&self, mut s: i32) -> Result<(), fidl::Error> {
1574        self.control_handle.inner.send::<DeviceSetInterfaceResponse>(
1575            (s,),
1576            self.tx_id,
1577            0x45348c50850b641d,
1578            fidl::encoding::DynamicFlags::empty(),
1579        )
1580    }
1581}
1582
1583#[must_use = "FIDL methods require a response to be sent"]
1584#[derive(Debug)]
1585pub struct DeviceGetDeviceIdResponder {
1586    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1587    tx_id: u32,
1588}
1589
1590/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1591/// if the responder is dropped without sending a response, so that the client
1592/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1593impl std::ops::Drop for DeviceGetDeviceIdResponder {
1594    fn drop(&mut self) {
1595        self.control_handle.shutdown();
1596        // Safety: drops once, never accessed again
1597        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1598    }
1599}
1600
1601impl fidl::endpoints::Responder for DeviceGetDeviceIdResponder {
1602    type ControlHandle = DeviceControlHandle;
1603
1604    fn control_handle(&self) -> &DeviceControlHandle {
1605        &self.control_handle
1606    }
1607
1608    fn drop_without_shutdown(mut self) {
1609        // Safety: drops once, never accessed again due to mem::forget
1610        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1611        // Prevent Drop from running (which would shut down the channel)
1612        std::mem::forget(self);
1613    }
1614}
1615
1616impl DeviceGetDeviceIdResponder {
1617    /// Sends a response to the FIDL transaction.
1618    ///
1619    /// Sets the channel to shutdown if an error occurs.
1620    pub fn send(self, mut device_id: u32) -> Result<(), fidl::Error> {
1621        let _result = self.send_raw(device_id);
1622        if _result.is_err() {
1623            self.control_handle.shutdown();
1624        }
1625        self.drop_without_shutdown();
1626        _result
1627    }
1628
1629    /// Similar to "send" but does not shutdown the channel if an error occurs.
1630    pub fn send_no_shutdown_on_err(self, mut device_id: u32) -> Result<(), fidl::Error> {
1631        let _result = self.send_raw(device_id);
1632        self.drop_without_shutdown();
1633        _result
1634    }
1635
1636    fn send_raw(&self, mut device_id: u32) -> Result<(), fidl::Error> {
1637        self.control_handle.inner.send::<DeviceGetDeviceIdResponse>(
1638            (device_id,),
1639            self.tx_id,
1640            0x34a73eef491c2ce0,
1641            fidl::encoding::DynamicFlags::empty(),
1642        )
1643    }
1644}
1645
1646#[must_use = "FIDL methods require a response to be sent"]
1647#[derive(Debug)]
1648pub struct DeviceGetHubDeviceIdResponder {
1649    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1650    tx_id: u32,
1651}
1652
1653/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1654/// if the responder is dropped without sending a response, so that the client
1655/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1656impl std::ops::Drop for DeviceGetHubDeviceIdResponder {
1657    fn drop(&mut self) {
1658        self.control_handle.shutdown();
1659        // Safety: drops once, never accessed again
1660        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1661    }
1662}
1663
1664impl fidl::endpoints::Responder for DeviceGetHubDeviceIdResponder {
1665    type ControlHandle = DeviceControlHandle;
1666
1667    fn control_handle(&self) -> &DeviceControlHandle {
1668        &self.control_handle
1669    }
1670
1671    fn drop_without_shutdown(mut self) {
1672        // Safety: drops once, never accessed again due to mem::forget
1673        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1674        // Prevent Drop from running (which would shut down the channel)
1675        std::mem::forget(self);
1676    }
1677}
1678
1679impl DeviceGetHubDeviceIdResponder {
1680    /// Sends a response to the FIDL transaction.
1681    ///
1682    /// Sets the channel to shutdown if an error occurs.
1683    pub fn send(self, mut hub_device_id: u32) -> Result<(), fidl::Error> {
1684        let _result = self.send_raw(hub_device_id);
1685        if _result.is_err() {
1686            self.control_handle.shutdown();
1687        }
1688        self.drop_without_shutdown();
1689        _result
1690    }
1691
1692    /// Similar to "send" but does not shutdown the channel if an error occurs.
1693    pub fn send_no_shutdown_on_err(self, mut hub_device_id: u32) -> Result<(), fidl::Error> {
1694        let _result = self.send_raw(hub_device_id);
1695        self.drop_without_shutdown();
1696        _result
1697    }
1698
1699    fn send_raw(&self, mut hub_device_id: u32) -> Result<(), fidl::Error> {
1700        self.control_handle.inner.send::<DeviceGetHubDeviceIdResponse>(
1701            (hub_device_id,),
1702            self.tx_id,
1703            0xce263c86f7bbbcd,
1704            fidl::encoding::DynamicFlags::empty(),
1705        )
1706    }
1707}
1708
1709#[must_use = "FIDL methods require a response to be sent"]
1710#[derive(Debug)]
1711pub struct DeviceGetConfigurationResponder {
1712    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1713    tx_id: u32,
1714}
1715
1716/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1717/// if the responder is dropped without sending a response, so that the client
1718/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1719impl std::ops::Drop for DeviceGetConfigurationResponder {
1720    fn drop(&mut self) {
1721        self.control_handle.shutdown();
1722        // Safety: drops once, never accessed again
1723        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1724    }
1725}
1726
1727impl fidl::endpoints::Responder for DeviceGetConfigurationResponder {
1728    type ControlHandle = DeviceControlHandle;
1729
1730    fn control_handle(&self) -> &DeviceControlHandle {
1731        &self.control_handle
1732    }
1733
1734    fn drop_without_shutdown(mut self) {
1735        // Safety: drops once, never accessed again due to mem::forget
1736        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1737        // Prevent Drop from running (which would shut down the channel)
1738        std::mem::forget(self);
1739    }
1740}
1741
1742impl DeviceGetConfigurationResponder {
1743    /// Sends a response to the FIDL transaction.
1744    ///
1745    /// Sets the channel to shutdown if an error occurs.
1746    pub fn send(self, mut configuration: u8) -> Result<(), fidl::Error> {
1747        let _result = self.send_raw(configuration);
1748        if _result.is_err() {
1749            self.control_handle.shutdown();
1750        }
1751        self.drop_without_shutdown();
1752        _result
1753    }
1754
1755    /// Similar to "send" but does not shutdown the channel if an error occurs.
1756    pub fn send_no_shutdown_on_err(self, mut configuration: u8) -> Result<(), fidl::Error> {
1757        let _result = self.send_raw(configuration);
1758        self.drop_without_shutdown();
1759        _result
1760    }
1761
1762    fn send_raw(&self, mut configuration: u8) -> Result<(), fidl::Error> {
1763        self.control_handle.inner.send::<DeviceGetConfigurationResponse>(
1764            (configuration,),
1765            self.tx_id,
1766            0x73f644382a2335fd,
1767            fidl::encoding::DynamicFlags::empty(),
1768        )
1769    }
1770}
1771
1772#[must_use = "FIDL methods require a response to be sent"]
1773#[derive(Debug)]
1774pub struct DeviceSetConfigurationResponder {
1775    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1776    tx_id: u32,
1777}
1778
1779/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1780/// if the responder is dropped without sending a response, so that the client
1781/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1782impl std::ops::Drop for DeviceSetConfigurationResponder {
1783    fn drop(&mut self) {
1784        self.control_handle.shutdown();
1785        // Safety: drops once, never accessed again
1786        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1787    }
1788}
1789
1790impl fidl::endpoints::Responder for DeviceSetConfigurationResponder {
1791    type ControlHandle = DeviceControlHandle;
1792
1793    fn control_handle(&self) -> &DeviceControlHandle {
1794        &self.control_handle
1795    }
1796
1797    fn drop_without_shutdown(mut self) {
1798        // Safety: drops once, never accessed again due to mem::forget
1799        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1800        // Prevent Drop from running (which would shut down the channel)
1801        std::mem::forget(self);
1802    }
1803}
1804
1805impl DeviceSetConfigurationResponder {
1806    /// Sends a response to the FIDL transaction.
1807    ///
1808    /// Sets the channel to shutdown if an error occurs.
1809    pub fn send(self, mut s: i32) -> Result<(), fidl::Error> {
1810        let _result = self.send_raw(s);
1811        if _result.is_err() {
1812            self.control_handle.shutdown();
1813        }
1814        self.drop_without_shutdown();
1815        _result
1816    }
1817
1818    /// Similar to "send" but does not shutdown the channel if an error occurs.
1819    pub fn send_no_shutdown_on_err(self, mut s: i32) -> Result<(), fidl::Error> {
1820        let _result = self.send_raw(s);
1821        self.drop_without_shutdown();
1822        _result
1823    }
1824
1825    fn send_raw(&self, mut s: i32) -> Result<(), fidl::Error> {
1826        self.control_handle.inner.send::<DeviceSetConfigurationResponse>(
1827            (s,),
1828            self.tx_id,
1829            0x12bf6e43b045ee9d,
1830            fidl::encoding::DynamicFlags::empty(),
1831        )
1832    }
1833}
1834
1835#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1836pub struct ServiceMarker;
1837
1838#[cfg(target_os = "fuchsia")]
1839impl fidl::endpoints::ServiceMarker for ServiceMarker {
1840    type Proxy = ServiceProxy;
1841    type Request = ServiceRequest;
1842    const SERVICE_NAME: &'static str = "fuchsia.hardware.usb.device.Service";
1843}
1844
1845/// A request for one of the member protocols of Service.
1846///
1847#[cfg(target_os = "fuchsia")]
1848pub enum ServiceRequest {
1849    Device(DeviceRequestStream),
1850}
1851
1852#[cfg(target_os = "fuchsia")]
1853impl fidl::endpoints::ServiceRequest for ServiceRequest {
1854    type Service = ServiceMarker;
1855
1856    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1857        match name {
1858            "device" => Self::Device(
1859                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1860            ),
1861            _ => panic!("no such member protocol name for service Service"),
1862        }
1863    }
1864
1865    fn member_names() -> &'static [&'static str] {
1866        &["device"]
1867    }
1868}
1869#[cfg(target_os = "fuchsia")]
1870pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1871
1872#[cfg(target_os = "fuchsia")]
1873impl fidl::endpoints::ServiceProxy for ServiceProxy {
1874    type Service = ServiceMarker;
1875
1876    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1877        Self(opener)
1878    }
1879}
1880
1881#[cfg(target_os = "fuchsia")]
1882impl ServiceProxy {
1883    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1884        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1885        self.connect_channel_to_device(server_end)?;
1886        Ok(proxy)
1887    }
1888
1889    /// Like `connect_to_device`, but returns a sync proxy.
1890    /// See [`Self::connect_to_device`] for more details.
1891    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1892        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1893        self.connect_channel_to_device(server_end)?;
1894        Ok(proxy)
1895    }
1896
1897    /// Like `connect_to_device`, but accepts a server end.
1898    /// See [`Self::connect_to_device`] for more details.
1899    pub fn connect_channel_to_device(
1900        &self,
1901        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1902    ) -> Result<(), fidl::Error> {
1903        self.0.open_member("device", server_end.into_channel())
1904    }
1905
1906    pub fn instance_name(&self) -> &str {
1907        self.0.instance_name()
1908    }
1909}
1910
1911mod internal {
1912    use super::*;
1913}