Trait FileSystem

Source
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§

Required Methods§

Source

fn create<P: AsRef<Path>>(&self, path: P) -> Result<Self::Handle>

Source

fn open<P: AsRef<Path>>( &self, path: P, perm: Permission, ) -> Result<Self::Handle>

Source

fn delete<P: AsRef<Path>>(&self, path: P) -> Result<()>

Source

fn rename<P: AsRef<Path>>(&self, src_path: P, dst_path: P) -> Result<()>

Source

fn new_reader(&self, handle: Arc<Self::Handle>) -> Result<Self::Reader>

Source

fn new_writer(&self, handle: Arc<Self::Handle>) -> Result<Self::Writer>

Provided Methods§

Source

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.

Source

fn reuse_and_open<P: AsRef<Path>>( &self, src_path: P, dst_path: P, ) -> Result<Self::Handle>

Source

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.

Source

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.

Implementors§

Source§

impl FileSystem for DefaultFileSystem

Source§

type Handle = LogFd

Source§

type Reader = LogFile

Source§

type Writer = LogFile

Source§

impl FileSystem for ObfuscatedFileSystem

Source§

type Handle = <DefaultFileSystem as FileSystem>::Handle

Source§

type Reader = ObfuscatedReader

Source§

type Writer = ObfuscatedWriter