2 stable releases

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

#58 in #dependency-injection

Download history 32/week @ 2024-02-19 84/week @ 2024-02-26 55/week @ 2024-03-04 51/week @ 2024-03-11 71/week @ 2024-03-18

262 downloads per month
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
~33K SLoC