aboutsummaryrefslogtreecommitdiff
path: root/src/async_di_container.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-10-02 19:32:25 +0200
committerHampusM <hampus@hampusmat.com>2022-10-02 19:32:25 +0200
commitd8525f169649e4ce7e806e68de5e328135755326 (patch)
tree4fc573e79c8f3836fada5fdb0851b4740a63c43d /src/async_di_container.rs
parent31f62ea0c634360030dcf89203268fa5684b5905 (diff)
refactor: improve management of feature specific items
Diffstat (limited to 'src/async_di_container.rs')
-rw-r--r--src/async_di_container.rs38
1 files changed, 14 insertions, 24 deletions
diff --git a/src/async_di_container.rs b/src/async_di_container.rs
index f8ce92d..881f64c 100644
--- a/src/async_di_container.rs
+++ b/src/async_di_container.rs
@@ -50,14 +50,11 @@
//! Ok(())
//! }
//! ```
-//!
-//! ---
-//!
-//! *This module is only available if Syrette is built with the "async" feature.*
use std::any::type_name;
use std::marker::PhantomData;
use std::sync::Arc;
+use feature_macros::feature_specific;
use tokio::sync::Mutex;
#[cfg(feature = "factory")]
@@ -82,6 +79,7 @@ use crate::provider::r#async::{
use crate::ptr::{SomeThreadsafePtr, ThreadsafeSingletonPtr, TransientPtr};
/// Alias for a threadsafe boxed function.
+#[feature_specific("factory")]
pub type BoxFn<Args, Return> = Box<(dyn Fn<Args, Output = Return> + Send + Sync)>;
/// When configurator for a binding for type 'Interface' inside a [`AsyncDIContainer`].
@@ -289,11 +287,9 @@ where
/// Creates a binding of factory type `Interface` to a factory inside of the
/// associated [`AsyncDIContainer`].
///
- /// *This function is only available if Syrette is built with the "factory" feature.*
- ///
/// # Errors
- /// Will return Err if the associated [`AsyncDIContainer`] already have a binding for
- /// the interface.
+ /// Will return Err if the associated [`AsyncDIContainer`] already have a binding
+ /// for the interface.
///
/// # Examples
/// ```
@@ -334,7 +330,7 @@ where
/// # Ok(())
/// # }
/// ```
- #[cfg(feature = "factory")]
+ #[feature_specific("factory")]
pub async fn to_factory<Args, Return, FactoryFunc>(
&self,
factory_func: &'static FactoryFunc,
@@ -373,11 +369,9 @@ where
/// Creates a binding of factory type `Interface` to a async factory inside of the
/// associated [`AsyncDIContainer`].
///
- /// *This function is only available if Syrette is built with the "factory" feature.*
- ///
/// # Errors
- /// Will return Err if the associated [`AsyncDIContainer`] already have a binding for
- /// the interface.
+ /// Will return Err if the associated [`AsyncDIContainer`] already have a binding
+ /// for the interface.
///
/// # Examples
/// ```
@@ -421,7 +415,7 @@ where
/// # Ok(())
/// # }
/// ```
- #[cfg(all(feature = "factory", feature = "async"))]
+ #[feature_specific("factory")]
pub async fn to_async_factory<Args, Return, FactoryFunc>(
&self,
factory_func: &'static FactoryFunc,
@@ -464,11 +458,9 @@ where
/// Creates a binding of type `Interface` to a factory that takes no arguments
/// inside of the associated [`AsyncDIContainer`].
///
- /// *This function is only available if Syrette is built with the "factory" feature.*
- ///
/// # Errors
- /// Will return Err if the associated [`AsyncDIContainer`] already have a binding for
- /// the interface.
+ /// Will return Err if the associated [`AsyncDIContainer`] already have a binding
+ /// for the interface.
///
/// # Examples
/// ```
@@ -509,7 +501,7 @@ where
/// # Ok(())
/// # }
/// ```
- #[cfg(feature = "factory")]
+ #[feature_specific("factory")]
pub async fn to_default_factory<Return, FactoryFunc>(
&self,
factory_func: &'static FactoryFunc,
@@ -549,11 +541,9 @@ where
/// Creates a binding of factory type `Interface` to a async factory inside of the
/// associated [`AsyncDIContainer`].
///
- /// *This function is only available if Syrette is built with the "factory" feature.*
- ///
/// # Errors
- /// Will return Err if the associated [`AsyncDIContainer`] already have a binding for
- /// the interface.
+ /// Will return Err if the associated [`AsyncDIContainer`] already have a binding
+ /// for the interface.
///
/// # Examples
/// ```
@@ -597,7 +587,7 @@ where
/// # Ok(())
/// # }
/// ```
- #[cfg(all(feature = "factory", feature = "async"))]
+ #[feature_specific("factory")]
pub async fn to_async_default_factory<Return, FactoryFunc>(
&self,
factory_func: &'static FactoryFunc,