aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
blob: cb0dd5ab99e8e7ea372568a342f06cdc9888f306 (plain)
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
#![cfg_attr(feature = "factory", feature(unboxed_closures, fn_traits))]
#![deny(clippy::all)]
#![deny(clippy::pedantic)]

//! Syrette
//!
//! Syrette is a collection of utilities useful for performing dependency injection.

pub mod di_container;
pub mod errors;
pub mod interfaces;
pub mod ptr;

#[cfg(feature = "factory")]
pub mod castable_factory;

pub use di_container::*;
pub use syrette_macros::*;

#[doc(hidden)]
pub mod libs;

// Private
mod provider;

/// Shortcut for creating a DI container binding for a injectable without a declared interface.
///
/// This will declare a interface for the implementation.
///
/// Useful for when the implementation or the interface is generic.
///
/// # Arguments
/// {interface} => {implementation}, {DI container variable name}
#[macro_export]
macro_rules! di_container_bind {
    ($interface: path => $implementation: ty, $di_container: ident) => {
        $di_container.bind::<dyn $interface>().to::<$implementation>();

        syrette::declare_interface!($implementation -> $interface);
    };
}