1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::{SeekAndRead, VfsError, VfsMetadata, VfsPath, VfsResult};
use std::fmt::Debug;
use std::io::Write;
pub trait FileSystem: Debug + Sync + Send + 'static {
fn read_dir(&self, path: &str) -> VfsResult<Box<dyn Iterator<Item = String>>>;
fn create_dir(&self, path: &str) -> VfsResult<()>;
fn open_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndRead>>;
fn create_file(&self, path: &str) -> VfsResult<Box<dyn Write>>;
fn append_file(&self, path: &str) -> VfsResult<Box<dyn Write>>;
fn metadata(&self, path: &str) -> VfsResult<VfsMetadata>;
fn exists(&self, path: &str) -> bool;
fn remove_file(&self, path: &str) -> VfsResult<()>;
fn remove_dir(&self, path: &str) -> VfsResult<()>;
fn copy_file(&self, _src: &str, _dest: &str) -> VfsResult<()> {
Err(VfsError::NotSupported)
}
fn move_file(&self, _src: &str, _dest: &str) -> VfsResult<()> {
Err(VfsError::NotSupported)
}
fn move_dir(&self, _src: &str, _dest: &str) -> VfsResult<()> {
Err(VfsError::NotSupported)
}
}
impl<T: FileSystem> From<T> for VfsPath {
fn from(filesystem: T) -> Self {
VfsPath::new(filesystem)
}
}