Trait tvix_castore::blobservice::BlobService

source ·
pub trait BlobService: Send + Sync {
    // Required methods
    fn has<'life0, 'life1, 'async_trait>(
        &'life0 self,
        digest: &'life1 B3Digest,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn open_read<'life0, 'life1, 'async_trait>(
        &'life0 self,
        digest: &'life1 B3Digest,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn BlobReader>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn open_write<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Box<dyn BlobWriter>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn chunks<'life0, 'life1, 'async_trait>(
        &'life0 self,
        digest: &'life1 B3Digest,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ChunkMeta>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

The base trait all BlobService services need to implement. It provides functions to check whether a given blob exists, a way to read (and seek) a blob, and a method to create a blobwriter handle, which will implement a writer interface, and also provides a close funtion, to finalize a blob and get its digest.

Required Methods§

source

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

Check if the service has the blob, by its content hash. On implementations returning chunks, this must also work for chunks.

source

fn open_read<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 B3Digest, ) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn BlobReader>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Request a blob from the store, by its content hash. On implementations returning chunks, this must also work for chunks.

source

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

Insert a new blob into the store. Returns a BlobWriter, which implements tokio::io::AsyncWrite and a BlobWriter::close to finalize the blob and get its digest.

Provided Methods§

source

fn chunks<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 B3Digest, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ChunkMeta>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Return a list of chunks for a given blob. There’s a distinction between returning Ok(None) and Ok(Some(vec![])). The former return value is sent in case the blob is not present at all, while the second one is sent in case there’s no more granular chunks (or the backend does not support chunking). A default implementation checking for existence and then returning it does not have more granular chunks available is provided.

Implementations on Foreign Types§

source§

impl<'a, T: 'a + BlobService + ?Sized> BlobService for &'a T
where &'a T: Send + Sync,

source§

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

source§

fn open_read<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 B3Digest, ) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn BlobReader>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

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

source§

fn chunks<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 B3Digest, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ChunkMeta>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

impl<'a, T: 'a + BlobService + ?Sized> BlobService for &'a mut T
where &'a mut T: Send + Sync,

source§

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

source§

fn open_read<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 B3Digest, ) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn BlobReader>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

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

source§

fn chunks<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 B3Digest, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ChunkMeta>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

impl<T: BlobService + ?Sized> BlobService for Box<T>
where Box<T>: Send + Sync,

source§

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

source§

fn open_read<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 B3Digest, ) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn BlobReader>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

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

source§

fn chunks<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 B3Digest, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ChunkMeta>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

impl<T: BlobService + ?Sized> BlobService for Arc<T>
where Arc<T>: Send + Sync,

source§

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

source§

fn open_read<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 B3Digest, ) -> Pin<Box<dyn Future<Output = Result<Option<Box<dyn BlobReader>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

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

source§

fn chunks<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 B3Digest, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ChunkMeta>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§

source§

impl BlobService for MemoryBlobService

source§

impl BlobService for ObjectStoreBlobService

source§

impl<BL, BR> BlobService for CombinedBlobService<BL, BR>
where BL: AsRef<dyn BlobService> + Clone + Send + Sync + 'static, BR: AsRef<dyn BlobService> + Clone + Send + Sync + 'static,

source§

impl<T> BlobService for GRPCBlobService<T>
where T: GrpcService<BoxBody> + Send + Sync + Clone + 'static, T::ResponseBody: Body<Data = Bytes> + Send + 'static, <T::ResponseBody as Body>::Error: Into<StdError> + Send, T::Future: Send,