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.

Implementors§

source§

impl FileSystem for DefaultFileSystem

§

type Handle = LogFd

§

type Reader = LogFile

§

type Writer = LogFile

source§

impl FileSystem for ObfuscatedFileSystem

§

type Handle = <DefaultFileSystem as FileSystem>::Handle

§

type Reader = ObfuscatedReader

§

type Writer = ObfuscatedWriter