This commit creates a Backend trait that encapsulates all the functions that are specific to a backend (rusb or nusb). This has the following advantages:
All the backend-specific code is out of src/lib.rs and moved into the usb module and submodules.
The number of cfg compilation directives is reduced drastically
It will be easier to change the backend dynamically by changing which trait object is used as a backend
It will also be easier to unit test the non-backend part of the codebase, by creating a MockBackend.
I'm not able to implement the dynamic backend feature at the moment, since I need to find a way to deal with the requirements for trait objects in Rust. This can definitely happen in a future PR.
This commit creates a
Backend
trait that encapsulates all the functions that are specific to a backend (rusb
ornusb
). This has the following advantages:src/lib.rs
and moved into theusb
module and submodules.cfg
compilation directives is reduced drasticallyMockBackend
.I'm not able to implement the dynamic backend feature at the moment, since I need to find a way to deal with the requirements for trait objects in Rust. This can definitely happen in a future PR.