Crates.io | minfac |
lib.rs | minfac |
version | 0.1.1 |
source | src |
created_at | 2021-08-11 20:29:41.789124 |
updated_at | 2024-10-28 09:34:58.337153 |
description | Lightweight Inversion Of Control |
homepage | |
repository | https://github.com/mineichen/minfac |
max_upload_size | |
id | 434942 |
size | 111,496 |
use {minfac::{Registered, ServiceCollection}};
let mut collection = ServiceCollection::new();
collection
.with::<Registered<u8>>()
.register(|byte| byte as i16 * 2);
collection.register(|| 1u8);
let provider = collection.build().expect("Configuration is valid");
assert_eq!(Some(2i16), provider.get::<i16>());
examples/distributed_simple
for more detailsT
without any additional frills, SharedServices as Arc<T>
ServiceProvider
s)provider.get_all::<MyService>()
returns an iterator, which lazily generates all registered MyService
instances)ServiceProvider
all registered services are checked to
ServiceProvider
(checked at runtime when debug_assertions are enabled)ServiceProvider
implements Send+Sync and is threadsafe without using locksVisit the examples/documentation for more details
✅ Transient services - New instance per request
✅ Shared services - Shared instance per ServiceProvider
✅ Instance services - Shared instance per ServiceProviderFactory
✅ ServiceProviderFactory for creating ServiceProvider's with minimal overhead
✅ ServiceProviderFactory inherit services from ServiceProvider
⬜ ServiceProviderFactory inherit services from other ServiceProviderFactory
✅ Replaceable strategy for service identification (TypeIds might change between rust versions)
✅ Recursive dependencies check
✅ Missing dependencies check
⬜ Make all structs FFI-Safe
⬜ Remove global Error handler. Use transition from ServiceCollection to ServiceProvider to replace default Error-Hander