refactor(tvix/castore/blobservice): use io::Result in trait

For all these calls, the caller has enough context about what it did, so
it should be fine to use io::Result here.

We pretty much only constructed crate::Error::StorageError before
anyways, so this conveys *more* information.

Change-Id: I5cabb3769c9c2314bab926d34dda748fda9d3ccc
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10328
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
Florian Klink 2023-12-12 15:48:01 +02:00 committed by clbot
parent 91456c3520
commit 30d82efa77
7 changed files with 52 additions and 56 deletions

View file

@ -1,7 +1,7 @@
use std::io;
use tonic::async_trait;
use crate::{B3Digest, Error};
use crate::B3Digest;
mod from_addr;
mod grpc;
@ -25,10 +25,10 @@ pub use self::sled::SledBlobService;
#[async_trait]
pub trait BlobService: Send + Sync {
/// Check if the service has the blob, by its content hash.
async fn has(&self, digest: &B3Digest) -> Result<bool, Error>;
async fn has(&self, digest: &B3Digest) -> io::Result<bool>;
/// Request a blob from the store, by its content hash.
async fn open_read(&self, digest: &B3Digest) -> Result<Option<Box<dyn BlobReader>>, Error>;
async fn open_read(&self, digest: &B3Digest) -> io::Result<Option<Box<dyn BlobReader>>>;
/// Insert a new blob into the store. Returns a [BlobWriter], which
/// implements [io::Write] and a [BlobWriter::close].
@ -43,7 +43,7 @@ pub trait BlobWriter: tokio::io::AsyncWrite + Send + Sync + Unpin + 'static {
/// contents written.
///
/// Closing a already-closed BlobWriter is a no-op.
async fn close(&mut self) -> Result<B3Digest, Error>;
async fn close(&mut self) -> io::Result<B3Digest>;
}
/// A [tokio::io::AsyncRead] that also allows seeking.