anthill-di-derive

Crates.ioanthill-di-derive
lib.rsanthill-di-derive
version1.2.4
sourcesrc
created_at2022-05-03 13:16:09.524563
updated_at2022-06-26 16:10:19.795444
descriptionDerive extension for anthill-di
homepage
repository
max_upload_size
id579714
size15,630
(Vidrochka)

documentation

README

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:

Commit count: 0

cargo fmt