From 8aeb7ad439b67228a0abc46b259967e8c91f8a97 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 17 Aug 2023 22:04:17 +0200 Subject: docs: remove the 'unbound' example This was not at all a useful example --- examples/unbound/animal_store.rs | 34 -------------------------- examples/unbound/animals/cat.rs | 22 ----------------- examples/unbound/animals/dog.rs | 22 ----------------- examples/unbound/animals/human.rs | 37 ----------------------------- examples/unbound/animals/mod.rs | 3 --- examples/unbound/bootstrap.rs | 29 ---------------------- examples/unbound/interfaces/animal_store.rs | 11 --------- examples/unbound/interfaces/cat.rs | 4 ---- examples/unbound/interfaces/dog.rs | 4 ---- examples/unbound/interfaces/human.rs | 4 ---- examples/unbound/interfaces/mod.rs | 4 ---- examples/unbound/main.rs | 32 ------------------------- 12 files changed, 206 deletions(-) delete mode 100644 examples/unbound/animal_store.rs delete mode 100644 examples/unbound/animals/cat.rs delete mode 100644 examples/unbound/animals/dog.rs delete mode 100644 examples/unbound/animals/human.rs delete mode 100644 examples/unbound/animals/mod.rs delete mode 100644 examples/unbound/bootstrap.rs delete mode 100644 examples/unbound/interfaces/animal_store.rs delete mode 100644 examples/unbound/interfaces/cat.rs delete mode 100644 examples/unbound/interfaces/dog.rs delete mode 100644 examples/unbound/interfaces/human.rs delete mode 100644 examples/unbound/interfaces/mod.rs delete mode 100644 examples/unbound/main.rs (limited to 'examples/unbound') diff --git a/examples/unbound/animal_store.rs b/examples/unbound/animal_store.rs deleted file mode 100644 index b2127e4..0000000 --- a/examples/unbound/animal_store.rs +++ /dev/null @@ -1,34 +0,0 @@ -use syrette::injectable; -use syrette::ptr::{SingletonPtr, TransientPtr}; - -use crate::interfaces::animal_store::IAnimalStore; -use crate::interfaces::cat::ICat; -use crate::interfaces::dog::IDog; - -pub struct AnimalStore -{ - dog: SingletonPtr, - cat: TransientPtr, -} - -#[injectable] -impl AnimalStore -{ - fn new(dog: SingletonPtr, cat: TransientPtr) -> Self - { - Self { dog, cat } - } -} - -impl IAnimalStore for AnimalStore -{ - fn get_dog(&self) -> SingletonPtr - { - self.dog.clone() - } - - fn get_cat(&self) -> &TransientPtr - { - &self.cat - } -} diff --git a/examples/unbound/animals/cat.rs b/examples/unbound/animals/cat.rs deleted file mode 100644 index 153ad4b..0000000 --- a/examples/unbound/animals/cat.rs +++ /dev/null @@ -1,22 +0,0 @@ -use syrette::injectable; - -use crate::interfaces::cat::ICat; - -pub struct Cat {} - -#[injectable(ICat)] -impl Cat -{ - pub fn new() -> Self - { - Self {} - } -} - -impl ICat for Cat -{ - fn meow(&self) - { - println!("Meow!"); - } -} diff --git a/examples/unbound/animals/dog.rs b/examples/unbound/animals/dog.rs deleted file mode 100644 index 84959c0..0000000 --- a/examples/unbound/animals/dog.rs +++ /dev/null @@ -1,22 +0,0 @@ -use syrette::injectable; - -use crate::interfaces::dog::IDog; - -pub struct Dog {} - -#[injectable(IDog)] -impl Dog -{ - pub fn new() -> Self - { - Self {} - } -} - -impl IDog for Dog -{ - fn woof(&self) - { - println!("Woof!"); - } -} diff --git a/examples/unbound/animals/human.rs b/examples/unbound/animals/human.rs deleted file mode 100644 index 56764d3..0000000 --- a/examples/unbound/animals/human.rs +++ /dev/null @@ -1,37 +0,0 @@ -use syrette::injectable; -use syrette::ptr::TransientPtr; - -use crate::interfaces::animal_store::IAnimalStore; -use crate::interfaces::human::IHuman; - -pub struct Human -{ - animal_store: TransientPtr, -} - -#[injectable(IHuman)] -impl Human -{ - pub fn new(animal_store: TransientPtr) -> Self - { - Self { animal_store } - } -} - -impl IHuman for Human -{ - fn make_pets_make_sounds(&self) - { - let dog = self.animal_store.get_dog(); - - println!("Hi doggy!"); - - dog.woof(); - - let cat = self.animal_store.get_cat(); - - println!("Hi kitty!"); - - cat.meow(); - } -} diff --git a/examples/unbound/animals/mod.rs b/examples/unbound/animals/mod.rs deleted file mode 100644 index 5444978..0000000 --- a/examples/unbound/animals/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod cat; -pub mod dog; -pub mod human; diff --git a/examples/unbound/bootstrap.rs b/examples/unbound/bootstrap.rs deleted file mode 100644 index 61e5326..0000000 --- a/examples/unbound/bootstrap.rs +++ /dev/null @@ -1,29 +0,0 @@ -use std::rc::Rc; - -use anyhow::Result; -use syrette::di_container::blocking::prelude::*; - -use crate::animal_store::AnimalStore; -use crate::animals::dog::Dog; -use crate::animals::human::Human; -use crate::interfaces::animal_store::IAnimalStore; -use crate::interfaces::dog::IDog; -use crate::interfaces::human::IHuman; - -pub fn bootstrap() -> Result> -{ - let mut di_container = DIContainer::new(); - - di_container - .bind::() - .to::()? - .in_singleton_scope()?; - - di_container.bind::().to::()?; - - di_container - .bind::() - .to::()?; - - Ok(di_container) -} diff --git a/examples/unbound/interfaces/animal_store.rs b/examples/unbound/interfaces/animal_store.rs deleted file mode 100644 index dc8a4c3..0000000 --- a/examples/unbound/interfaces/animal_store.rs +++ /dev/null @@ -1,11 +0,0 @@ -use syrette::ptr::{SingletonPtr, TransientPtr}; - -use crate::interfaces::cat::ICat; -use crate::interfaces::dog::IDog; - -pub trait IAnimalStore -{ - fn get_dog(&self) -> SingletonPtr; - - fn get_cat(&self) -> &TransientPtr; -} diff --git a/examples/unbound/interfaces/cat.rs b/examples/unbound/interfaces/cat.rs deleted file mode 100644 index 8650802..0000000 --- a/examples/unbound/interfaces/cat.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub trait ICat -{ - fn meow(&self); -} diff --git a/examples/unbound/interfaces/dog.rs b/examples/unbound/interfaces/dog.rs deleted file mode 100644 index 4211c27..0000000 --- a/examples/unbound/interfaces/dog.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub trait IDog -{ - fn woof(&self); -} diff --git a/examples/unbound/interfaces/human.rs b/examples/unbound/interfaces/human.rs deleted file mode 100644 index dc20194..0000000 --- a/examples/unbound/interfaces/human.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub trait IHuman -{ - fn make_pets_make_sounds(&self); -} diff --git a/examples/unbound/interfaces/mod.rs b/examples/unbound/interfaces/mod.rs deleted file mode 100644 index bd9f848..0000000 --- a/examples/unbound/interfaces/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod animal_store; -pub mod cat; -pub mod dog; -pub mod human; diff --git a/examples/unbound/main.rs b/examples/unbound/main.rs deleted file mode 100644 index 29fa0d4..0000000 --- a/examples/unbound/main.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![deny(clippy::all)] -#![deny(clippy::pedantic)] -#![allow(clippy::module_name_repetitions)] - -mod animal_store; -mod animals; -mod bootstrap; -mod interfaces; - -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<()> -{ - println!("Hello, world!"); - - let di_container = bootstrap()?; - - let dog = di_container.get::()?.singleton()?; - - dog.woof(); - - let human = di_container.get::()?.transient()?; - - human.make_pets_make_sounds(); - - Ok(()) -} -- cgit v1.2.3-18-g5258