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
use crossbeam_channel::Receiver;
use crate::{Error, Evaluator, Model, ModelEvent, Watcher};
pub struct Host {
evaluator: Evaluator,
_watcher: Watcher,
}
impl Host {
pub fn from_model(model: Model) -> Result<Self, Error> {
let watch_path = model.watch_path();
let evaluator = Evaluator::from_model(model);
let watcher = Watcher::watch_model(&watch_path, &evaluator)?;
Ok(Self {
evaluator,
_watcher: watcher,
})
}
pub fn events(&self) -> Receiver<ModelEvent> {
self.evaluator.events()
}
}