use crate::api::{
Attrs, CopyOptions, DirectoryListing, MkDirOp, OpenOp, ResourceLimits, Result, SetAttrsOp,
WriteResult,
};
use std::path::Path;
use super::{DirHandle, FileHandle};
pub trait Vfsi {
fn same_object_namespace(&self, _left: &Path, _right: &Path) -> bool {
true
}
fn vstatfs<P: crate::AsTarget<Self::File>>(
&self,
targets: &[P],
) -> Result<Vec<crate::FilesystemStats>>;
fn vgetattrs<P: crate::AsTarget<Self::File>>(
&self,
paths: &[P],
options: crate::api::AttrsOptions,
) -> Result<Vec<Attrs>>;
fn vfsync(&self, files: &[&Self::File], mode: crate::api::SyncMode) -> Result<()>;
fn vsetattrs<P: crate::api::AsTarget<Self::File>>(
&self,
updates: &[SetAttrsOp<P>],
) -> Result<()>;
fn capabilities(&self) -> Result<crate::api::Capabilities>;
fn vsymlink<P: AsRef<Path>, Q: AsRef<Path>>(&self, pairs: &[(P, Q)]) -> Result<()>;
fn vreadlink<P: AsRef<Path>>(&self, paths: &[P]) -> Result<Vec<std::path::PathBuf>>;
fn vhardlink<P: AsRef<Path>, Q: AsRef<Path>>(&self, pairs: &[(P, Q)]) -> Result<()>;
type Dir: DirHandle + 'static;
fn vopen_dirs<P: AsRef<Path>>(&self, paths: &[P]) -> Result<Vec<Self::Dir>> {
if paths.is_empty() {
Ok(Vec::new())
} else {
Err(crate::api::Error::unsupported(0))
}
}
fn vremove_dir_contents(
&self,
dirs: &[&Self::Dir],
options: crate::RemoveOptions,
) -> Result<()> {
let _ = options;
if dirs.is_empty() {
Ok(())
} else {
Err(crate::api::Error::unsupported(0))
}
}
type File: FileHandle + 'static;
fn limits(&self) -> ResourceLimits;
fn vopen(&self, requests: &[OpenOp]) -> Result<Vec<Self::File>>;
fn vread<'a>(
&self,
ops: impl IntoIterator<Item = crate::api::ReadOp<'a, Self::File>>,
options: crate::api::ReadOptions,
) -> Result<Vec<crate::api::ReadResult>>;
fn vwrite<'a>(
&self,
requests: &[crate::api::WriteOp<'a, Self::File>],
options: crate::api::WriteOptions,
) -> Result<Vec<WriteResult>>;
fn vclose(&self, files: &mut [Self::File]) -> Result<()>;
fn vmkdir<P: AsRef<Path>>(&self, directories: &[MkDirOp<P>]) -> Result<()>;
fn vcopy<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
pairs: &[(P, Q)],
options: CopyOptions,
) -> Result<()>;
fn vremove<P: AsRef<Path>>(
&self,
paths: &[P],
mode: crate::api::RemoveMode,
options: crate::api::RemoveOptions,
) -> Result<()>;
fn vrename<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
pairs: &[(P, Q)],
options: crate::api::RenameMode,
) -> Result<()>;
fn vlistdirs<P: AsRef<Path>>(
&self,
paths: &[P],
options: crate::api::ListDirOptions,
callback: impl FnMut(usize, DirectoryListing) -> Result<std::ops::ControlFlow<()>>,
) -> Result<Vec<crate::api::TraversalCompletion>>;
fn vstream<P: AsRef<Path>>(
&self,
paths: &[P],
options: crate::api::StreamOptions,
callback: impl FnMut(usize, u64, &[u8]) -> Result<std::ops::ControlFlow<()>>,
) -> Result<Vec<crate::api::StreamCompletion>>;
}