VFS crate

This commit is contained in:
Lucien Greathouse
2020-02-18 22:30:12 -08:00
parent 8f21514855
commit 838e8f6bde
6 changed files with 214 additions and 7 deletions

36
vfs/src/noop_backend.rs Normal file
View File

@@ -0,0 +1,36 @@
use std::io;
use std::path::Path;
use crate::{Metadata, ReadDir, VfsBackend};
pub struct NoopBackend;
impl VfsBackend for NoopBackend {
fn read(&self, path: &Path) -> io::Result<Vec<u8>> {
Err(io::Error::new(
io::ErrorKind::Other,
"NoopBackend doesn't do anything",
))
}
fn write(&self, path: &Path, data: &[u8]) -> io::Result<()> {
Err(io::Error::new(
io::ErrorKind::Other,
"NoopBackend doesn't do anything",
))
}
fn read_dir(&self, path: &Path) -> io::Result<ReadDir> {
Err(io::Error::new(
io::ErrorKind::Other,
"NoopBackend doesn't do anything",
))
}
fn metadata(&self, path: &Path) -> io::Result<Metadata> {
Err(io::Error::new(
io::ErrorKind::Other,
"NoopBackend doesn't do anything",
))
}
}