blob: 8ff374f7c7c2519a750aa02d3ab5999f031ad0fa (
plain) (
blame)
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
38
39
40
41
42
43
44
45
|
use crate::{Application, Command, Element};
pub trait Sandbox {
type Message: std::fmt::Debug + Send;
fn new() -> Self;
fn title(&self) -> String;
fn update(&mut self, message: Self::Message);
fn view(&mut self) -> Element<Self::Message>;
fn run()
where
Self: 'static + Sized,
{
<Self as Application>::run()
}
}
impl<T> Application for T
where
T: Sandbox,
{
type Message = T::Message;
fn new() -> (Self, Command<T::Message>) {
(T::new(), Command::none())
}
fn title(&self) -> String {
T::title(self)
}
fn update(&mut self, message: T::Message) -> Command<T::Message> {
T::update(self, message);
Command::none()
}
fn view(&mut self) -> Element<T::Message> {
T::view(self)
}
}
|