aboutsummaryrefslogtreecommitdiff
path: root/crates/vfs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/vfs')
-rw-r--r--crates/vfs/src/loader.rs12
-rw-r--r--crates/vfs/src/vfs_path.rs19
2 files changed, 23 insertions, 8 deletions
diff --git a/crates/vfs/src/loader.rs b/crates/vfs/src/loader.rs
index a216b5f13..6de2e5b3f 100644
--- a/crates/vfs/src/loader.rs
+++ b/crates/vfs/src/loader.rs
@@ -1,7 +1,7 @@
1//! Object safe interface for file watching and reading. 1//! Object safe interface for file watching and reading.
2use std::fmt; 2use std::fmt;
3 3
4use paths::AbsPathBuf; 4use paths::{AbsPath, AbsPathBuf};
5 5
6#[derive(Debug)] 6#[derive(Debug)]
7pub enum Entry { 7pub enum Entry {
@@ -16,7 +16,7 @@ pub struct Config {
16} 16}
17 17
18pub enum Message { 18pub enum Message {
19 Progress { n_entries_total: usize, n_entries_done: usize }, 19 Progress { n_total: usize, n_done: usize },
20 Loaded { files: Vec<(AbsPathBuf, Option<Vec<u8>>)> }, 20 Loaded { files: Vec<(AbsPathBuf, Option<Vec<u8>>)> },
21} 21}
22 22
@@ -28,7 +28,7 @@ pub trait Handle: fmt::Debug {
28 Self: Sized; 28 Self: Sized;
29 fn set_config(&mut self, config: Config); 29 fn set_config(&mut self, config: Config);
30 fn invalidate(&mut self, path: AbsPathBuf); 30 fn invalidate(&mut self, path: AbsPathBuf);
31 fn load_sync(&mut self, path: &AbsPathBuf) -> Option<Vec<u8>>; 31 fn load_sync(&mut self, path: &AbsPath) -> Option<Vec<u8>>;
32} 32}
33 33
34impl Entry { 34impl Entry {
@@ -56,10 +56,10 @@ impl fmt::Debug for Message {
56 Message::Loaded { files } => { 56 Message::Loaded { files } => {
57 f.debug_struct("Loaded").field("n_files", &files.len()).finish() 57 f.debug_struct("Loaded").field("n_files", &files.len()).finish()
58 } 58 }
59 Message::Progress { n_entries_total, n_entries_done } => f 59 Message::Progress { n_total, n_done } => f
60 .debug_struct("Progress") 60 .debug_struct("Progress")
61 .field("n_entries_total", n_entries_total) 61 .field("n_total", n_total)
62 .field("n_entries_done", n_entries_done) 62 .field("n_done", n_done)
63 .finish(), 63 .finish(),
64 } 64 }
65 } 65 }
diff --git a/crates/vfs/src/vfs_path.rs b/crates/vfs/src/vfs_path.rs
index 0a8a86c62..940f91d0e 100644
--- a/crates/vfs/src/vfs_path.rs
+++ b/crates/vfs/src/vfs_path.rs
@@ -5,7 +5,7 @@ use paths::{AbsPath, AbsPathBuf};
5 5
6/// Long-term, we want to support files which do not reside in the file-system, 6/// Long-term, we want to support files which do not reside in the file-system,
7/// so we treat VfsPaths as opaque identifiers. 7/// so we treat VfsPaths as opaque identifiers.
8#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] 8#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
9pub struct VfsPath(VfsPathRepr); 9pub struct VfsPath(VfsPathRepr);
10 10
11impl VfsPath { 11impl VfsPath {
@@ -50,7 +50,7 @@ impl VfsPath {
50 } 50 }
51} 51}
52 52
53#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] 53#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
54enum VfsPathRepr { 54enum VfsPathRepr {
55 PathBuf(AbsPathBuf), 55 PathBuf(AbsPathBuf),
56 VirtualPath(VirtualPath), 56 VirtualPath(VirtualPath),
@@ -71,6 +71,21 @@ impl fmt::Display for VfsPath {
71 } 71 }
72} 72}
73 73
74impl fmt::Debug for VfsPath {
75 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
76 fmt::Debug::fmt(&self.0, f)
77 }
78}
79
80impl fmt::Debug for VfsPathRepr {
81 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
82 match &self {
83 VfsPathRepr::PathBuf(it) => fmt::Debug::fmt(&it.display(), f),
84 VfsPathRepr::VirtualPath(VirtualPath(it)) => fmt::Debug::fmt(&it, f),
85 }
86 }
87}
88
74#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] 89#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
75struct VirtualPath(String); 90struct VirtualPath(String);
76 91