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
46
use super::{Instance, Platform};
use std::rc::Weak;
pub struct Link<P>
where
P: Platform + ?Sized,
{
instance: Weak<Instance<P>>,
}
impl<P> Clone for Link<P>
where
P: Platform + ?Sized,
{
fn clone(&self) -> Self {
Link {
instance: self.instance.clone(),
}
}
}
impl<P> Link<P>
where
P: Platform + ?Sized,
{
pub fn new(instance: Weak<Instance<P>>) -> Link<P> {
Link { instance }
}
}
pub trait Trigger: 'static {
fn trigger(&self);
}
impl<P> Trigger for Link<P>
where
P: Platform + ?Sized,
{
fn trigger(&self) {
if let Some(instance) = self.instance.clone().upgrade() {
instance.renderer().rerender(&instance);
}
}
}