-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support traits defined in crate #1
Comments
Hi, I mentioned similar thing in section "Factory functions". You can find more about this here. In brief, in Rust you can't implement an interface/trait from crate A for a type/struct from crate B in crate C. The main idea, that lies behind this library - you don't need to register all components in container. To achieve this, code generator behind
in test_def crate In the real world it means that all implementations of trait must be defined in the same crate if you are using waiter library. |
I tried 3. without success. Could you please provide a example. Even Inheritance with Traits didn't worked for me. This restrictions makes the implementation of a Hexagonal Architecture with crates and DI not easy. |
It's only question of preferences. You need to keep interfaces and implementations in the same crate. If it will be the same app, you can use Rust modules instead. |
I’m trying to create a small framework for handling modules and just came across this di crate which seems awesome, but this issue kinda got me thinking. If I have a trait |
You can read about this here: I also frustrated by this. But actually the main target of DI container is to simplify the project setup and remove boilerplate code. Otherwise I don't understand why somebody would use DI library when code with DI is more verbose then without using DI, it's like "using DI just to use DI". So conciseness was "must have" when I was choosing some trade off here. Anyway. What we can consider:
|
I extended the 3_inject_options_list.rs example to implement Interface4 from crate test_def.
I get the following compiling error:
The text was updated successfully, but these errors were encountered: