Skip to main content

BackupFolder

Trait BackupFolder 

Source
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§

Source

fn shown(&self, path: &str) -> PathBuf

A path in the folder, as messages show it.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn remove(&self, file: &str) -> Result<()>

Deletes a file, if it is there.

§Errors

Returns an error if it is there and cannot be deleted.

Source

fn free(&self) -> Result<u64>

How many bytes its drive has free.

§Errors

Returns an error if the system does not say.

Source

fn drive(&self) -> BackupDrive

What its drive is, as copies count it.

Provided Methods§

Source

fn exists(&self, file: &str) -> bool

Whether a file is there.

Source

fn sync_folder(&self, _folder: &str)

Saves a folder’s entries to the disk, where the system allows it.

Source

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".

Implementors§