I dropped the trait in the led-lib currently, and it compiles and works.
My instinct now tells me to put the trait in a file of itself. led_traits.rs.
(The driver can exist without the lib, and vice versa. Also, there can exist many drivers and many lib-files, so they should not redefine it)
But by doing so, I cant figure out to write the use/mod statements correctly.
If I do this in the driver:
mod led_traits
use led_traits::WriteLedRGB
And then implement the trait, I will have implemented
driver::led_traits::WriteLedRGB
And doing the same in the lib, i will have used:
ledlib::led_traits::WriteLedRGB
And that is not the same, so the compiler gets angry about the trait bounds not satisfied.
I'm getting the impression that you're either including the same led_traits module file in two separate crates, or including the same led_traits module file in two different paths within the same crate.
In a more general sense, I'm guessing that you're thinking of having one library (ledlib) that supports many different drivers. If that's the case, I would define the trait in the ledlib crate, and each driver that wants to interoperate would implement the trait. You could put this implementation behind a feature flag if you wanted to be able to build the driver without the ledlib dependency. The main alternative is that the ledlib would implement the trait for each driver.
If the trait is genuinely useful on it's own, a separate crate both ledlib and drivers depend on is another alternative.
(I'm not entirely sure this is what you meant because you also said that there may be "many lib-files", and I don't know how to interpret that.)