anthill-di-derive 0.1.0

Derive extension for anthill-di
Documentation
anthill-di-derive-0.1.0 has been yanked.

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>,
}

Refs