1use std::sync::Arc;
3
4#[derive(Clone)]
6pub struct Shell(Arc<dyn Notifier>);
7
8impl Shell {
9    pub fn new(notifier: impl Notifier) -> Self {
11        Self(Arc::new(notifier))
12    }
13
14    pub fn headless() -> Self {
16        struct Headless;
17
18        impl Notifier for Headless {
19            fn request_redraw(&self) {}
20
21            fn invalidate_layout(&self) {}
22        }
23
24        Self::new(Headless)
25    }
26
27    pub fn request_redraw(&self) {
29        self.0.request_redraw();
30    }
31
32    pub fn invalidate_layout(&self) {
34        self.0.invalidate_layout();
35    }
36}
37
38pub trait Notifier: Send + Sync + 'static {
40    fn request_redraw(&self);
42
43    fn invalidate_layout(&self);
45}