Experimental IOC library inpsired by injector for Rust. Goals: IOC + ergonomics.
See test suite for all supported usages.
Example quick-fire usages:
use Arc;
use *;
;
The get!
macro with a container
resolves a type in order of: installed provider (1), calling the associated inject
function on a type (2), and lastly the Default
implementation by a blanket impl of the InjectExt
trait (3) by the default associated function resolution order.
The interaction with the Default
impl is to imitiate ergonomics in injector.
(2) & (3) can be opt-out by attribute #[inject(no_inject(arg))]
, (name tbd) in which case only container held provider will be used for resolution of the type. Method specific defaults are annotated as #[inject(defualt(arg = expression))]
where expression will lazy evaluate on failing attempt at (1) and (2).
call!
macro behaves similiarily to get!
, but supports kwargs.
Todo:
- Support kwargs for "constructors" with a
create_object!
flavored macro. - Make
#[inject]
support Struct attribute notation with#[inject(..)]
for individual struct fields. - Make
default
andno_inject
story less annoying.