Struct wildland_dfs::MockDfsFrontend
source · pub struct MockDfsFrontend { /* private fields */ }
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.
Implementations§
source§impl MockDfsFrontend
impl MockDfsFrontend
sourcepub fn checkpoint(&mut self)
pub fn checkpoint(&mut self)
Validate that all current expectations for all methods have been satisfied, and discard them.
sourcepub fn new() -> MockDfsFrontend
pub fn new() -> MockDfsFrontend
Create a new mock object with no expectations.
This method will not be generated if the real struct
already has a new
method. However, it will be
generated if the struct implements a trait with a new
method. The trait’s new
method can still be called
like <MockX as TraitY>::new
source§impl MockDfsFrontend
impl MockDfsFrontend
sourcepub fn expect_read_dir(&mut self) -> &mut Expectation
pub fn expect_read_dir(&mut self) -> &mut Expectation
Create an Expectation
for mocking the read_dir
method
sourcepub fn expect_metadata(&mut self) -> &mut Expectation
pub fn expect_metadata(&mut self) -> &mut Expectation
Create an Expectation
for mocking the metadata
method
sourcepub fn expect_remove_file(&mut self) -> &mut Expectation
pub fn expect_remove_file(&mut self) -> &mut Expectation
Create an Expectation
for mocking the remove_file
method
sourcepub fn expect_rename(&mut self) -> &mut Expectation
pub fn expect_rename(&mut self) -> &mut Expectation
Create an Expectation
for mocking the rename
method
sourcepub fn expect_set_permissions(&mut self) -> &mut Expectation
pub fn expect_set_permissions(&mut self) -> &mut Expectation
Create an Expectation
for mocking the set_permissions
method
sourcepub fn expect_set_owner(&mut self) -> &mut Expectation
pub fn expect_set_owner(&mut self) -> &mut Expectation
Create an Expectation
for mocking the set_owner
method
sourcepub fn expect_create_dir(&mut self) -> &mut Expectation
pub fn expect_create_dir(&mut self) -> &mut Expectation
Create an Expectation
for mocking the create_dir
method
sourcepub fn expect_remove_dir(&mut self) -> &mut Expectation
pub fn expect_remove_dir(&mut self) -> &mut Expectation
Create an Expectation
for mocking the remove_dir
method
sourcepub fn expect_stat_fs(&mut self) -> &mut Expectation
pub fn expect_stat_fs(&mut self) -> &mut Expectation
Create an Expectation
for mocking the stat_fs
method
sourcepub fn expect_get_receiver(&mut self) -> &mut Expectation
pub fn expect_get_receiver(&mut self) -> &mut Expectation
Create an Expectation
for mocking the get_receiver
method
sourcepub fn expect_mount(&mut self) -> &mut Expectation
pub fn expect_mount(&mut self) -> &mut Expectation
Create an Expectation
for mocking the mount
method
sourcepub fn expect_get_space_usage(&mut self) -> &mut Expectation
pub fn expect_get_space_usage(&mut self) -> &mut Expectation
Create an Expectation
for mocking the get_space_usage
method
sourcepub fn expect_is_accessible(&mut self) -> &mut Expectation
pub fn expect_is_accessible(&mut self) -> &mut Expectation
Create an Expectation
for mocking the is_accessible
method
sourcepub fn expect_download(&mut self) -> &mut Expectation
pub fn expect_download(&mut self) -> &mut Expectation
Create an Expectation
for mocking the download
method
sourcepub fn expect_upload(&mut self) -> &mut Expectation
pub fn expect_upload(&mut self) -> &mut Expectation
Create an Expectation
for mocking the upload
method
sourcepub fn expect_get_path(&mut self) -> &mut Expectation
pub fn expect_get_path(&mut self) -> &mut Expectation
Create an Expectation
for mocking the get_path
method
Trait Implementations§
source§impl Debug for MockDfsFrontend
impl Debug for MockDfsFrontend
source§impl Default for MockDfsFrontend
impl Default for MockDfsFrontend
source§fn default() -> MockDfsFrontend
fn default() -> MockDfsFrontend
source§impl DfsFrontend for MockDfsFrontend
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.
source§fn read_dir(
&self,
path: String
) -> Result<Vec<DirEntry, Global>, DfsFrontendError>
fn read_dir( &self, path: String ) -> Result<Vec<DirEntry, Global>, 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
source§fn 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
source§fn 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
source§fn 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.
source§fn set_owner(&self, path: String) -> Result<(), DfsFrontendError>
fn set_owner(&self, path: String) -> Result<(), DfsFrontendError>
Not supported yet - it always returns DfsFrontendError::Generic(_)
source§fn 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.
source§fn 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
source§fn 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
source§fn 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
.
source§fn 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.
source§fn 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
source§fn is_accessible(&self, storage: &Storage) -> Result<bool, DfsFrontendError>
fn is_accessible(&self, storage: &Storage) -> Result<bool, DfsFrontendError>
Checks whether the Storage is accessible
source§fn download(
&self,
path: String,
output: Box<dyn OStream, Global>,
progress_reporter: Box<dyn ProgressReporter, Global>,
abort_flag: &AbortFlag
) -> Result<(), DfsFrontendError>
fn download( &self, path: String, output: Box<dyn OStream, Global>, progress_reporter: Box<dyn ProgressReporter, Global>, abort_flag: &AbortFlag ) -> Result<(), DfsFrontendError>
Downloads a file and writes it to the provided output stream