Skip to main content

StorageBackend

Trait StorageBackend 

pub trait StorageBackend: Send + Sync {
    // Required methods
    fn clean_file<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<String, XetError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn is_pointer(&self, content: &str) -> bool;
    fn clean_bytes<'life0, 'life1, 'async_trait>(
        &'life0 self,
        data: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<String, XetError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn smudge_file<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        pointer: &'life1 str,
        output_path: &'life2 Path,
    ) -> Pin<Box<dyn Future<Output = Result<(), XetError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn smudge_bytes<'life0, 'life1, 'async_trait>(
        &'life0 self,
        pointer: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, XetError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn smudge_from_hash<'life0, 'life1, 'async_trait>(
        &'life0 self,
        hash: &'life1 DataHash,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, XetError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn smudge_from_hash_to_file<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        hash: &'life1 DataHash,
        output_path: &'life2 Path,
    ) -> Pin<Box<dyn Future<Output = Result<(), XetError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
}
Expand description

Storage backend trait for XET filter operations.

This trait abstracts the XET content-addressed storage operations, allowing for clean (upload) and smudge (download) of file content.

All methods are async and designed for use with the XET data client. Implementations must be Send + Sync for use across threads.

Required Methods§

fn clean_file<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<String, XetError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Upload a file to XET CAS and return a JSON pointer string.

The returned pointer contains metadata (size, merkle hash) needed to retrieve the content later via smudge_bytes or smudge_file.

fn is_pointer(&self, content: &str) -> bool

Check if a string is a valid XET pointer.

Returns true if the content can be parsed as a valid XET pointer JSON.

fn clean_bytes<'life0, 'life1, 'async_trait>( &'life0 self, data: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<String, XetError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Upload data from memory to XET CAS and return a JSON pointer string.

This is more efficient than clean_file when data is already in memory.

fn smudge_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, pointer: &'life1 str, output_path: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<(), XetError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Download content from a pointer directly to a file.

This is more efficient than smudge_bytes when the destination is a file, as it avoids intermediate memory allocation.

fn smudge_bytes<'life0, 'life1, 'async_trait>( &'life0 self, pointer: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, XetError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Download content from a pointer to an in-memory buffer.

Use this for small files or when the content needs processing. For large files, prefer smudge_file to write directly to disk.

fn smudge_from_hash<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 DataHash, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, XetError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Download content by merkle hash to an in-memory buffer.

This is useful for LFS pointer resolution where you have a SHA256 hash instead of a full XET pointer JSON string.

fn smudge_from_hash_to_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, hash: &'life1 DataHash, output_path: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<(), XetError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Download content by merkle hash directly to a file.

Combines the efficiency of direct file writes with hash-based lookups for LFS pointer resolution.

Implementors§