pub trait FileSystem: Send + Sync {
type Handle: Send + Sync + Handle;
type Reader: Seek + Read + Send;
type Writer: Seek + Write + Send + WriteExt;
// Required methods
fn create<P: AsRef<Path>>(&self, path: P) -> Result<Self::Handle>;
fn open<P: AsRef<Path>>(
&self,
path: P,
perm: Permission,
) -> Result<Self::Handle>;
fn delete<P: AsRef<Path>>(&self, path: P) -> Result<()>;
fn rename<P: AsRef<Path>>(&self, src_path: P, dst_path: P) -> Result<()>;
fn new_reader(&self, handle: Arc<Self::Handle>) -> Result<Self::Reader>;
fn new_writer(&self, handle: Arc<Self::Handle>) -> Result<Self::Writer>;
// Provided methods
fn reuse<P: AsRef<Path>>(&self, src_path: P, dst_path: P) -> Result<()> { ... }
fn reuse_and_open<P: AsRef<Path>>(
&self,
src_path: P,
dst_path: P,
) -> Result<Self::Handle> { ... }
fn delete_metadata<P: AsRef<Path>>(&self, _path: P) -> Result<()> { ... }
fn exists_metadata<P: AsRef<Path>>(&self, _path: P) -> bool { ... }
}
Expand description
FileSystem
Required Associated Types§
type Handle: Send + Sync + Handle
type Reader: Seek + Read + Send
type Writer: Seek + Write + Send + WriteExt
Required Methods§
fn create<P: AsRef<Path>>(&self, path: P) -> Result<Self::Handle>
fn open<P: AsRef<Path>>( &self, path: P, perm: Permission, ) -> Result<Self::Handle>
fn delete<P: AsRef<Path>>(&self, path: P) -> Result<()>
fn rename<P: AsRef<Path>>(&self, src_path: P, dst_path: P) -> Result<()>
fn new_reader(&self, handle: Arc<Self::Handle>) -> Result<Self::Reader>
fn new_writer(&self, handle: Arc<Self::Handle>) -> Result<Self::Writer>
Provided Methods§
Sourcefn reuse<P: AsRef<Path>>(&self, src_path: P, dst_path: P) -> Result<()>
fn reuse<P: AsRef<Path>>(&self, src_path: P, dst_path: P) -> Result<()>
Reuses file at src_path
as a new file at dst_path
. The default
implementation simply renames the file.
fn reuse_and_open<P: AsRef<Path>>( &self, src_path: P, dst_path: P, ) -> Result<Self::Handle>
Sourcefn delete_metadata<P: AsRef<Path>>(&self, _path: P) -> Result<()>
fn delete_metadata<P: AsRef<Path>>(&self, _path: P) -> Result<()>
Deletes user implemented metadata associated with path
. Returns
true
if any metadata is deleted.
In older versions of Raft Engine, physical files are deleted without going through user implemented cleanup procedure. This method is used to detect and cleanup the user metadata that is no longer mapped to a physical file.
Sourcefn exists_metadata<P: AsRef<Path>>(&self, _path: P) -> bool
fn exists_metadata<P: AsRef<Path>>(&self, _path: P) -> bool
Returns whether there is any user metadata associated with given path
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.