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