Trait wildland_corex::dfs::interface::DfsFrontend
source · pub trait DfsFrontend: Send + Sync {
Show 16 methods
// Required methods
fn read_dir(&self, path: String) -> Result<Vec<DirEntry>, DfsFrontendError>;
fn metadata(&self, path: String) -> Result<NodeStat, DfsFrontendError>;
fn remove_file(&self, path: String) -> Result<(), DfsFrontendError>;
fn rename(
&self,
old_path: String,
new_path: String
) -> Result<(), DfsFrontendError>;
fn set_permissions(
&self,
path: String,
permissions: WlPermissions
) -> Result<(), DfsFrontendError>;
fn set_owner(&self, path: String) -> Result<(), DfsFrontendError>;
fn create_dir(&self, path: String) -> Result<(), DfsFrontendError>;
fn remove_dir(
&self,
path: String,
is_recursive: bool
) -> Result<(), DfsFrontendError>;
fn stat_fs(&self, path: String) -> Result<FsStat, DfsFrontendError>;
fn get_receiver(&self) -> Arc<Mutex<dyn EventReceiver>>;
fn mount(&self, storage: &Storage) -> Result<(), DfsFrontendError>;
fn get_space_usage(
&self,
storage: &Storage
) -> Result<SpaceUsage, DfsFrontendError>;
fn is_accessible(&self, storage: &Storage) -> Result<bool, DfsFrontendError>;
fn download(
&self,
path: String,
output: Box<dyn OStream>,
progress_reporter: Box<dyn ProgressReporter>,
abort_flag: &AbortFlag
) -> Result<(), DfsFrontendError>;
fn upload(
&self,
path: String,
input: Box<dyn IStream>,
progress_reporter: Box<dyn ProgressReporter>,
abort_flag: &AbortFlag,
creation_time: Option<UnixTimestamp>
) -> Result<(), DfsFrontendError>;
fn get_path(&self, identifier: String) -> Result<String, DfsFrontendError>;
}
Expand description
Interface that DFS exposes towards filesystem-like frontend providers
DFS methods may return error that are not related with particular operation but rather with wildland system in general. Those errors could be:
PathResolutionError
- happens when path resolving failed, e.g. due to the catlib error.StorageNotResponsive
- happens when none of storages that operation involves returns an answer.Generic
- unanticipated errors.
Required Methods§
sourcefn read_dir(&self, path: String) -> Result<Vec<DirEntry>, DfsFrontendError>
fn read_dir(&self, path: String) -> Result<Vec<DirEntry>, DfsFrontendError>
Returns vector of entries found under the provided path. It may merge entries from multiple containers.
Errors:
NotADirectory
- for paths that don’t represent directoriesNoSuchPath
- requested path does not exist
sourcefn remove_file(&self, path: String) -> Result<(), DfsFrontendError>
fn remove_file(&self, path: String) -> Result<(), DfsFrontendError>
Removes a file
Errors:
NoSuchPath
- requested path does not existNotAFile
- provided path represents a node that is not a file
sourcefn rename(
&self,
old_path: String,
new_path: String
) -> Result<(), DfsFrontendError>
fn rename( &self, old_path: String, new_path: String ) -> Result<(), DfsFrontendError>
Rename a file or directory to a new path, if new path does not exist yet. In contrast to POSIX-like rename operation, it returns error in case of new path existence in all cases, so it is up to a caller whether to remove a node under new path or not.
Errors:
NoSuchPath
- source not found
SourceIsParentOfTarget
- new directory would be a subdirectory of itself
MoveBetweenContainers
- new_path
is in different Container than old_path
PathAlreadyExists
- new_path
already exists
sourcefn set_permissions(
&self,
path: String,
permissions: WlPermissions
) -> Result<(), DfsFrontendError>
fn set_permissions( &self, path: String, permissions: WlPermissions ) -> Result<(), DfsFrontendError>
Changes the permissions of the underlying file.
sourcefn set_owner(&self, path: String) -> Result<(), DfsFrontendError>
fn set_owner(&self, path: String) -> Result<(), DfsFrontendError>
Not supported yet - it always returns DfsFrontendError::Generic(_)
sourcefn create_dir(&self, path: String) -> Result<(), DfsFrontendError>
fn create_dir(&self, path: String) -> Result<(), DfsFrontendError>
Creates a new, empty directory at the provided path
Errors:
InvalidParent
- a parent of the given path doesn’t exist.
PathAlreadyExists
- path already exists.
sourcefn remove_dir(
&self,
path: String,
is_recursive: bool
) -> Result<(), DfsFrontendError>
fn remove_dir( &self, path: String, is_recursive: bool ) -> Result<(), DfsFrontendError>
Removes a directory
If is_recursive
is set to true, it will remove all the children of the directory
Errors:
NotADirectory
- path does not represent a directory
NoSuchPath
- no such path exists
DirNotEmpty
- directory is not empty
sourcefn stat_fs(&self, path: String) -> Result<FsStat, DfsFrontendError>
fn stat_fs(&self, path: String) -> Result<FsStat, DfsFrontendError>
Returns information about a mounted filesystem. Path is the pathname of any file within the mounted filesystem.
Errors:
NoSuchPath
- no such path exists
sourcefn get_receiver(&self) -> Arc<Mutex<dyn EventReceiver>>
fn get_receiver(&self) -> Arc<Mutex<dyn EventReceiver>>
Returns receiver that can listen to DFS events.
Events may be split between different EventReceiver
.
sourcefn mount(&self, storage: &Storage) -> Result<(), DfsFrontendError>
fn mount(&self, storage: &Storage) -> Result<(), DfsFrontendError>
Attempts to mount given Storage. This method’s state should not be considered emphemeral.
This functionality may be used during container mount to ensure storage being healthy, before any FS operations are performed.
sourcefn get_space_usage(
&self,
storage: &Storage
) -> Result<SpaceUsage, DfsFrontendError>
fn get_space_usage( &self, storage: &Storage ) -> Result<SpaceUsage, DfsFrontendError>
Returns (used, total) space in bytes
sourcefn is_accessible(&self, storage: &Storage) -> Result<bool, DfsFrontendError>
fn is_accessible(&self, storage: &Storage) -> Result<bool, DfsFrontendError>
Checks whether the Storage is accessible
sourcefn download(
&self,
path: String,
output: Box<dyn OStream>,
progress_reporter: Box<dyn ProgressReporter>,
abort_flag: &AbortFlag
) -> Result<(), DfsFrontendError>
fn download( &self, path: String, output: Box<dyn OStream>, progress_reporter: Box<dyn ProgressReporter>, abort_flag: &AbortFlag ) -> Result<(), DfsFrontendError>
Downloads a file and writes it to the provided output stream
sourcefn upload(
&self,
path: String,
input: Box<dyn IStream>,
progress_reporter: Box<dyn ProgressReporter>,
abort_flag: &AbortFlag,
creation_time: Option<UnixTimestamp>
) -> Result<(), DfsFrontendError>
fn upload( &self, path: String, input: Box<dyn IStream>, progress_reporter: Box<dyn ProgressReporter>, abort_flag: &AbortFlag, creation_time: Option<UnixTimestamp> ) -> Result<(), DfsFrontendError>
Reads a file from the provided input stream and uploads it to the backend
Implementors§
impl DfsFrontend for MockDfsFrontend
Interface that DFS exposes towards filesystem-like frontend providers
DFS methods may return error that are not related with particular operation but rather with wildland system in general. Those errors could be:
PathResolutionError
- happens when path resolving failed, e.g. due to the catlib error.StorageNotResponsive
- happens when none of storages that operation involves returns an answer.Generic
- unanticipated errors.