diff --git a/src/vfs.rs b/src/vfs.rs index 22753533..00b7617d 100644 --- a/src/vfs.rs +++ b/src/vfs.rs @@ -36,6 +36,10 @@ pub struct VfsChange { route: Vec, } +/// A VfsItem represents either a file or directory as it came from the filesystem. +/// +/// The interface here is intentionally simplified to make it easier to traverse +/// files that have been read into memory. #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase", tag = "type")] pub enum VfsItem { @@ -171,12 +175,15 @@ impl Vfs { } } + /// Get the current time, used for logging timestamps for file changes. pub fn current_time(&self) -> f64 { let elapsed = self.start_time.elapsed(); elapsed.as_secs() as f64 + elapsed.subsec_nanos() as f64 * 1e-9 } + /// Register a new change to the filesystem at the given timestamp and VFS + /// route. pub fn add_change(&mut self, timestamp: f64, route: Vec) { if self.config.verbose { println!("Received change {:?}, running through plugins...", route); @@ -199,6 +206,7 @@ impl Vfs { } } + /// Collect a list of changes that occured since the given timestamp. pub fn changes_since(&self, timestamp: f64) -> &[VfsChange] { let mut marker: Option = None; @@ -217,6 +225,7 @@ impl Vfs { } } + /// Read an item from the filesystem using the given VFS route. pub fn read(&self, route: &[String]) -> Result { match self.route_to_path(route) { Some(path) => self.read_path(route, &path), diff --git a/src/vfs_watch.rs b/src/vfs_watch.rs index 872ba683..cb0d15be 100644 --- a/src/vfs_watch.rs +++ b/src/vfs_watch.rs @@ -8,6 +8,8 @@ use core::Config; use pathext::path_to_route; use vfs::Vfs; +/// An object that registers watchers on the real filesystem and relays those +/// changes to the virtual filesystem layer. pub struct VfsWatcher { vfs: Arc>, watchers: Vec,