1#![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_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct UsbConnectToEndpointRequest {
16 pub ep_addr: u8,
17 pub ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21 for UsbConnectToEndpointRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct UsbMarker;
27
28impl fidl::endpoints::ProtocolMarker for UsbMarker {
29 type Proxy = UsbProxy;
30 type RequestStream = UsbRequestStream;
31 #[cfg(target_os = "fuchsia")]
32 type SynchronousProxy = UsbSynchronousProxy;
33
34 const DEBUG_NAME: &'static str = "fuchsia.hardware.usb.Usb";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for UsbMarker {}
37pub type UsbConnectToEndpointResult = Result<(), i32>;
38pub type UsbGetConfigurationDescriptorResult = Result<Vec<u8>, i32>;
39pub type UsbSetConfigurationResult = Result<(), i32>;
40pub type UsbSetInterfaceResult = Result<(), i32>;
41pub type UsbControlTransferResult = Result<Vec<u8>, i32>;
42pub type UsbEnableEndpointResult = Result<(), i32>;
43pub type UsbResetEndpointResult = Result<(), i32>;
44
45pub trait UsbProxyInterface: Send + Sync {
46 type ConnectToEndpointResponseFut: std::future::Future<Output = Result<UsbConnectToEndpointResult, fidl::Error>>
47 + Send;
48 fn r#connect_to_endpoint(
49 &self,
50 ep_addr: u8,
51 ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
52 ) -> Self::ConnectToEndpointResponseFut;
53 type GetDeviceSpeedResponseFut: std::future::Future<
54 Output = Result<fidl_fuchsia_hardware_usb_descriptor::UsbSpeed, fidl::Error>,
55 > + Send;
56 fn r#get_device_speed(&self) -> Self::GetDeviceSpeedResponseFut;
57 type GetDeviceIdResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
58 fn r#get_device_id(&self) -> Self::GetDeviceIdResponseFut;
59 type GetDeviceDescriptorResponseFut: std::future::Future<
60 Output = Result<fidl_fuchsia_hardware_usb_descriptor::UsbDeviceDescriptor, fidl::Error>,
61 > + Send;
62 fn r#get_device_descriptor(&self) -> Self::GetDeviceDescriptorResponseFut;
63 type GetConfigurationDescriptorResponseFut: std::future::Future<Output = Result<UsbGetConfigurationDescriptorResult, fidl::Error>>
64 + Send;
65 fn r#get_configuration_descriptor(
66 &self,
67 config: u8,
68 ) -> Self::GetConfigurationDescriptorResponseFut;
69 type GetConfigurationResponseFut: std::future::Future<Output = Result<u8, fidl::Error>> + Send;
70 fn r#get_configuration(&self) -> Self::GetConfigurationResponseFut;
71 type SetConfigurationResponseFut: std::future::Future<Output = Result<UsbSetConfigurationResult, fidl::Error>>
72 + Send;
73 fn r#set_configuration(&self, configuration: u8) -> Self::SetConfigurationResponseFut;
74 type SetInterfaceResponseFut: std::future::Future<Output = Result<UsbSetInterfaceResult, fidl::Error>>
75 + Send;
76 fn r#set_interface(
77 &self,
78 interface_number: u8,
79 alt_setting: u8,
80 ) -> Self::SetInterfaceResponseFut;
81 type ControlTransferResponseFut: std::future::Future<Output = Result<UsbControlTransferResult, fidl::Error>>
82 + Send;
83 fn r#control_transfer(
84 &self,
85 setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
86 timeout_ns: i64,
87 write_data: &[u8],
88 ) -> Self::ControlTransferResponseFut;
89 type EnableEndpointResponseFut: std::future::Future<Output = Result<UsbEnableEndpointResult, fidl::Error>>
90 + Send;
91 fn r#enable_endpoint(
92 &self,
93 ep_desc: &fidl_fuchsia_hardware_usb_descriptor::UsbEndpointDescriptor,
94 ss_com_desc: &fidl_fuchsia_hardware_usb_descriptor::UsbSsEpCompDescriptor,
95 enable: bool,
96 ) -> Self::EnableEndpointResponseFut;
97 type ResetEndpointResponseFut: std::future::Future<Output = Result<UsbResetEndpointResult, fidl::Error>>
98 + Send;
99 fn r#reset_endpoint(&self, ep_address: u8) -> Self::ResetEndpointResponseFut;
100}
101#[derive(Debug)]
102#[cfg(target_os = "fuchsia")]
103pub struct UsbSynchronousProxy {
104 client: fidl::client::sync::Client,
105}
106
107#[cfg(target_os = "fuchsia")]
108impl fidl::endpoints::SynchronousProxy for UsbSynchronousProxy {
109 type Proxy = UsbProxy;
110 type Protocol = UsbMarker;
111
112 fn from_channel(inner: fidl::Channel) -> Self {
113 Self::new(inner)
114 }
115
116 fn into_channel(self) -> fidl::Channel {
117 self.client.into_channel()
118 }
119
120 fn as_channel(&self) -> &fidl::Channel {
121 self.client.as_channel()
122 }
123}
124
125#[cfg(target_os = "fuchsia")]
126impl UsbSynchronousProxy {
127 pub fn new(channel: fidl::Channel) -> Self {
128 Self { client: fidl::client::sync::Client::new(channel) }
129 }
130
131 pub fn into_channel(self) -> fidl::Channel {
132 self.client.into_channel()
133 }
134
135 pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<UsbEvent, fidl::Error> {
138 UsbEvent::decode(self.client.wait_for_event::<UsbMarker>(deadline)?)
139 }
140
141 pub fn r#connect_to_endpoint(
156 &self,
157 mut ep_addr: u8,
158 mut ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
159 ___deadline: zx::MonotonicInstant,
160 ) -> Result<UsbConnectToEndpointResult, fidl::Error> {
161 let _response = self.client.send_query::<
162 UsbConnectToEndpointRequest,
163 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
164 UsbMarker,
165 >(
166 (ep_addr, ep,),
167 0xebea9ba8bbbecb7,
168 fidl::encoding::DynamicFlags::FLEXIBLE,
169 ___deadline,
170 )?
171 .into_result::<UsbMarker>("connect_to_endpoint")?;
172 Ok(_response.map(|x| x))
173 }
174
175 pub fn r#get_device_speed(
177 &self,
178 ___deadline: zx::MonotonicInstant,
179 ) -> Result<fidl_fuchsia_hardware_usb_descriptor::UsbSpeed, fidl::Error> {
180 let _response = self.client.send_query::<
181 fidl::encoding::EmptyPayload,
182 fidl::encoding::FlexibleType<UsbGetDeviceSpeedResponse>,
183 UsbMarker,
184 >(
185 (),
186 0x61f5951481afbc86,
187 fidl::encoding::DynamicFlags::FLEXIBLE,
188 ___deadline,
189 )?
190 .into_result::<UsbMarker>("get_device_speed")?;
191 Ok(_response.speed)
192 }
193
194 pub fn r#get_device_id(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
196 let _response = self.client.send_query::<
197 fidl::encoding::EmptyPayload,
198 fidl::encoding::FlexibleType<UsbGetDeviceIdResponse>,
199 UsbMarker,
200 >(
201 (),
202 0x688b558000e7e7ac,
203 fidl::encoding::DynamicFlags::FLEXIBLE,
204 ___deadline,
205 )?
206 .into_result::<UsbMarker>("get_device_id")?;
207 Ok(_response.device_id)
208 }
209
210 pub fn r#get_device_descriptor(
212 &self,
213 ___deadline: zx::MonotonicInstant,
214 ) -> Result<fidl_fuchsia_hardware_usb_descriptor::UsbDeviceDescriptor, fidl::Error> {
215 let _response = self.client.send_query::<
216 fidl::encoding::EmptyPayload,
217 fidl::encoding::FlexibleType<UsbGetDeviceDescriptorResponse>,
218 UsbMarker,
219 >(
220 (),
221 0x31cf51c03a3f4167,
222 fidl::encoding::DynamicFlags::FLEXIBLE,
223 ___deadline,
224 )?
225 .into_result::<UsbMarker>("get_device_descriptor")?;
226 Ok(_response.descriptor)
227 }
228
229 pub fn r#get_configuration_descriptor(
236 &self,
237 mut config: u8,
238 ___deadline: zx::MonotonicInstant,
239 ) -> Result<UsbGetConfigurationDescriptorResult, fidl::Error> {
240 let _response = self.client.send_query::<
241 UsbGetConfigurationDescriptorRequest,
242 fidl::encoding::FlexibleResultType<UsbGetConfigurationDescriptorResponse, i32>,
243 UsbMarker,
244 >(
245 (config,),
246 0x2a7d59faba5bfdfe,
247 fidl::encoding::DynamicFlags::FLEXIBLE,
248 ___deadline,
249 )?
250 .into_result::<UsbMarker>("get_configuration_descriptor")?;
251 Ok(_response.map(|x| x.descriptor))
252 }
253
254 pub fn r#get_configuration(
256 &self,
257 ___deadline: zx::MonotonicInstant,
258 ) -> Result<u8, fidl::Error> {
259 let _response = self.client.send_query::<
260 fidl::encoding::EmptyPayload,
261 fidl::encoding::FlexibleType<UsbGetConfigurationResponse>,
262 UsbMarker,
263 >(
264 (),
265 0xd4286660f798887,
266 fidl::encoding::DynamicFlags::FLEXIBLE,
267 ___deadline,
268 )?
269 .into_result::<UsbMarker>("get_configuration")?;
270 Ok(_response.configuration)
271 }
272
273 pub fn r#set_configuration(
287 &self,
288 mut configuration: u8,
289 ___deadline: zx::MonotonicInstant,
290 ) -> Result<UsbSetConfigurationResult, fidl::Error> {
291 let _response = self.client.send_query::<
292 UsbSetConfigurationRequest,
293 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
294 UsbMarker,
295 >(
296 (configuration,),
297 0x10e837d081e5ff1f,
298 fidl::encoding::DynamicFlags::FLEXIBLE,
299 ___deadline,
300 )?
301 .into_result::<UsbMarker>("set_configuration")?;
302 Ok(_response.map(|x| x))
303 }
304
305 pub fn r#set_interface(
316 &self,
317 mut interface_number: u8,
318 mut alt_setting: u8,
319 ___deadline: zx::MonotonicInstant,
320 ) -> Result<UsbSetInterfaceResult, fidl::Error> {
321 let _response = self.client.send_query::<
322 UsbSetInterfaceRequest,
323 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
324 UsbMarker,
325 >(
326 (interface_number, alt_setting,),
327 0xea420cff57f9147,
328 fidl::encoding::DynamicFlags::FLEXIBLE,
329 ___deadline,
330 )?
331 .into_result::<UsbMarker>("set_interface")?;
332 Ok(_response.map(|x| x))
333 }
334
335 pub fn r#control_transfer(
354 &self,
355 mut setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
356 mut timeout_ns: i64,
357 mut write_data: &[u8],
358 ___deadline: zx::MonotonicInstant,
359 ) -> Result<UsbControlTransferResult, fidl::Error> {
360 let _response = self.client.send_query::<
361 UsbControlTransferRequest,
362 fidl::encoding::FlexibleResultType<UsbControlTransferResponse, i32>,
363 UsbMarker,
364 >(
365 (setup, timeout_ns, write_data,),
366 0x985e9d9082b78e4,
367 fidl::encoding::DynamicFlags::FLEXIBLE,
368 ___deadline,
369 )?
370 .into_result::<UsbMarker>("control_transfer")?;
371 Ok(_response.map(|x| x.read_data))
372 }
373
374 pub fn r#enable_endpoint(
385 &self,
386 mut ep_desc: &fidl_fuchsia_hardware_usb_descriptor::UsbEndpointDescriptor,
387 mut ss_com_desc: &fidl_fuchsia_hardware_usb_descriptor::UsbSsEpCompDescriptor,
388 mut enable: bool,
389 ___deadline: zx::MonotonicInstant,
390 ) -> Result<UsbEnableEndpointResult, fidl::Error> {
391 let _response = self.client.send_query::<
392 UsbEnableEndpointRequest,
393 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
394 UsbMarker,
395 >(
396 (ep_desc, ss_com_desc, enable,),
397 0xbdbe6ed69b0b844,
398 fidl::encoding::DynamicFlags::FLEXIBLE,
399 ___deadline,
400 )?
401 .into_result::<UsbMarker>("enable_endpoint")?;
402 Ok(_response.map(|x| x))
403 }
404
405 pub fn r#reset_endpoint(
416 &self,
417 mut ep_address: u8,
418 ___deadline: zx::MonotonicInstant,
419 ) -> Result<UsbResetEndpointResult, fidl::Error> {
420 let _response = self.client.send_query::<
421 UsbResetEndpointRequest,
422 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
423 UsbMarker,
424 >(
425 (ep_address,),
426 0x78325ec2b0014867,
427 fidl::encoding::DynamicFlags::FLEXIBLE,
428 ___deadline,
429 )?
430 .into_result::<UsbMarker>("reset_endpoint")?;
431 Ok(_response.map(|x| x))
432 }
433}
434
435#[cfg(target_os = "fuchsia")]
436impl From<UsbSynchronousProxy> for zx::NullableHandle {
437 fn from(value: UsbSynchronousProxy) -> Self {
438 value.into_channel().into()
439 }
440}
441
442#[cfg(target_os = "fuchsia")]
443impl From<fidl::Channel> for UsbSynchronousProxy {
444 fn from(value: fidl::Channel) -> Self {
445 Self::new(value)
446 }
447}
448
449#[cfg(target_os = "fuchsia")]
450impl fidl::endpoints::FromClient for UsbSynchronousProxy {
451 type Protocol = UsbMarker;
452
453 fn from_client(value: fidl::endpoints::ClientEnd<UsbMarker>) -> Self {
454 Self::new(value.into_channel())
455 }
456}
457
458#[derive(Debug, Clone)]
459pub struct UsbProxy {
460 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
461}
462
463impl fidl::endpoints::Proxy for UsbProxy {
464 type Protocol = UsbMarker;
465
466 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
467 Self::new(inner)
468 }
469
470 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
471 self.client.into_channel().map_err(|client| Self { client })
472 }
473
474 fn as_channel(&self) -> &::fidl::AsyncChannel {
475 self.client.as_channel()
476 }
477}
478
479impl UsbProxy {
480 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
482 let protocol_name = <UsbMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
483 Self { client: fidl::client::Client::new(channel, protocol_name) }
484 }
485
486 pub fn take_event_stream(&self) -> UsbEventStream {
492 UsbEventStream { event_receiver: self.client.take_event_receiver() }
493 }
494
495 pub fn r#connect_to_endpoint(
510 &self,
511 mut ep_addr: u8,
512 mut ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
513 ) -> fidl::client::QueryResponseFut<
514 UsbConnectToEndpointResult,
515 fidl::encoding::DefaultFuchsiaResourceDialect,
516 > {
517 UsbProxyInterface::r#connect_to_endpoint(self, ep_addr, ep)
518 }
519
520 pub fn r#get_device_speed(
522 &self,
523 ) -> fidl::client::QueryResponseFut<
524 fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
525 fidl::encoding::DefaultFuchsiaResourceDialect,
526 > {
527 UsbProxyInterface::r#get_device_speed(self)
528 }
529
530 pub fn r#get_device_id(
532 &self,
533 ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
534 UsbProxyInterface::r#get_device_id(self)
535 }
536
537 pub fn r#get_device_descriptor(
539 &self,
540 ) -> fidl::client::QueryResponseFut<
541 fidl_fuchsia_hardware_usb_descriptor::UsbDeviceDescriptor,
542 fidl::encoding::DefaultFuchsiaResourceDialect,
543 > {
544 UsbProxyInterface::r#get_device_descriptor(self)
545 }
546
547 pub fn r#get_configuration_descriptor(
554 &self,
555 mut config: u8,
556 ) -> fidl::client::QueryResponseFut<
557 UsbGetConfigurationDescriptorResult,
558 fidl::encoding::DefaultFuchsiaResourceDialect,
559 > {
560 UsbProxyInterface::r#get_configuration_descriptor(self, config)
561 }
562
563 pub fn r#get_configuration(
565 &self,
566 ) -> fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect> {
567 UsbProxyInterface::r#get_configuration(self)
568 }
569
570 pub fn r#set_configuration(
584 &self,
585 mut configuration: u8,
586 ) -> fidl::client::QueryResponseFut<
587 UsbSetConfigurationResult,
588 fidl::encoding::DefaultFuchsiaResourceDialect,
589 > {
590 UsbProxyInterface::r#set_configuration(self, configuration)
591 }
592
593 pub fn r#set_interface(
604 &self,
605 mut interface_number: u8,
606 mut alt_setting: u8,
607 ) -> fidl::client::QueryResponseFut<
608 UsbSetInterfaceResult,
609 fidl::encoding::DefaultFuchsiaResourceDialect,
610 > {
611 UsbProxyInterface::r#set_interface(self, interface_number, alt_setting)
612 }
613
614 pub fn r#control_transfer(
633 &self,
634 mut setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
635 mut timeout_ns: i64,
636 mut write_data: &[u8],
637 ) -> fidl::client::QueryResponseFut<
638 UsbControlTransferResult,
639 fidl::encoding::DefaultFuchsiaResourceDialect,
640 > {
641 UsbProxyInterface::r#control_transfer(self, setup, timeout_ns, write_data)
642 }
643
644 pub fn r#enable_endpoint(
655 &self,
656 mut ep_desc: &fidl_fuchsia_hardware_usb_descriptor::UsbEndpointDescriptor,
657 mut ss_com_desc: &fidl_fuchsia_hardware_usb_descriptor::UsbSsEpCompDescriptor,
658 mut enable: bool,
659 ) -> fidl::client::QueryResponseFut<
660 UsbEnableEndpointResult,
661 fidl::encoding::DefaultFuchsiaResourceDialect,
662 > {
663 UsbProxyInterface::r#enable_endpoint(self, ep_desc, ss_com_desc, enable)
664 }
665
666 pub fn r#reset_endpoint(
677 &self,
678 mut ep_address: u8,
679 ) -> fidl::client::QueryResponseFut<
680 UsbResetEndpointResult,
681 fidl::encoding::DefaultFuchsiaResourceDialect,
682 > {
683 UsbProxyInterface::r#reset_endpoint(self, ep_address)
684 }
685}
686
687impl UsbProxyInterface for UsbProxy {
688 type ConnectToEndpointResponseFut = fidl::client::QueryResponseFut<
689 UsbConnectToEndpointResult,
690 fidl::encoding::DefaultFuchsiaResourceDialect,
691 >;
692 fn r#connect_to_endpoint(
693 &self,
694 mut ep_addr: u8,
695 mut ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
696 ) -> Self::ConnectToEndpointResponseFut {
697 fn _decode(
698 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
699 ) -> Result<UsbConnectToEndpointResult, fidl::Error> {
700 let _response = fidl::client::decode_transaction_body::<
701 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
702 fidl::encoding::DefaultFuchsiaResourceDialect,
703 0xebea9ba8bbbecb7,
704 >(_buf?)?
705 .into_result::<UsbMarker>("connect_to_endpoint")?;
706 Ok(_response.map(|x| x))
707 }
708 self.client
709 .send_query_and_decode::<UsbConnectToEndpointRequest, UsbConnectToEndpointResult>(
710 (ep_addr, ep),
711 0xebea9ba8bbbecb7,
712 fidl::encoding::DynamicFlags::FLEXIBLE,
713 _decode,
714 )
715 }
716
717 type GetDeviceSpeedResponseFut = fidl::client::QueryResponseFut<
718 fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
719 fidl::encoding::DefaultFuchsiaResourceDialect,
720 >;
721 fn r#get_device_speed(&self) -> Self::GetDeviceSpeedResponseFut {
722 fn _decode(
723 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
724 ) -> Result<fidl_fuchsia_hardware_usb_descriptor::UsbSpeed, fidl::Error> {
725 let _response = fidl::client::decode_transaction_body::<
726 fidl::encoding::FlexibleType<UsbGetDeviceSpeedResponse>,
727 fidl::encoding::DefaultFuchsiaResourceDialect,
728 0x61f5951481afbc86,
729 >(_buf?)?
730 .into_result::<UsbMarker>("get_device_speed")?;
731 Ok(_response.speed)
732 }
733 self.client.send_query_and_decode::<
734 fidl::encoding::EmptyPayload,
735 fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
736 >(
737 (),
738 0x61f5951481afbc86,
739 fidl::encoding::DynamicFlags::FLEXIBLE,
740 _decode,
741 )
742 }
743
744 type GetDeviceIdResponseFut =
745 fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
746 fn r#get_device_id(&self) -> Self::GetDeviceIdResponseFut {
747 fn _decode(
748 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
749 ) -> Result<u32, fidl::Error> {
750 let _response = fidl::client::decode_transaction_body::<
751 fidl::encoding::FlexibleType<UsbGetDeviceIdResponse>,
752 fidl::encoding::DefaultFuchsiaResourceDialect,
753 0x688b558000e7e7ac,
754 >(_buf?)?
755 .into_result::<UsbMarker>("get_device_id")?;
756 Ok(_response.device_id)
757 }
758 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
759 (),
760 0x688b558000e7e7ac,
761 fidl::encoding::DynamicFlags::FLEXIBLE,
762 _decode,
763 )
764 }
765
766 type GetDeviceDescriptorResponseFut = fidl::client::QueryResponseFut<
767 fidl_fuchsia_hardware_usb_descriptor::UsbDeviceDescriptor,
768 fidl::encoding::DefaultFuchsiaResourceDialect,
769 >;
770 fn r#get_device_descriptor(&self) -> Self::GetDeviceDescriptorResponseFut {
771 fn _decode(
772 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
773 ) -> Result<fidl_fuchsia_hardware_usb_descriptor::UsbDeviceDescriptor, fidl::Error>
774 {
775 let _response = fidl::client::decode_transaction_body::<
776 fidl::encoding::FlexibleType<UsbGetDeviceDescriptorResponse>,
777 fidl::encoding::DefaultFuchsiaResourceDialect,
778 0x31cf51c03a3f4167,
779 >(_buf?)?
780 .into_result::<UsbMarker>("get_device_descriptor")?;
781 Ok(_response.descriptor)
782 }
783 self.client.send_query_and_decode::<
784 fidl::encoding::EmptyPayload,
785 fidl_fuchsia_hardware_usb_descriptor::UsbDeviceDescriptor,
786 >(
787 (),
788 0x31cf51c03a3f4167,
789 fidl::encoding::DynamicFlags::FLEXIBLE,
790 _decode,
791 )
792 }
793
794 type GetConfigurationDescriptorResponseFut = fidl::client::QueryResponseFut<
795 UsbGetConfigurationDescriptorResult,
796 fidl::encoding::DefaultFuchsiaResourceDialect,
797 >;
798 fn r#get_configuration_descriptor(
799 &self,
800 mut config: u8,
801 ) -> Self::GetConfigurationDescriptorResponseFut {
802 fn _decode(
803 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
804 ) -> Result<UsbGetConfigurationDescriptorResult, fidl::Error> {
805 let _response = fidl::client::decode_transaction_body::<
806 fidl::encoding::FlexibleResultType<UsbGetConfigurationDescriptorResponse, i32>,
807 fidl::encoding::DefaultFuchsiaResourceDialect,
808 0x2a7d59faba5bfdfe,
809 >(_buf?)?
810 .into_result::<UsbMarker>("get_configuration_descriptor")?;
811 Ok(_response.map(|x| x.descriptor))
812 }
813 self.client.send_query_and_decode::<
814 UsbGetConfigurationDescriptorRequest,
815 UsbGetConfigurationDescriptorResult,
816 >(
817 (config,),
818 0x2a7d59faba5bfdfe,
819 fidl::encoding::DynamicFlags::FLEXIBLE,
820 _decode,
821 )
822 }
823
824 type GetConfigurationResponseFut =
825 fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect>;
826 fn r#get_configuration(&self) -> Self::GetConfigurationResponseFut {
827 fn _decode(
828 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
829 ) -> Result<u8, fidl::Error> {
830 let _response = fidl::client::decode_transaction_body::<
831 fidl::encoding::FlexibleType<UsbGetConfigurationResponse>,
832 fidl::encoding::DefaultFuchsiaResourceDialect,
833 0xd4286660f798887,
834 >(_buf?)?
835 .into_result::<UsbMarker>("get_configuration")?;
836 Ok(_response.configuration)
837 }
838 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u8>(
839 (),
840 0xd4286660f798887,
841 fidl::encoding::DynamicFlags::FLEXIBLE,
842 _decode,
843 )
844 }
845
846 type SetConfigurationResponseFut = fidl::client::QueryResponseFut<
847 UsbSetConfigurationResult,
848 fidl::encoding::DefaultFuchsiaResourceDialect,
849 >;
850 fn r#set_configuration(&self, mut configuration: u8) -> Self::SetConfigurationResponseFut {
851 fn _decode(
852 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
853 ) -> Result<UsbSetConfigurationResult, fidl::Error> {
854 let _response = fidl::client::decode_transaction_body::<
855 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
856 fidl::encoding::DefaultFuchsiaResourceDialect,
857 0x10e837d081e5ff1f,
858 >(_buf?)?
859 .into_result::<UsbMarker>("set_configuration")?;
860 Ok(_response.map(|x| x))
861 }
862 self.client.send_query_and_decode::<UsbSetConfigurationRequest, UsbSetConfigurationResult>(
863 (configuration,),
864 0x10e837d081e5ff1f,
865 fidl::encoding::DynamicFlags::FLEXIBLE,
866 _decode,
867 )
868 }
869
870 type SetInterfaceResponseFut = fidl::client::QueryResponseFut<
871 UsbSetInterfaceResult,
872 fidl::encoding::DefaultFuchsiaResourceDialect,
873 >;
874 fn r#set_interface(
875 &self,
876 mut interface_number: u8,
877 mut alt_setting: u8,
878 ) -> Self::SetInterfaceResponseFut {
879 fn _decode(
880 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
881 ) -> Result<UsbSetInterfaceResult, fidl::Error> {
882 let _response = fidl::client::decode_transaction_body::<
883 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
884 fidl::encoding::DefaultFuchsiaResourceDialect,
885 0xea420cff57f9147,
886 >(_buf?)?
887 .into_result::<UsbMarker>("set_interface")?;
888 Ok(_response.map(|x| x))
889 }
890 self.client.send_query_and_decode::<UsbSetInterfaceRequest, UsbSetInterfaceResult>(
891 (interface_number, alt_setting),
892 0xea420cff57f9147,
893 fidl::encoding::DynamicFlags::FLEXIBLE,
894 _decode,
895 )
896 }
897
898 type ControlTransferResponseFut = fidl::client::QueryResponseFut<
899 UsbControlTransferResult,
900 fidl::encoding::DefaultFuchsiaResourceDialect,
901 >;
902 fn r#control_transfer(
903 &self,
904 mut setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
905 mut timeout_ns: i64,
906 mut write_data: &[u8],
907 ) -> Self::ControlTransferResponseFut {
908 fn _decode(
909 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
910 ) -> Result<UsbControlTransferResult, fidl::Error> {
911 let _response = fidl::client::decode_transaction_body::<
912 fidl::encoding::FlexibleResultType<UsbControlTransferResponse, i32>,
913 fidl::encoding::DefaultFuchsiaResourceDialect,
914 0x985e9d9082b78e4,
915 >(_buf?)?
916 .into_result::<UsbMarker>("control_transfer")?;
917 Ok(_response.map(|x| x.read_data))
918 }
919 self.client.send_query_and_decode::<UsbControlTransferRequest, UsbControlTransferResult>(
920 (setup, timeout_ns, write_data),
921 0x985e9d9082b78e4,
922 fidl::encoding::DynamicFlags::FLEXIBLE,
923 _decode,
924 )
925 }
926
927 type EnableEndpointResponseFut = fidl::client::QueryResponseFut<
928 UsbEnableEndpointResult,
929 fidl::encoding::DefaultFuchsiaResourceDialect,
930 >;
931 fn r#enable_endpoint(
932 &self,
933 mut ep_desc: &fidl_fuchsia_hardware_usb_descriptor::UsbEndpointDescriptor,
934 mut ss_com_desc: &fidl_fuchsia_hardware_usb_descriptor::UsbSsEpCompDescriptor,
935 mut enable: bool,
936 ) -> Self::EnableEndpointResponseFut {
937 fn _decode(
938 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
939 ) -> Result<UsbEnableEndpointResult, fidl::Error> {
940 let _response = fidl::client::decode_transaction_body::<
941 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
942 fidl::encoding::DefaultFuchsiaResourceDialect,
943 0xbdbe6ed69b0b844,
944 >(_buf?)?
945 .into_result::<UsbMarker>("enable_endpoint")?;
946 Ok(_response.map(|x| x))
947 }
948 self.client.send_query_and_decode::<UsbEnableEndpointRequest, UsbEnableEndpointResult>(
949 (ep_desc, ss_com_desc, enable),
950 0xbdbe6ed69b0b844,
951 fidl::encoding::DynamicFlags::FLEXIBLE,
952 _decode,
953 )
954 }
955
956 type ResetEndpointResponseFut = fidl::client::QueryResponseFut<
957 UsbResetEndpointResult,
958 fidl::encoding::DefaultFuchsiaResourceDialect,
959 >;
960 fn r#reset_endpoint(&self, mut ep_address: u8) -> Self::ResetEndpointResponseFut {
961 fn _decode(
962 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
963 ) -> Result<UsbResetEndpointResult, fidl::Error> {
964 let _response = fidl::client::decode_transaction_body::<
965 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
966 fidl::encoding::DefaultFuchsiaResourceDialect,
967 0x78325ec2b0014867,
968 >(_buf?)?
969 .into_result::<UsbMarker>("reset_endpoint")?;
970 Ok(_response.map(|x| x))
971 }
972 self.client.send_query_and_decode::<UsbResetEndpointRequest, UsbResetEndpointResult>(
973 (ep_address,),
974 0x78325ec2b0014867,
975 fidl::encoding::DynamicFlags::FLEXIBLE,
976 _decode,
977 )
978 }
979}
980
981pub struct UsbEventStream {
982 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
983}
984
985impl std::marker::Unpin for UsbEventStream {}
986
987impl futures::stream::FusedStream for UsbEventStream {
988 fn is_terminated(&self) -> bool {
989 self.event_receiver.is_terminated()
990 }
991}
992
993impl futures::Stream for UsbEventStream {
994 type Item = Result<UsbEvent, fidl::Error>;
995
996 fn poll_next(
997 mut self: std::pin::Pin<&mut Self>,
998 cx: &mut std::task::Context<'_>,
999 ) -> std::task::Poll<Option<Self::Item>> {
1000 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1001 &mut self.event_receiver,
1002 cx
1003 )?) {
1004 Some(buf) => std::task::Poll::Ready(Some(UsbEvent::decode(buf))),
1005 None => std::task::Poll::Ready(None),
1006 }
1007 }
1008}
1009
1010#[derive(Debug)]
1011pub enum UsbEvent {
1012 #[non_exhaustive]
1013 _UnknownEvent {
1014 ordinal: u64,
1016 },
1017}
1018
1019impl UsbEvent {
1020 fn decode(
1022 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1023 ) -> Result<UsbEvent, fidl::Error> {
1024 let (bytes, _handles) = buf.split_mut();
1025 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1026 debug_assert_eq!(tx_header.tx_id, 0);
1027 match tx_header.ordinal {
1028 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1029 Ok(UsbEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1030 }
1031 _ => Err(fidl::Error::UnknownOrdinal {
1032 ordinal: tx_header.ordinal,
1033 protocol_name: <UsbMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1034 }),
1035 }
1036 }
1037}
1038
1039pub struct UsbRequestStream {
1041 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1042 is_terminated: bool,
1043}
1044
1045impl std::marker::Unpin for UsbRequestStream {}
1046
1047impl futures::stream::FusedStream for UsbRequestStream {
1048 fn is_terminated(&self) -> bool {
1049 self.is_terminated
1050 }
1051}
1052
1053impl fidl::endpoints::RequestStream for UsbRequestStream {
1054 type Protocol = UsbMarker;
1055 type ControlHandle = UsbControlHandle;
1056
1057 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1058 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1059 }
1060
1061 fn control_handle(&self) -> Self::ControlHandle {
1062 UsbControlHandle { inner: self.inner.clone() }
1063 }
1064
1065 fn into_inner(
1066 self,
1067 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1068 {
1069 (self.inner, self.is_terminated)
1070 }
1071
1072 fn from_inner(
1073 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1074 is_terminated: bool,
1075 ) -> Self {
1076 Self { inner, is_terminated }
1077 }
1078}
1079
1080impl futures::Stream for UsbRequestStream {
1081 type Item = Result<UsbRequest, fidl::Error>;
1082
1083 fn poll_next(
1084 mut self: std::pin::Pin<&mut Self>,
1085 cx: &mut std::task::Context<'_>,
1086 ) -> std::task::Poll<Option<Self::Item>> {
1087 let this = &mut *self;
1088 if this.inner.check_shutdown(cx) {
1089 this.is_terminated = true;
1090 return std::task::Poll::Ready(None);
1091 }
1092 if this.is_terminated {
1093 panic!("polled UsbRequestStream after completion");
1094 }
1095 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1096 |bytes, handles| {
1097 match this.inner.channel().read_etc(cx, bytes, handles) {
1098 std::task::Poll::Ready(Ok(())) => {}
1099 std::task::Poll::Pending => return std::task::Poll::Pending,
1100 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1101 this.is_terminated = true;
1102 return std::task::Poll::Ready(None);
1103 }
1104 std::task::Poll::Ready(Err(e)) => {
1105 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1106 e.into(),
1107 ))));
1108 }
1109 }
1110
1111 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1113
1114 std::task::Poll::Ready(Some(match header.ordinal {
1115 0xebea9ba8bbbecb7 => {
1116 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1117 let mut req = fidl::new_empty!(
1118 UsbConnectToEndpointRequest,
1119 fidl::encoding::DefaultFuchsiaResourceDialect
1120 );
1121 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbConnectToEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
1122 let control_handle = UsbControlHandle { inner: this.inner.clone() };
1123 Ok(UsbRequest::ConnectToEndpoint {
1124 ep_addr: req.ep_addr,
1125 ep: req.ep,
1126
1127 responder: UsbConnectToEndpointResponder {
1128 control_handle: std::mem::ManuallyDrop::new(control_handle),
1129 tx_id: header.tx_id,
1130 },
1131 })
1132 }
1133 0x61f5951481afbc86 => {
1134 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1135 let mut req = fidl::new_empty!(
1136 fidl::encoding::EmptyPayload,
1137 fidl::encoding::DefaultFuchsiaResourceDialect
1138 );
1139 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1140 let control_handle = UsbControlHandle { inner: this.inner.clone() };
1141 Ok(UsbRequest::GetDeviceSpeed {
1142 responder: UsbGetDeviceSpeedResponder {
1143 control_handle: std::mem::ManuallyDrop::new(control_handle),
1144 tx_id: header.tx_id,
1145 },
1146 })
1147 }
1148 0x688b558000e7e7ac => {
1149 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1150 let mut req = fidl::new_empty!(
1151 fidl::encoding::EmptyPayload,
1152 fidl::encoding::DefaultFuchsiaResourceDialect
1153 );
1154 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1155 let control_handle = UsbControlHandle { inner: this.inner.clone() };
1156 Ok(UsbRequest::GetDeviceId {
1157 responder: UsbGetDeviceIdResponder {
1158 control_handle: std::mem::ManuallyDrop::new(control_handle),
1159 tx_id: header.tx_id,
1160 },
1161 })
1162 }
1163 0x31cf51c03a3f4167 => {
1164 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1165 let mut req = fidl::new_empty!(
1166 fidl::encoding::EmptyPayload,
1167 fidl::encoding::DefaultFuchsiaResourceDialect
1168 );
1169 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1170 let control_handle = UsbControlHandle { inner: this.inner.clone() };
1171 Ok(UsbRequest::GetDeviceDescriptor {
1172 responder: UsbGetDeviceDescriptorResponder {
1173 control_handle: std::mem::ManuallyDrop::new(control_handle),
1174 tx_id: header.tx_id,
1175 },
1176 })
1177 }
1178 0x2a7d59faba5bfdfe => {
1179 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1180 let mut req = fidl::new_empty!(
1181 UsbGetConfigurationDescriptorRequest,
1182 fidl::encoding::DefaultFuchsiaResourceDialect
1183 );
1184 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbGetConfigurationDescriptorRequest>(&header, _body_bytes, handles, &mut req)?;
1185 let control_handle = UsbControlHandle { inner: this.inner.clone() };
1186 Ok(UsbRequest::GetConfigurationDescriptor {
1187 config: req.config,
1188
1189 responder: UsbGetConfigurationDescriptorResponder {
1190 control_handle: std::mem::ManuallyDrop::new(control_handle),
1191 tx_id: header.tx_id,
1192 },
1193 })
1194 }
1195 0xd4286660f798887 => {
1196 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1197 let mut req = fidl::new_empty!(
1198 fidl::encoding::EmptyPayload,
1199 fidl::encoding::DefaultFuchsiaResourceDialect
1200 );
1201 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1202 let control_handle = UsbControlHandle { inner: this.inner.clone() };
1203 Ok(UsbRequest::GetConfiguration {
1204 responder: UsbGetConfigurationResponder {
1205 control_handle: std::mem::ManuallyDrop::new(control_handle),
1206 tx_id: header.tx_id,
1207 },
1208 })
1209 }
1210 0x10e837d081e5ff1f => {
1211 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1212 let mut req = fidl::new_empty!(
1213 UsbSetConfigurationRequest,
1214 fidl::encoding::DefaultFuchsiaResourceDialect
1215 );
1216 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbSetConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
1217 let control_handle = UsbControlHandle { inner: this.inner.clone() };
1218 Ok(UsbRequest::SetConfiguration {
1219 configuration: req.configuration,
1220
1221 responder: UsbSetConfigurationResponder {
1222 control_handle: std::mem::ManuallyDrop::new(control_handle),
1223 tx_id: header.tx_id,
1224 },
1225 })
1226 }
1227 0xea420cff57f9147 => {
1228 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1229 let mut req = fidl::new_empty!(
1230 UsbSetInterfaceRequest,
1231 fidl::encoding::DefaultFuchsiaResourceDialect
1232 );
1233 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbSetInterfaceRequest>(&header, _body_bytes, handles, &mut req)?;
1234 let control_handle = UsbControlHandle { inner: this.inner.clone() };
1235 Ok(UsbRequest::SetInterface {
1236 interface_number: req.interface_number,
1237 alt_setting: req.alt_setting,
1238
1239 responder: UsbSetInterfaceResponder {
1240 control_handle: std::mem::ManuallyDrop::new(control_handle),
1241 tx_id: header.tx_id,
1242 },
1243 })
1244 }
1245 0x985e9d9082b78e4 => {
1246 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1247 let mut req = fidl::new_empty!(
1248 UsbControlTransferRequest,
1249 fidl::encoding::DefaultFuchsiaResourceDialect
1250 );
1251 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbControlTransferRequest>(&header, _body_bytes, handles, &mut req)?;
1252 let control_handle = UsbControlHandle { inner: this.inner.clone() };
1253 Ok(UsbRequest::ControlTransfer {
1254 setup: req.setup,
1255 timeout_ns: req.timeout_ns,
1256 write_data: req.write_data,
1257
1258 responder: UsbControlTransferResponder {
1259 control_handle: std::mem::ManuallyDrop::new(control_handle),
1260 tx_id: header.tx_id,
1261 },
1262 })
1263 }
1264 0xbdbe6ed69b0b844 => {
1265 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1266 let mut req = fidl::new_empty!(
1267 UsbEnableEndpointRequest,
1268 fidl::encoding::DefaultFuchsiaResourceDialect
1269 );
1270 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbEnableEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
1271 let control_handle = UsbControlHandle { inner: this.inner.clone() };
1272 Ok(UsbRequest::EnableEndpoint {
1273 ep_desc: req.ep_desc,
1274 ss_com_desc: req.ss_com_desc,
1275 enable: req.enable,
1276
1277 responder: UsbEnableEndpointResponder {
1278 control_handle: std::mem::ManuallyDrop::new(control_handle),
1279 tx_id: header.tx_id,
1280 },
1281 })
1282 }
1283 0x78325ec2b0014867 => {
1284 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1285 let mut req = fidl::new_empty!(
1286 UsbResetEndpointRequest,
1287 fidl::encoding::DefaultFuchsiaResourceDialect
1288 );
1289 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbResetEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
1290 let control_handle = UsbControlHandle { inner: this.inner.clone() };
1291 Ok(UsbRequest::ResetEndpoint {
1292 ep_address: req.ep_address,
1293
1294 responder: UsbResetEndpointResponder {
1295 control_handle: std::mem::ManuallyDrop::new(control_handle),
1296 tx_id: header.tx_id,
1297 },
1298 })
1299 }
1300 _ if header.tx_id == 0
1301 && header
1302 .dynamic_flags()
1303 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1304 {
1305 Ok(UsbRequest::_UnknownMethod {
1306 ordinal: header.ordinal,
1307 control_handle: UsbControlHandle { inner: this.inner.clone() },
1308 method_type: fidl::MethodType::OneWay,
1309 })
1310 }
1311 _ if header
1312 .dynamic_flags()
1313 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1314 {
1315 this.inner.send_framework_err(
1316 fidl::encoding::FrameworkErr::UnknownMethod,
1317 header.tx_id,
1318 header.ordinal,
1319 header.dynamic_flags(),
1320 (bytes, handles),
1321 )?;
1322 Ok(UsbRequest::_UnknownMethod {
1323 ordinal: header.ordinal,
1324 control_handle: UsbControlHandle { inner: this.inner.clone() },
1325 method_type: fidl::MethodType::TwoWay,
1326 })
1327 }
1328 _ => Err(fidl::Error::UnknownOrdinal {
1329 ordinal: header.ordinal,
1330 protocol_name: <UsbMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1331 }),
1332 }))
1333 },
1334 )
1335 }
1336}
1337
1338#[derive(Debug)]
1343pub enum UsbRequest {
1344 ConnectToEndpoint {
1359 ep_addr: u8,
1360 ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
1361 responder: UsbConnectToEndpointResponder,
1362 },
1363 GetDeviceSpeed { responder: UsbGetDeviceSpeedResponder },
1365 GetDeviceId { responder: UsbGetDeviceIdResponder },
1367 GetDeviceDescriptor { responder: UsbGetDeviceDescriptorResponder },
1369 GetConfigurationDescriptor { config: u8, responder: UsbGetConfigurationDescriptorResponder },
1376 GetConfiguration { responder: UsbGetConfigurationResponder },
1378 SetConfiguration { configuration: u8, responder: UsbSetConfigurationResponder },
1392 SetInterface { interface_number: u8, alt_setting: u8, responder: UsbSetInterfaceResponder },
1403 ControlTransfer {
1422 setup: fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
1423 timeout_ns: i64,
1424 write_data: Vec<u8>,
1425 responder: UsbControlTransferResponder,
1426 },
1427 EnableEndpoint {
1438 ep_desc: fidl_fuchsia_hardware_usb_descriptor::UsbEndpointDescriptor,
1439 ss_com_desc: fidl_fuchsia_hardware_usb_descriptor::UsbSsEpCompDescriptor,
1440 enable: bool,
1441 responder: UsbEnableEndpointResponder,
1442 },
1443 ResetEndpoint { ep_address: u8, responder: UsbResetEndpointResponder },
1454 #[non_exhaustive]
1456 _UnknownMethod {
1457 ordinal: u64,
1459 control_handle: UsbControlHandle,
1460 method_type: fidl::MethodType,
1461 },
1462}
1463
1464impl UsbRequest {
1465 #[allow(irrefutable_let_patterns)]
1466 pub fn into_connect_to_endpoint(
1467 self,
1468 ) -> Option<(
1469 u8,
1470 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
1471 UsbConnectToEndpointResponder,
1472 )> {
1473 if let UsbRequest::ConnectToEndpoint { ep_addr, ep, responder } = self {
1474 Some((ep_addr, ep, responder))
1475 } else {
1476 None
1477 }
1478 }
1479
1480 #[allow(irrefutable_let_patterns)]
1481 pub fn into_get_device_speed(self) -> Option<(UsbGetDeviceSpeedResponder)> {
1482 if let UsbRequest::GetDeviceSpeed { responder } = self { Some((responder)) } else { None }
1483 }
1484
1485 #[allow(irrefutable_let_patterns)]
1486 pub fn into_get_device_id(self) -> Option<(UsbGetDeviceIdResponder)> {
1487 if let UsbRequest::GetDeviceId { responder } = self { Some((responder)) } else { None }
1488 }
1489
1490 #[allow(irrefutable_let_patterns)]
1491 pub fn into_get_device_descriptor(self) -> Option<(UsbGetDeviceDescriptorResponder)> {
1492 if let UsbRequest::GetDeviceDescriptor { responder } = self {
1493 Some((responder))
1494 } else {
1495 None
1496 }
1497 }
1498
1499 #[allow(irrefutable_let_patterns)]
1500 pub fn into_get_configuration_descriptor(
1501 self,
1502 ) -> Option<(u8, UsbGetConfigurationDescriptorResponder)> {
1503 if let UsbRequest::GetConfigurationDescriptor { config, responder } = self {
1504 Some((config, responder))
1505 } else {
1506 None
1507 }
1508 }
1509
1510 #[allow(irrefutable_let_patterns)]
1511 pub fn into_get_configuration(self) -> Option<(UsbGetConfigurationResponder)> {
1512 if let UsbRequest::GetConfiguration { responder } = self { Some((responder)) } else { None }
1513 }
1514
1515 #[allow(irrefutable_let_patterns)]
1516 pub fn into_set_configuration(self) -> Option<(u8, UsbSetConfigurationResponder)> {
1517 if let UsbRequest::SetConfiguration { configuration, responder } = self {
1518 Some((configuration, responder))
1519 } else {
1520 None
1521 }
1522 }
1523
1524 #[allow(irrefutable_let_patterns)]
1525 pub fn into_set_interface(self) -> Option<(u8, u8, UsbSetInterfaceResponder)> {
1526 if let UsbRequest::SetInterface { interface_number, alt_setting, responder } = self {
1527 Some((interface_number, alt_setting, responder))
1528 } else {
1529 None
1530 }
1531 }
1532
1533 #[allow(irrefutable_let_patterns)]
1534 pub fn into_control_transfer(
1535 self,
1536 ) -> Option<(
1537 fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
1538 i64,
1539 Vec<u8>,
1540 UsbControlTransferResponder,
1541 )> {
1542 if let UsbRequest::ControlTransfer { setup, timeout_ns, write_data, responder } = self {
1543 Some((setup, timeout_ns, write_data, responder))
1544 } else {
1545 None
1546 }
1547 }
1548
1549 #[allow(irrefutable_let_patterns)]
1550 pub fn into_enable_endpoint(
1551 self,
1552 ) -> Option<(
1553 fidl_fuchsia_hardware_usb_descriptor::UsbEndpointDescriptor,
1554 fidl_fuchsia_hardware_usb_descriptor::UsbSsEpCompDescriptor,
1555 bool,
1556 UsbEnableEndpointResponder,
1557 )> {
1558 if let UsbRequest::EnableEndpoint { ep_desc, ss_com_desc, enable, responder } = self {
1559 Some((ep_desc, ss_com_desc, enable, responder))
1560 } else {
1561 None
1562 }
1563 }
1564
1565 #[allow(irrefutable_let_patterns)]
1566 pub fn into_reset_endpoint(self) -> Option<(u8, UsbResetEndpointResponder)> {
1567 if let UsbRequest::ResetEndpoint { ep_address, responder } = self {
1568 Some((ep_address, responder))
1569 } else {
1570 None
1571 }
1572 }
1573
1574 pub fn method_name(&self) -> &'static str {
1576 match *self {
1577 UsbRequest::ConnectToEndpoint { .. } => "connect_to_endpoint",
1578 UsbRequest::GetDeviceSpeed { .. } => "get_device_speed",
1579 UsbRequest::GetDeviceId { .. } => "get_device_id",
1580 UsbRequest::GetDeviceDescriptor { .. } => "get_device_descriptor",
1581 UsbRequest::GetConfigurationDescriptor { .. } => "get_configuration_descriptor",
1582 UsbRequest::GetConfiguration { .. } => "get_configuration",
1583 UsbRequest::SetConfiguration { .. } => "set_configuration",
1584 UsbRequest::SetInterface { .. } => "set_interface",
1585 UsbRequest::ControlTransfer { .. } => "control_transfer",
1586 UsbRequest::EnableEndpoint { .. } => "enable_endpoint",
1587 UsbRequest::ResetEndpoint { .. } => "reset_endpoint",
1588 UsbRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1589 "unknown one-way method"
1590 }
1591 UsbRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1592 "unknown two-way method"
1593 }
1594 }
1595 }
1596}
1597
1598#[derive(Debug, Clone)]
1599pub struct UsbControlHandle {
1600 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1601}
1602
1603impl UsbControlHandle {
1604 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1605 self.inner.shutdown_with_epitaph(status.into())
1606 }
1607}
1608
1609impl fidl::endpoints::ControlHandle for UsbControlHandle {
1610 fn shutdown(&self) {
1611 self.inner.shutdown()
1612 }
1613
1614 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1615 self.inner.shutdown_with_epitaph(status)
1616 }
1617
1618 fn is_closed(&self) -> bool {
1619 self.inner.channel().is_closed()
1620 }
1621 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1622 self.inner.channel().on_closed()
1623 }
1624
1625 #[cfg(target_os = "fuchsia")]
1626 fn signal_peer(
1627 &self,
1628 clear_mask: zx::Signals,
1629 set_mask: zx::Signals,
1630 ) -> Result<(), zx_status::Status> {
1631 use fidl::Peered;
1632 self.inner.channel().signal_peer(clear_mask, set_mask)
1633 }
1634}
1635
1636impl UsbControlHandle {}
1637
1638#[must_use = "FIDL methods require a response to be sent"]
1639#[derive(Debug)]
1640pub struct UsbConnectToEndpointResponder {
1641 control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
1642 tx_id: u32,
1643}
1644
1645impl std::ops::Drop for UsbConnectToEndpointResponder {
1649 fn drop(&mut self) {
1650 self.control_handle.shutdown();
1651 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1653 }
1654}
1655
1656impl fidl::endpoints::Responder for UsbConnectToEndpointResponder {
1657 type ControlHandle = UsbControlHandle;
1658
1659 fn control_handle(&self) -> &UsbControlHandle {
1660 &self.control_handle
1661 }
1662
1663 fn drop_without_shutdown(mut self) {
1664 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1666 std::mem::forget(self);
1668 }
1669}
1670
1671impl UsbConnectToEndpointResponder {
1672 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1676 let _result = self.send_raw(result);
1677 if _result.is_err() {
1678 self.control_handle.shutdown();
1679 }
1680 self.drop_without_shutdown();
1681 _result
1682 }
1683
1684 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1686 let _result = self.send_raw(result);
1687 self.drop_without_shutdown();
1688 _result
1689 }
1690
1691 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1692 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1693 fidl::encoding::EmptyStruct,
1694 i32,
1695 >>(
1696 fidl::encoding::FlexibleResult::new(result),
1697 self.tx_id,
1698 0xebea9ba8bbbecb7,
1699 fidl::encoding::DynamicFlags::FLEXIBLE,
1700 )
1701 }
1702}
1703
1704#[must_use = "FIDL methods require a response to be sent"]
1705#[derive(Debug)]
1706pub struct UsbGetDeviceSpeedResponder {
1707 control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
1708 tx_id: u32,
1709}
1710
1711impl std::ops::Drop for UsbGetDeviceSpeedResponder {
1715 fn drop(&mut self) {
1716 self.control_handle.shutdown();
1717 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1719 }
1720}
1721
1722impl fidl::endpoints::Responder for UsbGetDeviceSpeedResponder {
1723 type ControlHandle = UsbControlHandle;
1724
1725 fn control_handle(&self) -> &UsbControlHandle {
1726 &self.control_handle
1727 }
1728
1729 fn drop_without_shutdown(mut self) {
1730 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1732 std::mem::forget(self);
1734 }
1735}
1736
1737impl UsbGetDeviceSpeedResponder {
1738 pub fn send(
1742 self,
1743 mut speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
1744 ) -> Result<(), fidl::Error> {
1745 let _result = self.send_raw(speed);
1746 if _result.is_err() {
1747 self.control_handle.shutdown();
1748 }
1749 self.drop_without_shutdown();
1750 _result
1751 }
1752
1753 pub fn send_no_shutdown_on_err(
1755 self,
1756 mut speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
1757 ) -> Result<(), fidl::Error> {
1758 let _result = self.send_raw(speed);
1759 self.drop_without_shutdown();
1760 _result
1761 }
1762
1763 fn send_raw(
1764 &self,
1765 mut speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
1766 ) -> Result<(), fidl::Error> {
1767 self.control_handle.inner.send::<fidl::encoding::FlexibleType<UsbGetDeviceSpeedResponse>>(
1768 fidl::encoding::Flexible::new((speed,)),
1769 self.tx_id,
1770 0x61f5951481afbc86,
1771 fidl::encoding::DynamicFlags::FLEXIBLE,
1772 )
1773 }
1774}
1775
1776#[must_use = "FIDL methods require a response to be sent"]
1777#[derive(Debug)]
1778pub struct UsbGetDeviceIdResponder {
1779 control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
1780 tx_id: u32,
1781}
1782
1783impl std::ops::Drop for UsbGetDeviceIdResponder {
1787 fn drop(&mut self) {
1788 self.control_handle.shutdown();
1789 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1791 }
1792}
1793
1794impl fidl::endpoints::Responder for UsbGetDeviceIdResponder {
1795 type ControlHandle = UsbControlHandle;
1796
1797 fn control_handle(&self) -> &UsbControlHandle {
1798 &self.control_handle
1799 }
1800
1801 fn drop_without_shutdown(mut self) {
1802 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1804 std::mem::forget(self);
1806 }
1807}
1808
1809impl UsbGetDeviceIdResponder {
1810 pub fn send(self, mut device_id: u32) -> Result<(), fidl::Error> {
1814 let _result = self.send_raw(device_id);
1815 if _result.is_err() {
1816 self.control_handle.shutdown();
1817 }
1818 self.drop_without_shutdown();
1819 _result
1820 }
1821
1822 pub fn send_no_shutdown_on_err(self, mut device_id: u32) -> Result<(), fidl::Error> {
1824 let _result = self.send_raw(device_id);
1825 self.drop_without_shutdown();
1826 _result
1827 }
1828
1829 fn send_raw(&self, mut device_id: u32) -> Result<(), fidl::Error> {
1830 self.control_handle.inner.send::<fidl::encoding::FlexibleType<UsbGetDeviceIdResponse>>(
1831 fidl::encoding::Flexible::new((device_id,)),
1832 self.tx_id,
1833 0x688b558000e7e7ac,
1834 fidl::encoding::DynamicFlags::FLEXIBLE,
1835 )
1836 }
1837}
1838
1839#[must_use = "FIDL methods require a response to be sent"]
1840#[derive(Debug)]
1841pub struct UsbGetDeviceDescriptorResponder {
1842 control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
1843 tx_id: u32,
1844}
1845
1846impl std::ops::Drop for UsbGetDeviceDescriptorResponder {
1850 fn drop(&mut self) {
1851 self.control_handle.shutdown();
1852 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1854 }
1855}
1856
1857impl fidl::endpoints::Responder for UsbGetDeviceDescriptorResponder {
1858 type ControlHandle = UsbControlHandle;
1859
1860 fn control_handle(&self) -> &UsbControlHandle {
1861 &self.control_handle
1862 }
1863
1864 fn drop_without_shutdown(mut self) {
1865 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1867 std::mem::forget(self);
1869 }
1870}
1871
1872impl UsbGetDeviceDescriptorResponder {
1873 pub fn send(
1877 self,
1878 mut descriptor: &fidl_fuchsia_hardware_usb_descriptor::UsbDeviceDescriptor,
1879 ) -> Result<(), fidl::Error> {
1880 let _result = self.send_raw(descriptor);
1881 if _result.is_err() {
1882 self.control_handle.shutdown();
1883 }
1884 self.drop_without_shutdown();
1885 _result
1886 }
1887
1888 pub fn send_no_shutdown_on_err(
1890 self,
1891 mut descriptor: &fidl_fuchsia_hardware_usb_descriptor::UsbDeviceDescriptor,
1892 ) -> Result<(), fidl::Error> {
1893 let _result = self.send_raw(descriptor);
1894 self.drop_without_shutdown();
1895 _result
1896 }
1897
1898 fn send_raw(
1899 &self,
1900 mut descriptor: &fidl_fuchsia_hardware_usb_descriptor::UsbDeviceDescriptor,
1901 ) -> Result<(), fidl::Error> {
1902 self.control_handle
1903 .inner
1904 .send::<fidl::encoding::FlexibleType<UsbGetDeviceDescriptorResponse>>(
1905 fidl::encoding::Flexible::new((descriptor,)),
1906 self.tx_id,
1907 0x31cf51c03a3f4167,
1908 fidl::encoding::DynamicFlags::FLEXIBLE,
1909 )
1910 }
1911}
1912
1913#[must_use = "FIDL methods require a response to be sent"]
1914#[derive(Debug)]
1915pub struct UsbGetConfigurationDescriptorResponder {
1916 control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
1917 tx_id: u32,
1918}
1919
1920impl std::ops::Drop for UsbGetConfigurationDescriptorResponder {
1924 fn drop(&mut self) {
1925 self.control_handle.shutdown();
1926 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1928 }
1929}
1930
1931impl fidl::endpoints::Responder for UsbGetConfigurationDescriptorResponder {
1932 type ControlHandle = UsbControlHandle;
1933
1934 fn control_handle(&self) -> &UsbControlHandle {
1935 &self.control_handle
1936 }
1937
1938 fn drop_without_shutdown(mut self) {
1939 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1941 std::mem::forget(self);
1943 }
1944}
1945
1946impl UsbGetConfigurationDescriptorResponder {
1947 pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1951 let _result = self.send_raw(result);
1952 if _result.is_err() {
1953 self.control_handle.shutdown();
1954 }
1955 self.drop_without_shutdown();
1956 _result
1957 }
1958
1959 pub fn send_no_shutdown_on_err(
1961 self,
1962 mut result: Result<&[u8], i32>,
1963 ) -> Result<(), fidl::Error> {
1964 let _result = self.send_raw(result);
1965 self.drop_without_shutdown();
1966 _result
1967 }
1968
1969 fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
1970 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1971 UsbGetConfigurationDescriptorResponse,
1972 i32,
1973 >>(
1974 fidl::encoding::FlexibleResult::new(result.map(|descriptor| (descriptor,))),
1975 self.tx_id,
1976 0x2a7d59faba5bfdfe,
1977 fidl::encoding::DynamicFlags::FLEXIBLE,
1978 )
1979 }
1980}
1981
1982#[must_use = "FIDL methods require a response to be sent"]
1983#[derive(Debug)]
1984pub struct UsbGetConfigurationResponder {
1985 control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
1986 tx_id: u32,
1987}
1988
1989impl std::ops::Drop for UsbGetConfigurationResponder {
1993 fn drop(&mut self) {
1994 self.control_handle.shutdown();
1995 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1997 }
1998}
1999
2000impl fidl::endpoints::Responder for UsbGetConfigurationResponder {
2001 type ControlHandle = UsbControlHandle;
2002
2003 fn control_handle(&self) -> &UsbControlHandle {
2004 &self.control_handle
2005 }
2006
2007 fn drop_without_shutdown(mut self) {
2008 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2010 std::mem::forget(self);
2012 }
2013}
2014
2015impl UsbGetConfigurationResponder {
2016 pub fn send(self, mut configuration: u8) -> Result<(), fidl::Error> {
2020 let _result = self.send_raw(configuration);
2021 if _result.is_err() {
2022 self.control_handle.shutdown();
2023 }
2024 self.drop_without_shutdown();
2025 _result
2026 }
2027
2028 pub fn send_no_shutdown_on_err(self, mut configuration: u8) -> Result<(), fidl::Error> {
2030 let _result = self.send_raw(configuration);
2031 self.drop_without_shutdown();
2032 _result
2033 }
2034
2035 fn send_raw(&self, mut configuration: u8) -> Result<(), fidl::Error> {
2036 self.control_handle.inner.send::<fidl::encoding::FlexibleType<UsbGetConfigurationResponse>>(
2037 fidl::encoding::Flexible::new((configuration,)),
2038 self.tx_id,
2039 0xd4286660f798887,
2040 fidl::encoding::DynamicFlags::FLEXIBLE,
2041 )
2042 }
2043}
2044
2045#[must_use = "FIDL methods require a response to be sent"]
2046#[derive(Debug)]
2047pub struct UsbSetConfigurationResponder {
2048 control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
2049 tx_id: u32,
2050}
2051
2052impl std::ops::Drop for UsbSetConfigurationResponder {
2056 fn drop(&mut self) {
2057 self.control_handle.shutdown();
2058 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2060 }
2061}
2062
2063impl fidl::endpoints::Responder for UsbSetConfigurationResponder {
2064 type ControlHandle = UsbControlHandle;
2065
2066 fn control_handle(&self) -> &UsbControlHandle {
2067 &self.control_handle
2068 }
2069
2070 fn drop_without_shutdown(mut self) {
2071 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2073 std::mem::forget(self);
2075 }
2076}
2077
2078impl UsbSetConfigurationResponder {
2079 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2083 let _result = self.send_raw(result);
2084 if _result.is_err() {
2085 self.control_handle.shutdown();
2086 }
2087 self.drop_without_shutdown();
2088 _result
2089 }
2090
2091 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2093 let _result = self.send_raw(result);
2094 self.drop_without_shutdown();
2095 _result
2096 }
2097
2098 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2099 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2100 fidl::encoding::EmptyStruct,
2101 i32,
2102 >>(
2103 fidl::encoding::FlexibleResult::new(result),
2104 self.tx_id,
2105 0x10e837d081e5ff1f,
2106 fidl::encoding::DynamicFlags::FLEXIBLE,
2107 )
2108 }
2109}
2110
2111#[must_use = "FIDL methods require a response to be sent"]
2112#[derive(Debug)]
2113pub struct UsbSetInterfaceResponder {
2114 control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
2115 tx_id: u32,
2116}
2117
2118impl std::ops::Drop for UsbSetInterfaceResponder {
2122 fn drop(&mut self) {
2123 self.control_handle.shutdown();
2124 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2126 }
2127}
2128
2129impl fidl::endpoints::Responder for UsbSetInterfaceResponder {
2130 type ControlHandle = UsbControlHandle;
2131
2132 fn control_handle(&self) -> &UsbControlHandle {
2133 &self.control_handle
2134 }
2135
2136 fn drop_without_shutdown(mut self) {
2137 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2139 std::mem::forget(self);
2141 }
2142}
2143
2144impl UsbSetInterfaceResponder {
2145 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2149 let _result = self.send_raw(result);
2150 if _result.is_err() {
2151 self.control_handle.shutdown();
2152 }
2153 self.drop_without_shutdown();
2154 _result
2155 }
2156
2157 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2159 let _result = self.send_raw(result);
2160 self.drop_without_shutdown();
2161 _result
2162 }
2163
2164 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2165 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2166 fidl::encoding::EmptyStruct,
2167 i32,
2168 >>(
2169 fidl::encoding::FlexibleResult::new(result),
2170 self.tx_id,
2171 0xea420cff57f9147,
2172 fidl::encoding::DynamicFlags::FLEXIBLE,
2173 )
2174 }
2175}
2176
2177#[must_use = "FIDL methods require a response to be sent"]
2178#[derive(Debug)]
2179pub struct UsbControlTransferResponder {
2180 control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
2181 tx_id: u32,
2182}
2183
2184impl std::ops::Drop for UsbControlTransferResponder {
2188 fn drop(&mut self) {
2189 self.control_handle.shutdown();
2190 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2192 }
2193}
2194
2195impl fidl::endpoints::Responder for UsbControlTransferResponder {
2196 type ControlHandle = UsbControlHandle;
2197
2198 fn control_handle(&self) -> &UsbControlHandle {
2199 &self.control_handle
2200 }
2201
2202 fn drop_without_shutdown(mut self) {
2203 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2205 std::mem::forget(self);
2207 }
2208}
2209
2210impl UsbControlTransferResponder {
2211 pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2215 let _result = self.send_raw(result);
2216 if _result.is_err() {
2217 self.control_handle.shutdown();
2218 }
2219 self.drop_without_shutdown();
2220 _result
2221 }
2222
2223 pub fn send_no_shutdown_on_err(
2225 self,
2226 mut result: Result<&[u8], i32>,
2227 ) -> Result<(), fidl::Error> {
2228 let _result = self.send_raw(result);
2229 self.drop_without_shutdown();
2230 _result
2231 }
2232
2233 fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2234 self.control_handle
2235 .inner
2236 .send::<fidl::encoding::FlexibleResultType<UsbControlTransferResponse, i32>>(
2237 fidl::encoding::FlexibleResult::new(result.map(|read_data| (read_data,))),
2238 self.tx_id,
2239 0x985e9d9082b78e4,
2240 fidl::encoding::DynamicFlags::FLEXIBLE,
2241 )
2242 }
2243}
2244
2245#[must_use = "FIDL methods require a response to be sent"]
2246#[derive(Debug)]
2247pub struct UsbEnableEndpointResponder {
2248 control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
2249 tx_id: u32,
2250}
2251
2252impl std::ops::Drop for UsbEnableEndpointResponder {
2256 fn drop(&mut self) {
2257 self.control_handle.shutdown();
2258 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2260 }
2261}
2262
2263impl fidl::endpoints::Responder for UsbEnableEndpointResponder {
2264 type ControlHandle = UsbControlHandle;
2265
2266 fn control_handle(&self) -> &UsbControlHandle {
2267 &self.control_handle
2268 }
2269
2270 fn drop_without_shutdown(mut self) {
2271 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2273 std::mem::forget(self);
2275 }
2276}
2277
2278impl UsbEnableEndpointResponder {
2279 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2283 let _result = self.send_raw(result);
2284 if _result.is_err() {
2285 self.control_handle.shutdown();
2286 }
2287 self.drop_without_shutdown();
2288 _result
2289 }
2290
2291 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2293 let _result = self.send_raw(result);
2294 self.drop_without_shutdown();
2295 _result
2296 }
2297
2298 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2299 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2300 fidl::encoding::EmptyStruct,
2301 i32,
2302 >>(
2303 fidl::encoding::FlexibleResult::new(result),
2304 self.tx_id,
2305 0xbdbe6ed69b0b844,
2306 fidl::encoding::DynamicFlags::FLEXIBLE,
2307 )
2308 }
2309}
2310
2311#[must_use = "FIDL methods require a response to be sent"]
2312#[derive(Debug)]
2313pub struct UsbResetEndpointResponder {
2314 control_handle: std::mem::ManuallyDrop<UsbControlHandle>,
2315 tx_id: u32,
2316}
2317
2318impl std::ops::Drop for UsbResetEndpointResponder {
2322 fn drop(&mut self) {
2323 self.control_handle.shutdown();
2324 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2326 }
2327}
2328
2329impl fidl::endpoints::Responder for UsbResetEndpointResponder {
2330 type ControlHandle = UsbControlHandle;
2331
2332 fn control_handle(&self) -> &UsbControlHandle {
2333 &self.control_handle
2334 }
2335
2336 fn drop_without_shutdown(mut self) {
2337 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2339 std::mem::forget(self);
2341 }
2342}
2343
2344impl UsbResetEndpointResponder {
2345 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2349 let _result = self.send_raw(result);
2350 if _result.is_err() {
2351 self.control_handle.shutdown();
2352 }
2353 self.drop_without_shutdown();
2354 _result
2355 }
2356
2357 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2359 let _result = self.send_raw(result);
2360 self.drop_without_shutdown();
2361 _result
2362 }
2363
2364 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2365 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2366 fidl::encoding::EmptyStruct,
2367 i32,
2368 >>(
2369 fidl::encoding::FlexibleResult::new(result),
2370 self.tx_id,
2371 0x78325ec2b0014867,
2372 fidl::encoding::DynamicFlags::FLEXIBLE,
2373 )
2374 }
2375}
2376
2377#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2378pub struct UsbServiceMarker;
2379
2380#[cfg(target_os = "fuchsia")]
2381impl fidl::endpoints::ServiceMarker for UsbServiceMarker {
2382 type Proxy = UsbServiceProxy;
2383 type Request = UsbServiceRequest;
2384 const SERVICE_NAME: &'static str = "fuchsia.hardware.usb.UsbService";
2385}
2386
2387#[cfg(target_os = "fuchsia")]
2390pub enum UsbServiceRequest {
2391 Device(UsbRequestStream),
2392}
2393
2394#[cfg(target_os = "fuchsia")]
2395impl fidl::endpoints::ServiceRequest for UsbServiceRequest {
2396 type Service = UsbServiceMarker;
2397
2398 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2399 match name {
2400 "device" => Self::Device(
2401 <UsbRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2402 ),
2403 _ => panic!("no such member protocol name for service UsbService"),
2404 }
2405 }
2406
2407 fn member_names() -> &'static [&'static str] {
2408 &["device"]
2409 }
2410}
2411#[cfg(target_os = "fuchsia")]
2412pub struct UsbServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2413
2414#[cfg(target_os = "fuchsia")]
2415impl fidl::endpoints::ServiceProxy for UsbServiceProxy {
2416 type Service = UsbServiceMarker;
2417
2418 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2419 Self(opener)
2420 }
2421}
2422
2423#[cfg(target_os = "fuchsia")]
2424impl UsbServiceProxy {
2425 pub fn connect_to_device(&self) -> Result<UsbProxy, fidl::Error> {
2426 let (proxy, server_end) = fidl::endpoints::create_proxy::<UsbMarker>();
2427 self.connect_channel_to_device(server_end)?;
2428 Ok(proxy)
2429 }
2430
2431 pub fn connect_to_device_sync(&self) -> Result<UsbSynchronousProxy, fidl::Error> {
2434 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<UsbMarker>();
2435 self.connect_channel_to_device(server_end)?;
2436 Ok(proxy)
2437 }
2438
2439 pub fn connect_channel_to_device(
2442 &self,
2443 server_end: fidl::endpoints::ServerEnd<UsbMarker>,
2444 ) -> Result<(), fidl::Error> {
2445 self.0.open_member("device", server_end.into_channel())
2446 }
2447
2448 pub fn instance_name(&self) -> &str {
2449 self.0.instance_name()
2450 }
2451}
2452
2453mod internal {
2454 use super::*;
2455
2456 impl fidl::encoding::ResourceTypeMarker for UsbConnectToEndpointRequest {
2457 type Borrowed<'a> = &'a mut Self;
2458 fn take_or_borrow<'a>(
2459 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2460 ) -> Self::Borrowed<'a> {
2461 value
2462 }
2463 }
2464
2465 unsafe impl fidl::encoding::TypeMarker for UsbConnectToEndpointRequest {
2466 type Owned = Self;
2467
2468 #[inline(always)]
2469 fn inline_align(_context: fidl::encoding::Context) -> usize {
2470 4
2471 }
2472
2473 #[inline(always)]
2474 fn inline_size(_context: fidl::encoding::Context) -> usize {
2475 8
2476 }
2477 }
2478
2479 unsafe impl
2480 fidl::encoding::Encode<
2481 UsbConnectToEndpointRequest,
2482 fidl::encoding::DefaultFuchsiaResourceDialect,
2483 > for &mut UsbConnectToEndpointRequest
2484 {
2485 #[inline]
2486 unsafe fn encode(
2487 self,
2488 encoder: &mut fidl::encoding::Encoder<
2489 '_,
2490 fidl::encoding::DefaultFuchsiaResourceDialect,
2491 >,
2492 offset: usize,
2493 _depth: fidl::encoding::Depth,
2494 ) -> fidl::Result<()> {
2495 encoder.debug_check_bounds::<UsbConnectToEndpointRequest>(offset);
2496 fidl::encoding::Encode::<
2498 UsbConnectToEndpointRequest,
2499 fidl::encoding::DefaultFuchsiaResourceDialect,
2500 >::encode(
2501 (
2502 <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.ep_addr),
2503 <fidl::encoding::Endpoint<
2504 fidl::endpoints::ServerEnd<
2505 fidl_fuchsia_hardware_usb_endpoint::EndpointMarker,
2506 >,
2507 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2508 &mut self.ep
2509 ),
2510 ),
2511 encoder,
2512 offset,
2513 _depth,
2514 )
2515 }
2516 }
2517 unsafe impl<
2518 T0: fidl::encoding::Encode<u8, fidl::encoding::DefaultFuchsiaResourceDialect>,
2519 T1: fidl::encoding::Encode<
2520 fidl::encoding::Endpoint<
2521 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
2522 >,
2523 fidl::encoding::DefaultFuchsiaResourceDialect,
2524 >,
2525 >
2526 fidl::encoding::Encode<
2527 UsbConnectToEndpointRequest,
2528 fidl::encoding::DefaultFuchsiaResourceDialect,
2529 > for (T0, T1)
2530 {
2531 #[inline]
2532 unsafe fn encode(
2533 self,
2534 encoder: &mut fidl::encoding::Encoder<
2535 '_,
2536 fidl::encoding::DefaultFuchsiaResourceDialect,
2537 >,
2538 offset: usize,
2539 depth: fidl::encoding::Depth,
2540 ) -> fidl::Result<()> {
2541 encoder.debug_check_bounds::<UsbConnectToEndpointRequest>(offset);
2542 unsafe {
2545 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2546 (ptr as *mut u32).write_unaligned(0);
2547 }
2548 self.0.encode(encoder, offset + 0, depth)?;
2550 self.1.encode(encoder, offset + 4, depth)?;
2551 Ok(())
2552 }
2553 }
2554
2555 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2556 for UsbConnectToEndpointRequest
2557 {
2558 #[inline(always)]
2559 fn new_empty() -> Self {
2560 Self {
2561 ep_addr: fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect),
2562 ep: fidl::new_empty!(
2563 fidl::encoding::Endpoint<
2564 fidl::endpoints::ServerEnd<
2565 fidl_fuchsia_hardware_usb_endpoint::EndpointMarker,
2566 >,
2567 >,
2568 fidl::encoding::DefaultFuchsiaResourceDialect
2569 ),
2570 }
2571 }
2572
2573 #[inline]
2574 unsafe fn decode(
2575 &mut self,
2576 decoder: &mut fidl::encoding::Decoder<
2577 '_,
2578 fidl::encoding::DefaultFuchsiaResourceDialect,
2579 >,
2580 offset: usize,
2581 _depth: fidl::encoding::Depth,
2582 ) -> fidl::Result<()> {
2583 decoder.debug_check_bounds::<Self>(offset);
2584 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2586 let padval = unsafe { (ptr as *const u32).read_unaligned() };
2587 let mask = 0xffffff00u32;
2588 let maskedval = padval & mask;
2589 if maskedval != 0 {
2590 return Err(fidl::Error::NonZeroPadding {
2591 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2592 });
2593 }
2594 fidl::decode!(
2595 u8,
2596 fidl::encoding::DefaultFuchsiaResourceDialect,
2597 &mut self.ep_addr,
2598 decoder,
2599 offset + 0,
2600 _depth
2601 )?;
2602 fidl::decode!(
2603 fidl::encoding::Endpoint<
2604 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
2605 >,
2606 fidl::encoding::DefaultFuchsiaResourceDialect,
2607 &mut self.ep,
2608 decoder,
2609 offset + 4,
2610 _depth
2611 )?;
2612 Ok(())
2613 }
2614 }
2615}