1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! A dependency injection crate inspired by the [Spring Framework](https://spring.io/) in Java.
//!
//! The philosophy of **Springtime** is to provide the means of easy dependency injection without
//! unnecessary manual configuration, e.g. without the need to explicitly create dependencies and
//! storing them in containers. As much work as possible is placed on compile-time metadata creation
//! and automatic [component] discovery, thus allowing users to focus on the _usage_ of components,
//! rather than their _creation_ and _management_. With an accent placed on attributes,
//! dependency configuration becomes declarative (_what I want to accomplish_) leaving the gritty
//! details the framework itself (_how to accomplish what was requested_).
//!
//! ### Simple usage example
//!
//! ```
//! use springtime_di::component::Component;
//! use springtime_di::instance_provider::ComponentInstancePtr;
//! use springtime_di::{Component, component_alias, injectable};
//!
//! // this is a trait we would like to use in our component
//! #[injectable]
//! trait TestTrait {}
//!
//! // this is a dependency which implements the above trait and also is an injectable component
//! #[derive(Component)]
//! struct TestDependency;
//!
//! // we're telling the framework it should provide TestDependency when asked for dyn TestTrait
//! #[component_alias]
//! impl TestTrait for TestDependency {}
//!
//! // this is another component, but with a dependency
//! #[derive(Component)]
//! struct TestComponent {
//!     // the framework will know how to inject dyn TestTrait, when asked for TestComponent
//!     // more details are available in other parts of the documentation
//!     dependency: ComponentInstancePtr<dyn TestTrait + Send + Sync>,
//! }
//! ```
//!
//! *Note:* `Send + Sync` are only required when the `threadsafe` feature is enabled.
//!
//! ### Features
//!
//! * `derive` - automatically import helper proc macros
//! * `threadsafe` - use threadsafe pointers and `Send + Sync` trait bounds
//! * `async` - turn all creation functions async

pub mod component;
pub mod component_registry;
pub mod factory;
#[cfg(feature = "async")]
pub mod future;
pub mod instance_provider;
pub mod scope;

#[cfg(feature = "derive")]
pub use springtime_di_derive::*;