rust-embedded-community / usb-device

Experimental device-side USB framework for microcontrollers in Rust.
MIT License
451 stars 76 forks source link

Make USB device config public #69

Open nickray opened 3 years ago

nickray commented 3 years ago

I was about to start tackling USB/IP when I discovered @Sawchord's https://github.com/Sawchord/usbip-device.

For usbip list -r localhost to be somewhat pretty, the USB/IP server should return basic info on the device, which duplicates the contents of the non-public Config struct here. (It's not strictly necessary for this info to be correct, AFAIU.)

Looking at UsbDeviceBuilder, in reality it's a ConfigBuilder, which would become quite redundant (candidate for deprecation?) if the config itself were made public with a fluent/builder interface. I'm gambling on increasing merge/publish potential by staying backwards compatible though :)

This would then allow re-use in the USB/IP driver (e.g. https://github.com/nickray/usbip-device/blob/7bab96f64072da82a552c94213b5dc98f2481c99/examples/twitching_mouse.rs#L16-L26)

There's a bit chicken+egg involved regarding DRY and the interface descriptors (which USB/IP also advertises); solving that seems it would require breaking changes which I don't want to propose.

P.S. Are there any/many useful cases for Config<'a> with non-'static lifetimes?