From 9e01cdf341a7866180b3a63d745f3b2d7578d28a Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 23 Oct 2022 18:12:23 +0200 Subject: refactor!: reduce DI container coupling BREAKING CHANGE: You now have to import the DI containers's interfaces to use the DI containers's methods --- examples/async-factory/main.rs | 3 ++- examples/async/bootstrap.rs | 3 ++- examples/async/main.rs | 12 ++++++------ examples/basic/bootstrap.rs | 2 +- examples/basic/main.rs | 1 + examples/factory/bootstrap.rs | 2 +- examples/factory/main.rs | 3 ++- examples/generics/bootstrap.rs | 3 ++- examples/generics/main.rs | 6 ++++-- examples/named/bootstrap.rs | 2 +- examples/named/main.rs | 1 + examples/unbound/bootstrap.rs | 2 +- examples/unbound/main.rs | 11 ++++++----- examples/with-3rd-party/bootstrap.rs | 3 ++- examples/with-3rd-party/main.rs | 6 ++++-- 15 files changed, 36 insertions(+), 24 deletions(-) (limited to 'examples') diff --git a/examples/async-factory/main.rs b/examples/async-factory/main.rs index 715abf5..b9beded 100644 --- a/examples/async-factory/main.rs +++ b/examples/async-factory/main.rs @@ -5,8 +5,9 @@ use std::time::Duration; use anyhow::Result; +use syrette::di_container::asynchronous::prelude::*; use syrette::ptr::TransientPtr; -use syrette::{async_closure, declare_default_factory, factory, AsyncDIContainer}; +use syrette::{async_closure, declare_default_factory, factory}; use tokio::time::sleep; trait IFoo: Send + Sync diff --git a/examples/async/bootstrap.rs b/examples/async/bootstrap.rs index 9b495c2..5f90d88 100644 --- a/examples/async/bootstrap.rs +++ b/examples/async/bootstrap.rs @@ -1,8 +1,9 @@ use std::sync::Arc; use anyhow::Result; +use syrette::declare_default_factory; +use syrette::di_container::asynchronous::prelude::*; use syrette::ptr::TransientPtr; -use syrette::{declare_default_factory, AsyncDIContainer}; use crate::animals::cat::Cat; use crate::animals::dog::Dog; diff --git a/examples/async/main.rs b/examples/async/main.rs index 03e36e1..d051b94 100644 --- a/examples/async/main.rs +++ b/examples/async/main.rs @@ -2,19 +2,19 @@ #![deny(clippy::pedantic)] #![allow(clippy::module_name_repetitions)] -use anyhow::Result; -use tokio::spawn; - mod animals; mod bootstrap; mod food; mod interfaces; -use bootstrap::bootstrap; -use interfaces::dog::IDog; -use interfaces::human::IHuman; +use anyhow::Result; +use syrette::di_container::asynchronous::prelude::*; +use tokio::spawn; +use crate::bootstrap::bootstrap; +use crate::interfaces::dog::IDog; use crate::interfaces::food::IFoodFactory; +use crate::interfaces::human::IHuman; #[tokio::main] async fn main() -> Result<()> diff --git a/examples/basic/bootstrap.rs b/examples/basic/bootstrap.rs index 2c45676..1cad500 100644 --- a/examples/basic/bootstrap.rs +++ b/examples/basic/bootstrap.rs @@ -1,7 +1,7 @@ use std::error::Error; use std::rc::Rc; -use syrette::DIContainer; +use syrette::di_container::blocking::prelude::*; use crate::animals::cat::Cat; use crate::animals::dog::Dog; diff --git a/examples/basic/main.rs b/examples/basic/main.rs index dbc9215..7b129e9 100644 --- a/examples/basic/main.rs +++ b/examples/basic/main.rs @@ -11,6 +11,7 @@ mod interfaces; use bootstrap::bootstrap; use interfaces::dog::IDog; use interfaces::human::IHuman; +use syrette::di_container::blocking::prelude::*; fn main() -> Result<(), Box> { diff --git a/examples/factory/bootstrap.rs b/examples/factory/bootstrap.rs index f8bef6e..e535dd2 100644 --- a/examples/factory/bootstrap.rs +++ b/examples/factory/bootstrap.rs @@ -1,8 +1,8 @@ use std::error::Error; use std::rc::Rc; +use syrette::di_container::blocking::prelude::*; use syrette::ptr::TransientPtr; -use syrette::DIContainer; use crate::interfaces::user::{IUser, IUserFactory}; use crate::interfaces::user_manager::IUserManager; diff --git a/examples/factory/main.rs b/examples/factory/main.rs index 0f1a97b..d428717 100644 --- a/examples/factory/main.rs +++ b/examples/factory/main.rs @@ -9,8 +9,9 @@ mod user_manager; use std::error::Error; -use bootstrap::bootstrap; +use syrette::di_container::blocking::prelude::*; +use crate::bootstrap::bootstrap; use crate::interfaces::user_manager::IUserManager; fn main() -> Result<(), Box> diff --git a/examples/generics/bootstrap.rs b/examples/generics/bootstrap.rs index 98d03db..4034aa8 100644 --- a/examples/generics/bootstrap.rs +++ b/examples/generics/bootstrap.rs @@ -1,6 +1,7 @@ use std::rc::Rc; -use syrette::{di_container_bind, DIContainer}; +use syrette::di_container::blocking::prelude::*; +use syrette::di_container_bind; use crate::interfaces::printer::IPrinter; use crate::printer::Printer; diff --git a/examples/generics/main.rs b/examples/generics/main.rs index f491aa0..7910cad 100644 --- a/examples/generics/main.rs +++ b/examples/generics/main.rs @@ -4,8 +4,10 @@ mod printer; use std::error::Error; -use bootstrap::bootstrap; -use interfaces::printer::IPrinter; +use syrette::di_container::blocking::prelude::*; + +use crate::bootstrap::bootstrap; +use crate::interfaces::printer::IPrinter; fn main() -> Result<(), Box> { diff --git a/examples/named/bootstrap.rs b/examples/named/bootstrap.rs index 5f63b47..f7edc5d 100644 --- a/examples/named/bootstrap.rs +++ b/examples/named/bootstrap.rs @@ -1,7 +1,7 @@ use std::rc::Rc; use anyhow::Result; -use syrette::DIContainer; +use syrette::di_container::blocking::prelude::*; use crate::interfaces::ninja::INinja; use crate::interfaces::weapon::IWeapon; diff --git a/examples/named/main.rs b/examples/named/main.rs index 5411a12..e7cccd0 100644 --- a/examples/named/main.rs +++ b/examples/named/main.rs @@ -9,6 +9,7 @@ mod ninja; mod shuriken; use anyhow::Result; +use syrette::di_container::blocking::prelude::*; use crate::bootstrap::bootstrap; use crate::interfaces::ninja::INinja; diff --git a/examples/unbound/bootstrap.rs b/examples/unbound/bootstrap.rs index 04643dc..61e5326 100644 --- a/examples/unbound/bootstrap.rs +++ b/examples/unbound/bootstrap.rs @@ -1,7 +1,7 @@ use std::rc::Rc; use anyhow::Result; -use syrette::DIContainer; +use syrette::di_container::blocking::prelude::*; use crate::animal_store::AnimalStore; use crate::animals::dog::Dog; diff --git a/examples/unbound/main.rs b/examples/unbound/main.rs index f8dddbb..29fa0d4 100644 --- a/examples/unbound/main.rs +++ b/examples/unbound/main.rs @@ -2,16 +2,17 @@ #![deny(clippy::pedantic)] #![allow(clippy::module_name_repetitions)] -use anyhow::Result; - mod animal_store; mod animals; mod bootstrap; mod interfaces; -use bootstrap::bootstrap; -use interfaces::dog::IDog; -use interfaces::human::IHuman; +use anyhow::Result; +use syrette::di_container::blocking::prelude::*; + +use crate::bootstrap::bootstrap; +use crate::interfaces::dog::IDog; +use crate::interfaces::human::IHuman; fn main() -> Result<()> { diff --git a/examples/with-3rd-party/bootstrap.rs b/examples/with-3rd-party/bootstrap.rs index 4fea754..9a55eb1 100644 --- a/examples/with-3rd-party/bootstrap.rs +++ b/examples/with-3rd-party/bootstrap.rs @@ -1,8 +1,9 @@ use std::error::Error; use std::rc::Rc; +use syrette::declare_default_factory; +use syrette::di_container::blocking::prelude::*; use syrette::ptr::TransientPtr; -use syrette::{declare_default_factory, DIContainer}; use third_party_lib::Shuriken; use crate::interfaces::ninja::INinja; diff --git a/examples/with-3rd-party/main.rs b/examples/with-3rd-party/main.rs index e48c78f..520038e 100644 --- a/examples/with-3rd-party/main.rs +++ b/examples/with-3rd-party/main.rs @@ -2,12 +2,14 @@ #![deny(clippy::pedantic)] #![allow(clippy::module_name_repetitions)] -use std::error::Error; - mod bootstrap; mod interfaces; mod ninja; +use std::error::Error; + +use syrette::di_container::blocking::prelude::*; + use crate::bootstrap::bootstrap; use crate::interfaces::ninja::INinja; -- cgit v1.2.3-18-g5258