ContentStorage

Trait ContentStorage 

Source
pub trait ContentStorage: Send + Sync {
    // Required methods
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn content_location(&self, digest: &AnyHash) -> Option<PathBuf>;
    fn load_content<'life0, 'life1, 'async_trait>(
        &'life0 self,
        digest: &'life1 AnyHash,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Pin<Box<dyn Stream<Item = Result<Bytes>> + Send + Sync>>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn store_content<'life0, 'life1, 'async_trait>(
        &'life0 self,
        stream: Pin<Box<dyn Stream<Item = Result<Bytes>> + Send + Sync>>,
        expected_digest: Option<&'life1 AnyHash>,
    ) -> Pin<Box<dyn Future<Output = Result<AnyHash>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Trait for content storage implementations.

Content storage data must be synchronized if shared between multiple threads and processes.

Required Methods§

Source

fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear content local data

Source

fn content_location(&self, digest: &AnyHash) -> Option<PathBuf>

Gets the location of the content associated with the given digest if it exists as a file on disk.

Returns None if the content is not present on disk.

Source

fn load_content<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 AnyHash, ) -> Pin<Box<dyn Future<Output = Result<Option<Pin<Box<dyn Stream<Item = Result<Bytes>> + Send + Sync>>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads the content associated with the given digest as a stream.

If the content is not found, Ok(None) is returned.

Source

fn store_content<'life0, 'life1, 'async_trait>( &'life0 self, stream: Pin<Box<dyn Stream<Item = Result<Bytes>> + Send + Sync>>, expected_digest: Option<&'life1 AnyHash>, ) -> Pin<Box<dyn Future<Output = Result<AnyHash>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stores the given stream as content.

If expected_digest is Some, the storage will verify that the written content matches the given digest. If the digests do not match, an error is returned.

Returns the hash of the written content.

Implementors§