From f5cf6592455d5178e829984c76f2df5037319272 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 23 Mar 2024 23:42:55 +0100 Subject: feat(tvix/castore): AsRef impl BlobService This allows us to use containers around BlobServices as BlobServices too. Change-Id: I3c7feb074f42b4e07c550fb8dfa63cf81d448ab5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11249 Autosubmit: flokli Tested-by: BuildkiteCI Reviewed-by: raitobezarius --- tvix/castore/src/blobservice/mod.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tvix') diff --git a/tvix/castore/src/blobservice/mod.rs b/tvix/castore/src/blobservice/mod.rs index 5eb88a479427..e9cbd190623a 100644 --- a/tvix/castore/src/blobservice/mod.rs +++ b/tvix/castore/src/blobservice/mod.rs @@ -61,6 +61,28 @@ pub trait BlobService: Send + Sync { } } +#[async_trait] +impl BlobService for A +where + A: AsRef + Send + Sync, +{ + async fn has(&self, digest: &B3Digest) -> io::Result { + self.as_ref().has(digest).await + } + + async fn open_read(&self, digest: &B3Digest) -> io::Result>> { + self.as_ref().open_read(digest).await + } + + async fn open_write(&self) -> Box { + self.as_ref().open_write().await + } + + async fn chunks(&self, digest: &B3Digest) -> io::Result>> { + self.as_ref().chunks(digest).await + } +} + /// A [tokio::io::AsyncWrite] that the user needs to close() afterwards for persist. /// On success, it returns the digest of the written blob. #[async_trait] -- cgit 1.4.1