Skip to main content

FileSystem

Trait FileSystem 

Source
pub trait FileSystem: Send + Sync {
    // Required methods
    fn can_handle(&self, path: &str) -> bool;
    fn open_read(&self, path: &str) -> Result<Box<dyn FileRead>>;
    fn open_write(&self, path: &str) -> Result<Box<dyn FileWrite>>;
    fn exists(&self, path: &str) -> bool;
    fn remove(&self, path: &str) -> Result<()>;
    fn create_dir_all(&self, path: &str) -> Result<()>;
}
Expand description

A generic file system interface.

Required Methods§

Source

fn can_handle(&self, path: &str) -> bool

Check if this file system can handle the given path/URL.

Source

fn open_read(&self, path: &str) -> Result<Box<dyn FileRead>>

Open a file for reading.

Source

fn open_write(&self, path: &str) -> Result<Box<dyn FileWrite>>

Open a file for writing (creates or truncates).

Source

fn exists(&self, path: &str) -> bool

Check if a path exists.

Source

fn remove(&self, path: &str) -> Result<()>

Remove a file.

Source

fn create_dir_all(&self, path: &str) -> Result<()>

Create a directory and all parents.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§