pub trait Backend: Send + Sync {
// Required methods
fn is_initialized(&self) -> Result<bool>;
fn init(&self) -> Result<()>;
fn store(
&self,
hash: &Hashes,
source: &Path,
compression: Compression,
on_bytes: Option<&(dyn Fn(u64) + Send + Sync)>,
) -> Result<u64>;
fn retrieve(
&self,
hash: &Hashes,
target: &Path,
compression: Compression,
on_bytes: Option<&(dyn Fn(u64) + Send + Sync)>,
) -> Result<bool>;
fn exists(&self, hash: &Hashes) -> Result<bool>;
fn remove(&self, hash: &Hashes) -> Result<()>;
fn log_audit(&self, entry: &AuditEntry) -> Result<()>;
fn read_audit_file(&self, files: &[PathBuf]) -> Result<Vec<AuditEntry>>;
}Required Methods§
Sourcefn is_initialized(&self) -> Result<bool>
fn is_initialized(&self) -> Result<bool>
Check whether the backend has already been initialized.
Sourcefn init(&self) -> Result<()>
fn init(&self) -> Result<()>
Initialize the backend storage (create directories, set permissions, etc.)
Sourcefn store(
&self,
hash: &Hashes,
source: &Path,
compression: Compression,
on_bytes: Option<&(dyn Fn(u64) + Send + Sync)>,
) -> Result<u64>
fn store( &self, hash: &Hashes, source: &Path, compression: Compression, on_bytes: Option<&(dyn Fn(u64) + Send + Sync)>, ) -> Result<u64>
Store file to backend by hash, optionally compressing. Returns the stored (compressed) size in bytes.
Sourcefn retrieve(
&self,
hash: &Hashes,
target: &Path,
compression: Compression,
on_bytes: Option<&(dyn Fn(u64) + Send + Sync)>,
) -> Result<bool>
fn retrieve( &self, hash: &Hashes, target: &Path, compression: Compression, on_bytes: Option<&(dyn Fn(u64) + Send + Sync)>, ) -> Result<bool>
Retrieve content by hash to target path, optionally decompressing. Returns true if the file was copied to the target path.
Sourcefn remove(&self, hash: &Hashes) -> Result<()>
fn remove(&self, hash: &Hashes) -> Result<()>
Remove content by hash (for rollback). Best-effort, may silently fail.
Sourcefn log_audit(&self, entry: &AuditEntry) -> Result<()>
fn log_audit(&self, entry: &AuditEntry) -> Result<()>
Log an audit entry to the backend’s audit log.
Sourcefn read_audit_file(&self, files: &[PathBuf]) -> Result<Vec<AuditEntry>>
fn read_audit_file(&self, files: &[PathBuf]) -> Result<Vec<AuditEntry>>
Read the whole audit file, filtered by the given file paths.
If files is empty, return the full audit log
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".