Trait rspack_fs::sync::WritableFileSystem

source ·
pub trait WritableFileSystem {
    // Required methods
    fn create_dir(&self, dir: &Path) -> Result<()>;
    fn create_dir_all(&self, dir: &Path) -> Result<()>;
    fn write(&self, file: &Path, data: &[u8]) -> Result<()>;
}

Required Methods§

source

fn create_dir(&self, dir: &Path) -> Result<()>

Creates a new, empty directory at the provided path.

NOTE: If a parent of the given path doesn’t exist, this function is supposed to return an error. To create a directory and all its missing parents at the same time, use the [create_dir_all] function.

Error: This function is supposed to return an error in the following situations, but is not limited to just these cases:

  • User lacks permissions to create directory at path.
  • A parent of the given path doesn’t exist. (To create a directory and all its missing parents at the same time, use the create_dir_all function.)
  • Path already exists.
source

fn create_dir_all(&self, dir: &Path) -> Result<()>

Recursively create a directory and all of its parent components if they are missing.

source

fn write(&self, file: &Path, data: &[u8]) -> Result<()>

Write a slice as the entire contents of a file. This function will create a file if it does not exist, and will entirely replace its contents if it does.

Implementors§