Struct rzbackup::ZBackupRepository
[−]
[src]
pub struct ZBackupRepository { /* fields omitted */ }
This is the main struct which implements the ZBackup restore functionality. It is multi-threaded, using a cpu pool internally, and it is fully thread safe.
Methods
impl Repository
[src]
fn default_config() -> RepositoryConfig
Provides a default configuration for a Repository. This may be useful for some users of the library, although normally a custom configuration will be a better option.
fn open<RepositoryPath: AsRef<Path>, PasswordFilePath: AsRef<Path>>(
output: &Output,
repository_config: RepositoryConfig,
repository_path: RepositoryPath,
password_file_path: Option<PasswordFilePath>
) -> Result<Repository, String>
output: &Output,
repository_config: RepositoryConfig,
repository_path: RepositoryPath,
password_file_path: Option<PasswordFilePath>
) -> Result<Repository, String>
Constructs a new Repository from a configuration and a path, and an optional password file path.
This will read the repositories info file, and decrypt the encryption key using the password, if provided.
fn load_indexes(&self, output: &Output) -> Result<(), String>
Load the index files. This is not done automatically, but it will be done lazily when they are first needed. This function also implements a lazy loading pattern, and so no index files will be reloaded if it is called more than ones.
Apart from being used internally, this function is designed to be used by library users who want to eagerly load the indexes so that restore operations can begin more quickly. This would also allow errors when reading the index files to be caught more quickly and deterministically.
fn reload_indexes(&self, output: &Output) -> Result<(), String>
Reload the index files. This forces the indexes to be reloaded, even if they have already been loaded. This should be called if new backups have been added to an already-open repository.
fn read_and_expand_backup(
&self,
output: &Output,
backup_name: &str
) -> Result<(Vec<u8>, [u8; 32]), String>
&self,
output: &Output,
backup_name: &str
) -> Result<(Vec<u8>, [u8; 32]), String>
This will load a backup entirely into memory. The use of this function should probably be discouraged for most use cases, since backups could be extremely large.
fn restore(
&self,
output: &Output,
backup_name: &str,
target: &mut Write
) -> Result<(), String>
&self,
output: &Output,
backup_name: &str,
target: &mut Write
) -> Result<(), String>
This function will restore a named backup, writing it to the provided
implementation of the Write
trait.
fn get_chunk(&self, chunk_id: ChunkId) -> Result<ChunkData, String>
This will load a single chunk from the repository. It can be used to
create advanced behaviours, and is used, for example, by the
RandomAccess
struct.
fn get_chunk_async(&self, chunk_id: ChunkId) -> BoxFuture<ChunkData, String>
This will load a single chunk from the repository, returning immediately with a future which can later be waited for. The chunk will be loaded in the background using the cpu pool.
fn get_chunk_async_async(
&self,
chunk_id: ChunkId
) -> BoxFuture<BoxFuture<ChunkData, String>, String>
&self,
chunk_id: ChunkId
) -> BoxFuture<BoxFuture<ChunkData, String>, String>
This will load a single chunk from the repository, returning immediately with a future which will complete immediately if the chunk is in cache, with a future which will complete immediately with the chunk data.
If the chunk is not in cache, the returned future will wait until there is an available thread to start loading the bundle containing the chunk's data. It will then complete with a future which will in turn complete when the bundle has been loaded.
This double-asynchronicity allows consumers to efficiently use all available threads while blocking when none are available. This should significantly reduce worst-case memory usage.
fn get_index_entry(&self, chunk_id: ChunkId) -> Result<IndexEntry, String>
This will load a single index entry from the repository. It returns this
as a MasterIndexEntry
, which includes the index entry and the header
from the index file, since both are generally needed to do anything
useful.
It can be used to create advanced behaviours, and is used, for example,
by the RandomAccess
struct.
fn has_chunk(&self, chunk_id: &ChunkId) -> bool
Returns true if a chunk is present in the loaded indexes
fn open_backup(
&self,
output: &Output,
backup_name: &str
) -> Result<RandomAccess, String>
&self,
output: &Output,
backup_name: &str
) -> Result<RandomAccess, String>
This is a convenience method to construct a RandomAccess
struct. It
simply calls the RandomAccess::new
constructor.
fn close(self, output: &Output)
This method closes the repository, removing all temporary files
fn config(&self) -> &RepositoryConfig
This is an accessor method to access the RepositoryConfig
struct which
was used to construct this Repository
.
fn core(&self) -> &RepositoryCore
This is an accessor method for the RepositoryCore
which holds the most
basic details about a repository
fn path(&self) -> &Path
This is an accessor method to access the repository's path
fn storage_info(&self) -> &DiskStorageInfo
This is an accessor method to access the StorageInfo
protobug struct
which was loaded from the repository's index file.
fn encryption_key(&self) -> Option<EncryptionKey>
This is an accessor method to access the decrypted encryption key which was stored in the repository's info file and decrypted using the provided password.
fn index_path(&self, index_id: IndexId) -> PathBuf
Convenience function to return the filesystem path for an index id.
fn bundle_path(&self, bundle_id: BundleId) -> PathBuf
Convenience function to return the filesystem path for a bundle id.
fn status(&self) -> RepositoryStatus
Trait Implementations
impl Clone for Repository
[src]
fn clone(&self) -> Repository
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more