aboutsummaryrefslogtreecommitdiff
path: root/examples/unbound/animals/human.rs
blob: 56764d39bc8b2d0493136763ac1b607b4ff457aa (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
use syrette::injectable;
use syrette::ptr::TransientPtr;

use crate::interfaces::animal_store::IAnimalStore;
use crate::interfaces::human::IHuman;

pub struct Human
{
    animal_store: TransientPtr<dyn IAnimalStore>,
}

#[injectable(IHuman)]
impl Human
{
    pub fn new(animal_store: TransientPtr<dyn IAnimalStore>) -> 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();
    }
}