2 stable releases

1.2.4 Jun 26, 2022
1.2.3 May 4, 2022
0.1.0 May 3, 2022

#60 in #dependency-injection


Used in 3 crates

MIT license

15KB
273 lines

anthill-di-derive

anthill-di derive extensopn

Basic concepts

Add #[derive(constructor)] on top of struct

#[derive(constructor)]
struct TestInjection {}

Register dependency

#[derive(constructor)]
struct TestInjection1 {
    // simple resolve call (can be omitted)
    #[resolve] TestInjection2
    
    // resolve custom data
    #[custom_resolve(value = "\"test3\".to_string()")] str: String,

    // save context
    #[ioc_context] di_context: anthill_di::DependencyContext,

    // resolve collection of service
    #[resolve_collection] collection: Vec<Box<dyn GetStr>>,

    // resolve service by component type
    #[resolve_by_component(TestInjection3)] second: Box<dyn GetStr>,
}

Crate version is equal minimal required version of anthill-di

Crate required dependency:

Dependencies

~1.5MB
~35K SLoC