pub trait FileSystem:
Debug
+ Send
+ Sync {
// Required methods
fn metadata(&self) -> FileSystemMetadata;
fn path_metadata(&self, path: &FsPath) -> FsResult<FileMetadata>;
fn exists(&self, path: &FsPath) -> FsResult<bool>;
fn list(
&self,
path: &FsPath,
options: &ListOptions,
) -> FsResult<Box<dyn DirectoryStream>>;
fn open_reader(
&self,
path: &FsPath,
options: &ReadOptions,
) -> FsResult<Box<dyn FileReader>>;
fn open_writer(
&self,
path: &FsPath,
options: &WriteOptions,
) -> FsResult<Box<dyn FileWriter>>;
fn create_dir(
&self,
path: &FsPath,
options: &CreateDirOptions,
) -> FsResult<()>;
fn delete(&self, path: &FsPath, options: &DeleteOptions) -> FsResult<()>;
fn rename(
&self,
from: &FsPath,
to: &FsPath,
options: &RenameOptions,
) -> FsResult<()>;
fn copy(
&self,
from: &FsPath,
to: &FsPath,
options: &CopyOptions,
) -> FsResult<CopyOutcome>;
// Provided methods
fn capabilities(&self) -> FileSystemCapabilities { ... }
fn temp_resource_factory(&self) -> &dyn TempResourceFactory { ... }
}Expand description
Provider-neutral filesystem interface.
Required Methods§
Sourcefn metadata(&self) -> FileSystemMetadata
fn metadata(&self) -> FileSystemMetadata
Sourcefn path_metadata(&self, path: &FsPath) -> FsResult<FileMetadata>
fn path_metadata(&self, path: &FsPath) -> FsResult<FileMetadata>
Reads metadata for a path.
§Parameters
path: Resource path.
§Returns
Resource metadata.
§Errors
Returns crate::FsError when metadata cannot be read.
Sourcefn exists(&self, path: &FsPath) -> FsResult<bool>
fn exists(&self, path: &FsPath) -> FsResult<bool>
Checks whether a path exists.
§Parameters
path: Resource path.
§Returns
true when the resource exists.
§Errors
Returns crate::FsError for errors other than confirmed absence.
Sourcefn list(
&self,
path: &FsPath,
options: &ListOptions,
) -> FsResult<Box<dyn DirectoryStream>>
fn list( &self, path: &FsPath, options: &ListOptions, ) -> FsResult<Box<dyn DirectoryStream>>
Lists a directory, prefix, or collection.
§Parameters
path: Container path.options: Listing options.
§Returns
Directory stream.
§Errors
Returns crate::FsError when listing cannot be started.
Sourcefn open_reader(
&self,
path: &FsPath,
options: &ReadOptions,
) -> FsResult<Box<dyn FileReader>>
fn open_reader( &self, path: &FsPath, options: &ReadOptions, ) -> FsResult<Box<dyn FileReader>>
Opens a readable resource.
§Parameters
path: Resource path.options: Read options.
§Returns
Reader handle.
§Errors
Returns crate::FsError when the reader cannot be opened.
Sourcefn open_writer(
&self,
path: &FsPath,
options: &WriteOptions,
) -> FsResult<Box<dyn FileWriter>>
fn open_writer( &self, path: &FsPath, options: &WriteOptions, ) -> FsResult<Box<dyn FileWriter>>
Opens a writable resource.
§Parameters
path: Resource path.options: Write options.
§Returns
Writer handle.
§Errors
Returns crate::FsError when the writer cannot be opened.
Sourcefn create_dir(&self, path: &FsPath, options: &CreateDirOptions) -> FsResult<()>
fn create_dir(&self, path: &FsPath, options: &CreateDirOptions) -> FsResult<()>
Creates a directory, collection, or equivalent container.
§Parameters
path: Container path.options: Creation options.
§Errors
Returns crate::FsError when the container cannot be created.
Sourcefn delete(&self, path: &FsPath, options: &DeleteOptions) -> FsResult<()>
fn delete(&self, path: &FsPath, options: &DeleteOptions) -> FsResult<()>
Deletes a resource.
§Parameters
path: Resource path.options: Delete options.
§Errors
Returns crate::FsError when deletion fails.
Sourcefn rename(
&self,
from: &FsPath,
to: &FsPath,
options: &RenameOptions,
) -> FsResult<()>
fn rename( &self, from: &FsPath, to: &FsPath, options: &RenameOptions, ) -> FsResult<()>
Renames or moves a resource within this filesystem.
§Parameters
from: Source path.to: Destination path.options: Rename options.
§Errors
Returns crate::FsError when rename fails.
Sourcefn copy(
&self,
from: &FsPath,
to: &FsPath,
options: &CopyOptions,
) -> FsResult<CopyOutcome>
fn copy( &self, from: &FsPath, to: &FsPath, options: &CopyOptions, ) -> FsResult<CopyOutcome>
Copies a resource within this filesystem.
§Parameters
from: Source path.to: Destination path.options: Copy options.
§Returns
Copy outcome.
§Errors
Returns crate::FsError when copy fails.
Provided Methods§
Sourcefn capabilities(&self) -> FileSystemCapabilities
fn capabilities(&self) -> FileSystemCapabilities
Sourcefn temp_resource_factory(&self) -> &dyn TempResourceFactory
fn temp_resource_factory(&self) -> &dyn TempResourceFactory
Gets the temporary resource factory for this filesystem instance.
If the specified filesystem does not provide its specific implementation,
a default ManagedTempResourceFactory will be returned.
§Returns
Factory used to create temporary files and directories owned by this filesystem instance.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".