| Crates.io | fibre_ioc |
| lib.rs | fibre_ioc |
| version | 0.5.2 |
| created_at | 2025-06-16 05:57:17.844787+00 |
| updated_at | 2025-06-16 16:10:41.315706+00 |
| description | A flexible, thread-safe and dynamic Inversion of Control (IoC) container for Rust. |
| homepage | https://github.com/excsn/fibre |
| repository | https://github.com/excsn/fibre |
| max_upload_size | |
| id | 1713920 |
| size | 82,797 |
fibre_ioc is a flexible, thread-safe and dynamic Inversion of Control (IoC) container for Rust.
It provides a robust solution for managing dependencies within an application, promoting loose coupling and enhancing testability. Unlike containers that require a single, upfront initialization, Fibre IoC allows for dynamic registration of services at any point during the application's lifecycle, making it ideal for complex, modular systems.
The container is built from the ground up for concurrency. It uses high-performance concurrent data structures (dashmap and once_cell) to ensure that registering and resolving services is completely thread-safe, without sacrificing performance.
Fibre IoC supports different service lifetimes to suit various use cases:
For convenience, a static global container is available via the global() function. For testing or modularity, you can create fully isolated Container instances with Container::new(), preventing any interference between dependency scopes.
Resolve dependencies effortlessly with the resolve! macro, which provides a concise, panicking API for retrieving services. For cases where failure is expected, the container.get() method returns an Option, allowing for graceful error handling.
Fibre IoC automatically detects and prevents circular dependencies during resolution. If Service A depends on B, and B depends on A, the container will panic with a clear error message instead of causing a stack overflow.
Add Fibre IoC to your project by running:
cargo add fibre_ioc
For a detailed guide on core concepts and advanced usage patterns, please see the Usage Guide.
The tests/ directory in the repository also contains a comprehensive suite of examples demonstrating every feature, from basic registration to complex concurrent scenarios.
For a complete API reference, see the documentation on docs.rs.
This library is distributed under the terms of the MPL-2.0 license.