Crates.io | anthill-di-derive |
lib.rs | anthill-di-derive |
version | 1.2.4 |
source | src |
created_at | 2022-05-03 13:16:09.524563 |
updated_at | 2022-06-26 16:10:19.795444 |
description | Derive extension for anthill-di |
homepage | |
repository | |
max_upload_size | |
id | 579714 |
size | 15,630 |
anthill-di
derive extensopn
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: