jiegec / usbip

A Rust library to run a USB/IP server
MIT License
255 stars 25 forks source link

Derive Debug for all structs #17

Open h7x4 opened 1 year ago

h7x4 commented 1 year ago

Let all structs derive debug for ease of debugging.

The only thing that I feel is a little questionable about this is making UsbInterfaceHandler and UsbDeviceHandler into a supertraits of Debug. Although not semantically correct, it is meant to force UsbDevice.device_handler: Option<Arc<Mutex<Box<dyn UsbDeviceHandler + Send>>>> to be debuggable, so UsbDevice can be so as well. Would it be better to maintain a manual implementation here?

jiegec commented 1 year ago

I don't know what's the best practice, but it might break existing code not impl-ing Debug?

h7x4 commented 1 year ago

... it might break existing code not impl-ing Debug?

That's a good call. Do you think it would be better to create a manual implementation? I guess something like derivative also is an option, at the cost of introducing a new dependency.

jamesadevine commented 1 year ago

Could this be a package configuration option instead?

h7x4 commented 1 year ago

That works for me. I've never heard of debug being a used as a configuration option though. Is the intention to include the extra dependency only for those that need it?

jamesadevine commented 1 year ago

I don't think it is a big deal to derive the debug struct personally.