FileSystem

Trait FileSystem 

Source
pub trait FileSystem:
    Send
    + Sync
    + RefUnwindSafe {
    // Required methods
    fn open_with_options(
        &self,
        path: &Path,
        options: OpenOptions,
    ) -> Result<Box<dyn File>>;
    fn traversal<'scope>(
        &'scope self,
        func: Box<dyn FnOnce(&dyn TraversalScope<'scope>) + Send + '_>,
    );
    fn working_directory(&self) -> Option<PathBuf>;
    fn path_exists(&self, path: &Path) -> bool;
    fn path_is_file(&self, path: &Path) -> bool;
    fn get_changed_files(&self, base: &str) -> Result<Vec<String>>;
    fn resolve_configuration(
        &self,
        path: &str,
    ) -> Result<Resolution, ResolveError>;

    // Provided methods
    fn deprecated_config_name(&self) -> &str { ... }
    fn auto_search(
        &self,
        file_path: PathBuf,
        file_names: &[&str],
        should_error_if_file_not_found: bool,
    ) -> Result<Option<AutoSearchResult>, FileSystemDiagnostic> { ... }
}

Required Methods§

Source

fn open_with_options( &self, path: &Path, options: OpenOptions, ) -> Result<Box<dyn File>>

It opens a file with the given set of options

Source

fn traversal<'scope>( &'scope self, func: Box<dyn FnOnce(&dyn TraversalScope<'scope>) + Send + '_>, )

Initiate a traversal of the filesystem

This method creates a new “traversal scope” that can be used to efficiently batch many filesystem read operations

Source

fn working_directory(&self) -> Option<PathBuf>

Return the path to the working directory

Source

fn path_exists(&self, path: &Path) -> bool

Checks if the given path exists in the file system

Source

fn path_is_file(&self, path: &Path) -> bool

Checks if the given path is a regular file

Source

fn get_changed_files(&self, base: &str) -> Result<Vec<String>>

Source

fn resolve_configuration(&self, path: &str) -> Result<Resolution, ResolveError>

Provided Methods§

Source

fn deprecated_config_name(&self) -> &str

Returns the temporary configuration files that are supported

Method that takes a path to a folder file_path, and a file_name. It attempts to find and read the file from that folder and if not found, it reads the parent directories recursively until:

  • the file is found, then it reads and return its contents
  • the file is not found

If should_error_if_file_not_found it true, it returns an error.

§Errors
  • The file can’t be read

Implementations on Foreign Types§

Source§

impl<T> FileSystem for Arc<T>
where T: FileSystem + Send,

Source§

fn open_with_options( &self, path: &Path, options: OpenOptions, ) -> Result<Box<dyn File>>

Source§

fn traversal<'scope>( &'scope self, func: Box<dyn FnOnce(&dyn TraversalScope<'scope>) + Send + '_>, )

Source§

fn working_directory(&self) -> Option<PathBuf>

Source§

fn path_exists(&self, path: &Path) -> bool

Source§

fn path_is_file(&self, path: &Path) -> bool

Source§

fn get_changed_files(&self, base: &str) -> Result<Vec<String>>

Source§

fn resolve_configuration(&self, path: &str) -> Result<Resolution, ResolveError>

Implementors§