aboutsummaryrefslogtreecommitdiff
path: root/syrette/src/di_container.rs
diff options
context:
space:
mode:
Diffstat (limited to 'syrette/src/di_container.rs')
-rw-r--r--syrette/src/di_container.rs41
1 files changed, 39 insertions, 2 deletions
diff --git a/syrette/src/di_container.rs b/syrette/src/di_container.rs
index df51140..334c533 100644
--- a/syrette/src/di_container.rs
+++ b/syrette/src/di_container.rs
@@ -74,9 +74,46 @@ where
///
/// # Examples
/// ```
-/// di_container.bind::<dyn IDatabaseService>().to::<DatabaseService>();
+/// use std::collections::HashMap;
///
-/// let database_service = di_container.get::<dyn IDatabaseService>()?;
+/// use syrette::{DIContainer, injectable};
+/// use syrette::errors::di_container::DIContainerError;
+///
+/// trait IDatabaseService
+/// {
+/// fn get_all_records(&self, table_name: String) -> HashMap<String, String>;
+/// }
+///
+/// struct DatabaseService {}
+///
+/// #[injectable(IDatabaseService)]
+/// impl DatabaseService
+/// {
+/// fn new() -> Self
+/// {
+/// Self {}
+/// }
+/// }
+///
+/// impl IDatabaseService for DatabaseService
+/// {
+/// fn get_all_records(&self, table_name: String) -> HashMap<String, String>
+/// {
+/// // Do stuff here
+/// HashMap::<String, String>::new()
+/// }
+/// }
+///
+/// fn main() -> error_stack::Result<(), DIContainerError>
+/// {
+/// let mut di_container = DIContainer::new();
+///
+/// di_container.bind::<dyn IDatabaseService>().to::<DatabaseService>();
+///
+/// let database_service = di_container.get::<dyn IDatabaseService>()?;
+///
+/// Ok(())
+/// }
/// ```
pub struct DIContainer
{