mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
Batch rename: imfs -> vfs
This commit is contained in:
36
src/vfs/fetcher.rs
Normal file
36
src/vfs/fetcher.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use std::{
|
||||
io,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use crossbeam_channel::Receiver;
|
||||
|
||||
use super::event::VfsEvent;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum FileType {
|
||||
File,
|
||||
Directory,
|
||||
}
|
||||
|
||||
/// The generic interface that `Vfs` uses to lazily read files from the disk.
|
||||
/// In tests, it's stubbed out to do different versions of absolutely nothing
|
||||
/// depending on the test.
|
||||
pub trait VfsFetcher {
|
||||
fn file_type(&mut self, path: &Path) -> io::Result<FileType>;
|
||||
fn read_children(&mut self, path: &Path) -> io::Result<Vec<PathBuf>>;
|
||||
fn read_contents(&mut self, path: &Path) -> io::Result<Vec<u8>>;
|
||||
|
||||
fn create_directory(&mut self, path: &Path) -> io::Result<()>;
|
||||
fn write_file(&mut self, path: &Path, contents: &[u8]) -> io::Result<()>;
|
||||
fn remove(&mut self, path: &Path) -> io::Result<()>;
|
||||
|
||||
fn watch(&mut self, path: &Path);
|
||||
fn unwatch(&mut self, path: &Path);
|
||||
fn receiver(&self) -> Receiver<VfsEvent>;
|
||||
|
||||
/// A method intended for debugging what paths the fetcher is watching.
|
||||
fn watched_paths(&self) -> Vec<&Path> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user