pub trait BackupFolder: Send + Sync {
// Required methods
fn shown(&self, path: &str) -> PathBuf;
fn list(&self, folder: &str) -> Result<Vec<(String, Option<u64>)>>;
fn open(&self, file: &str) -> Result<File>;
fn create(&self, file: &str) -> Result<File>;
fn open_lock(&self, file: &str) -> Result<File>;
fn put(&self, file: &str, folder: &str) -> Result<()>;
fn remove(&self, file: &str) -> Result<()>;
fn free(&self) -> Result<u64>;
fn drive(&self) -> BackupDrive;
// Provided methods
fn exists(&self, file: &str) -> bool { ... }
fn sync_folder(&self, _folder: &str) { ... }
fn unjournaled(&self) -> bool { ... }
}Expand description
A backup’s folder, as the engine reads and writes it: files and folders under it, named by
their paths from it, with / between names, such as spaces/<space>/<digest>.pack. On
computers, the file system stands behind it; on Android, the folder that the system’s
picker gives, which gives files but no paths, never replaces a file in one step, and
moves a file only under its own name (technical design: backups).
Required Methods§
Sourcefn list(&self, folder: &str) -> Result<Vec<(String, Option<u64>)>>
fn list(&self, folder: &str) -> Result<Vec<(String, Option<u64>)>>
The entries of a folder in it, "" for the folder itself: each one’s name, with a
file’s size, or None for a folder.
§Errors
Returns an error of the kind io::ErrorKind::NotFound if there is no such folder.
Sourcefn open(&self, file: &str) -> Result<File>
fn open(&self, file: &str) -> Result<File>
Opens a file to read.
§Errors
Returns an error of the kind io::ErrorKind::NotFound if there is no such file.
Sourcefn create(&self, file: &str) -> Result<File>
fn create(&self, file: &str) -> Result<File>
Makes a new file to write, and the folders it is in.
§Errors
Returns an error if it cannot be made, or one is there already.
Sourcefn open_lock(&self, file: &str) -> Result<File>
fn open_lock(&self, file: &str) -> Result<File>
Opens a file to read and write, made if there is none: the one that an update locks.
§Errors
Returns an error if it cannot be opened or made.
Sourcefn put(&self, file: &str, folder: &str) -> Result<()>
fn put(&self, file: &str, folder: &str) -> Result<()>
Moves a file into another folder, made if there is none, under the same name, in place of a file of that name there: in one step where the system can, and otherwise by deleting that one first.
§Errors
Returns an error if it cannot be moved.
Sourcefn drive(&self) -> BackupDrive
fn drive(&self) -> BackupDrive
What its drive is, as copies count it.
Provided Methods§
Sourcefn sync_folder(&self, _folder: &str)
fn sync_folder(&self, _folder: &str)
Saves a folder’s entries to the disk, where the system allows it.
Sourcefn unjournaled(&self) -> bool
fn unjournaled(&self) -> bool
Whether its file system keeps no journal, as BackupDrive::unjournaled says, which
an update asks before it needs the rest.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".