Skip to main content

AsyncDataCache

Trait AsyncDataCache 

Source
pub trait AsyncDataCache: Send + Sync {
    // Required methods
    fn object_key(&self, hash: &str, algorithm: &str) -> String;
    fn as_any(&self) -> &dyn Any;
    fn object_exists<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        hash: &'life1 str,
        algorithm: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn put_object<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        hash: &'life1 str,
        algorithm: &'life2 str,
        data: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_object<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        hash: &'life1 str,
        algorithm: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn copy_from<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        _source: &'life1 dyn AsyncDataCache,
        _hash: &'life2 str,
        _algorithm: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Result<CopyResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn multipart_part_size(&self) -> usize { ... }
    fn as_multipart(&self) -> Option<&dyn MultipartDataCache> { ... }
    fn as_range_read(&self) -> Option<&dyn RangeReadDataCache> { ... }
    fn copy_object_to_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        hash: &'life1 str,
        algorithm: &'life2 str,
        dest: &'life3 Path,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn write_object_to_file_at_offset<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        hash: &'life1 str,
        algorithm: &'life2 str,
        dest: &'life3 Path,
        offset: u64,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
}
Expand description

Async content-addressed data cache for use in tokio pipelines.

This is the core trait implemented by every async cache backend. Backends that additionally support S3-style multipart upload or byte-range reads implement the companion traits MultipartDataCache and RangeReadDataCache and override as_multipart / as_range_read so callers can discover the extra capability through a trait object.

Required Methods§

Source

fn object_key(&self, hash: &str, algorithm: &str) -> String

Source

fn as_any(&self) -> &dyn Any

Source

fn object_exists<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, hash: &'life1 str, algorithm: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn put_object<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, hash: &'life1 str, algorithm: &'life2 str, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

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

Provided Methods§

Source

fn copy_from<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _source: &'life1 dyn AsyncDataCache, _hash: &'life2 str, _algorithm: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<CopyResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Attempt a server-side copy from another cache. Returns NotSupported by default.

Source

fn multipart_part_size(&self) -> usize

Returns the part size for multipart transfers. Default: 32MB.

Callers use this value as a threshold hint (e.g. whether a file is large enough to warrant multipart upload) before checking whether the backend actually supports multipart via as_multipart.

Source

fn as_multipart(&self) -> Option<&dyn MultipartDataCache>

Returns Some(self) as a MultipartDataCache if the backend supports S3-style multipart upload. Default: None.

Source

fn as_range_read(&self) -> Option<&dyn RangeReadDataCache>

Returns Some(self) as a RangeReadDataCache if the backend supports byte-range reads. Default: None.

Source

fn copy_object_to_file<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, hash: &'life1 str, algorithm: &'life2 str, dest: &'life3 Path, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Copy a cached object directly to a file. The default reads into memory then writes. Filesystem implementations can override for zero-copy (e.g. sendfile).

Source

fn write_object_to_file_at_offset<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, hash: &'life1 str, algorithm: &'life2 str, dest: &'life3 Path, offset: u64, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Write a cached object into an already-open file at a given offset. Default reads into memory then writes. Filesystem can override for efficiency.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§