diff options
Diffstat (limited to 'crates/ra_vfs/src/lib.rs')
-rw-r--r-- | crates/ra_vfs/src/lib.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs index 8005c4ff8..3cd11c9f6 100644 --- a/crates/ra_vfs/src/lib.rs +++ b/crates/ra_vfs/src/lib.rs | |||
@@ -33,10 +33,20 @@ use crate::{ | |||
33 | roots::Roots, | 33 | roots::Roots, |
34 | }; | 34 | }; |
35 | 35 | ||
36 | pub use crate::{ | 36 | pub use crate::roots::VfsRoot; |
37 | io::TaskResult as VfsTask, | 37 | |
38 | roots::VfsRoot, | 38 | /// Opaque wrapper around file-system event. |
39 | }; | 39 | /// |
40 | /// Calling code is expected to just pass `VfsTask` to `handle_task` method. It | ||
41 | /// is exposed as a public API so that the caller can plug vfs events into the | ||
42 | /// main event loop and be notified when changes happen. | ||
43 | pub struct VfsTask(TaskResult); | ||
44 | |||
45 | impl fmt::Debug for VfsTask { | ||
46 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
47 | f.write_str("VfsTask { ... }") | ||
48 | } | ||
49 | } | ||
40 | 50 | ||
41 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 51 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
42 | pub struct VfsFile(pub u32); | 52 | pub struct VfsFile(pub u32); |
@@ -159,12 +169,12 @@ impl Vfs { | |||
159 | mem::replace(&mut self.pending_changes, Vec::new()) | 169 | mem::replace(&mut self.pending_changes, Vec::new()) |
160 | } | 170 | } |
161 | 171 | ||
162 | pub fn task_receiver(&self) -> &Receiver<io::TaskResult> { | 172 | pub fn task_receiver(&self) -> &Receiver<VfsTask> { |
163 | self.worker.receiver() | 173 | self.worker.receiver() |
164 | } | 174 | } |
165 | 175 | ||
166 | pub fn handle_task(&mut self, task: io::TaskResult) { | 176 | pub fn handle_task(&mut self, task: VfsTask) { |
167 | match task { | 177 | match task.0 { |
168 | TaskResult::BulkLoadRoot { root, files } => { | 178 | TaskResult::BulkLoadRoot { root, files } => { |
169 | let mut cur_files = Vec::new(); | 179 | let mut cur_files = Vec::new(); |
170 | // While we were scanning the root in the background, a file might have | 180 | // While we were scanning the root in the background, a file might have |