Syrette
The convenient dependency injection library for Rust.
Namesake
From the syrette Wikipedia article.
A syrette is a device for injecting liquid through a needle. It is similar to a syringe except that it has a closed flexible tube (like that typically used for toothpaste) instead of a rigid tube and piston.
Features
- A dependency injection container
- Autowiring dependencies
- API inspired from the one of InversifyJS
- Helpful error messages
- Enforces the use of interface traits
- Supports generic implementations & generic interface traits
- Binding singletons
Optional features
factory. Binding factories (Rust nightly required)
To use these features, you must enable it in Cargo.
Motivation
Other DI libraries for Rust are either unmaintained (di for example), overcomplicated and or bloated (anthill-di for example) or has a weird API (teloc for example).
The goal of Syrette is to be a simple, useful, convenient and familiar DI library.
Example usage
use ;
use TransientPtr;
For more examples see the examples folder.
Todo
- Add support for generic factories
- Add asynchronous functionality