1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::rc::Rc;

#[derive(Debug, Clone)]
pub struct Event {
    pub message: String,
}

impl Event {
    pub fn new<S: Into<String>>(s: S) -> Self {
        Self { message: s.into() }
    }
}

pub trait Observable {
    fn register(self, observer: &Rc<dyn Observer>) -> Self;
    fn notify_all(&self, event: Event);
    fn finish_all(&self);
}

pub trait Observer {
    fn notify(&self, event: Event);
    fn finished(&self);
}