aboutsummaryrefslogtreecommitdiff
path: root/src/di_container/mod.rs
blob: 4e60505eb92b131dbf3fb7fb5d747e0f6cd462f2 (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
42
43
//! Dependency injection container types.

#[cfg(feature = "async")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "async")))]
pub mod asynchronous;

pub mod blocking;

/// DI container binding options.
///
/// # Examples
/// ```
/// # use syrette::di_container::BindingOptions;
/// #
/// BindingOptions::new().name("foo");
/// ```
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
pub struct BindingOptions<'a>
{
    name: Option<&'a str>,
}

impl<'a> BindingOptions<'a>
{
    /// Returns a new `BindingOptions`.
    #[must_use]
    pub const fn new() -> Self
    {
        Self { name: None }
    }

    /// Returns `Self` with the specified name set.
    #[must_use]
    pub const fn name(mut self, name: &'a str) -> Self
    {
        self.name = Some(name);

        self
    }
}

// Private.
pub(crate) mod binding_storage;