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§
Sourcefn open_with_options(
&self,
path: &Path,
options: OpenOptions,
) -> Result<Box<dyn File>>
fn open_with_options( &self, path: &Path, options: OpenOptions, ) -> Result<Box<dyn File>>
It opens a file with the given set of options
Sourcefn traversal<'scope>(
&'scope self,
func: Box<dyn FnOnce(&dyn TraversalScope<'scope>) + Send + '_>,
)
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
Sourcefn working_directory(&self) -> Option<PathBuf>
fn working_directory(&self) -> Option<PathBuf>
Return the path to the working directory
Sourcefn path_exists(&self, path: &Path) -> bool
fn path_exists(&self, path: &Path) -> bool
Checks if the given path exists in the file system
Sourcefn path_is_file(&self, path: &Path) -> bool
fn path_is_file(&self, path: &Path) -> bool
Checks if the given path is a regular file
fn get_changed_files(&self, base: &str) -> Result<Vec<String>>
fn resolve_configuration(&self, path: &str) -> Result<Resolution, ResolveError>
Provided Methods§
Sourcefn deprecated_config_name(&self) -> &str
fn deprecated_config_name(&self) -> &str
Returns the temporary configuration files that are supported
Sourcefn auto_search(
&self,
file_path: PathBuf,
file_names: &[&str],
should_error_if_file_not_found: bool,
) -> Result<Option<AutoSearchResult>, FileSystemDiagnostic>
fn auto_search( &self, file_path: PathBuf, file_names: &[&str], should_error_if_file_not_found: bool, ) -> Result<Option<AutoSearchResult>, FileSystemDiagnostic>
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