diff options
author | Aleksey Kladov <[email protected]> | 2018-08-30 14:27:09 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-30 14:27:09 +0100 |
commit | 9fcebbc51284408203c05219a0ee92519f51ea74 (patch) | |
tree | 5fd3f53769e3fe5b8f6a0d2a5eaa86167b7a3b10 /crates/server/src/main_loop/subscriptions.rs | |
parent | 7570d85869da7e2d35958047f8d1a90e3b6e2212 (diff) |
subscriptions
Diffstat (limited to 'crates/server/src/main_loop/subscriptions.rs')
-rw-r--r-- | crates/server/src/main_loop/subscriptions.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/crates/server/src/main_loop/subscriptions.rs b/crates/server/src/main_loop/subscriptions.rs new file mode 100644 index 000000000..963096aef --- /dev/null +++ b/crates/server/src/main_loop/subscriptions.rs | |||
@@ -0,0 +1,21 @@ | |||
1 | use std::collections::HashSet; | ||
2 | use libanalysis::FileId; | ||
3 | |||
4 | pub struct Subscriptions { | ||
5 | subs: HashSet<FileId>, | ||
6 | } | ||
7 | |||
8 | impl Subscriptions { | ||
9 | pub fn new() -> Subscriptions { | ||
10 | Subscriptions { subs: HashSet::new() } | ||
11 | } | ||
12 | pub fn add_sub(&mut self, file_id: FileId) { | ||
13 | self.subs.insert(file_id); | ||
14 | } | ||
15 | pub fn remove_sub(&mut self, file_id: FileId) { | ||
16 | self.subs.remove(&file_id); | ||
17 | } | ||
18 | pub fn subscriptions(&self) -> Vec<FileId> { | ||
19 | self.subs.iter().cloned().collect() | ||
20 | } | ||
21 | } | ||