use crate::error::VfsErrorKind;
use crate::{SeekAndRead, 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> + Send>>;
fn create_dir(&self, path: &str) -> VfsResult<()>;
fn open_file(&self, path: &str) -> VfsResult<Box<dyn SeekAndRead + Send>>;
fn create_file(&self, path: &str) -> VfsResult<Box<dyn Write + Send>>;
fn append_file(&self, path: &str) -> VfsResult<Box<dyn Write + Send>>;
fn metadata(&self, path: &str) -> VfsResult<VfsMetadata>;
fn exists(&self, path: &str) -> VfsResult<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(VfsErrorKind::NotSupported.into())
}
fn move_file(&self, _src: &str, _dest: &str) -> VfsResult<()> {
Err(VfsErrorKind::NotSupported.into())
}
fn move_dir(&self, _src: &str, _dest: &str) -> VfsResult<()> {
Err(VfsErrorKind::NotSupported.into())
}
}
impl<T: FileSystem> From<T> for VfsPath {
fn from(filesystem: T) -> Self {
VfsPath::new(filesystem)
}
}