Skip to main content
← dvs documentation Rust API reference

Backend

Trait Backend 

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

Source

fn is_initialized(&self) -> Result<bool>

Check whether the backend has already been initialized.

Source

fn init(&self) -> Result<()>

Initialize the backend storage (create directories, set permissions, etc.)

Source

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.

Source

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.

Source

fn exists(&self, hash: &Hashes) -> Result<bool>

Check if the file exists in the backend

Source

fn remove(&self, hash: &Hashes) -> Result<()>

Remove content by hash (for rollback). Best-effort, may silently fail.

Source

fn log_audit(&self, entry: &AuditEntry) -> Result<()>

Log an audit entry to the backend’s audit log.

Source

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

Implementors§