Skip to main content

hara_native/lang/protocol/
iwatch.rs

1use hara_protocol_macros::hara_protocol;
2
3#[hara_protocol(namespace = "std.protocol.iwatch", name = "IWatch")]
4pub trait IWatch<V: Clone> {
5    type Key: Clone + Eq;
6    type WatchEntry;
7
8    #[hara_method(value = "watch-add", arity = 3)]
9    fn add_watch(&self, key: Self::Key, watch: impl Fn(&Self::WatchEntry) + Send + Sync + 'static);
10    #[hara_method(value = "watch-remove", arity = 2)]
11    fn remove_watch(&self, key: &Self::Key);
12    #[hara_method(value = "watch-list", arity = 1)]
13    fn list_watches(&self) -> Vec<Self::WatchEntry> {
14        Vec::new()
15    }
16
17    fn notify_watches(&self, old_value: V, new_value: V);
18}