diff options
author | Florian Klink <flokli@flokli.de> | 2023-06-30T14·08+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-07-21T18·52+0000 |
commit | 7613e2e76972554ee2a5ae1397f8b5ca84f4f729 (patch) | |
tree | 366554a7137abbd63971e8c517a0926fcffc56a7 /tvix/store/src/blobservice/mod.rs | |
parent | 42dc18353d99453bc0f83492f9f5bc4796f4cc4c (diff) |
feat(tvix/store/blobservice): implement seek r/6434
For memory and sled, it's trivial, as we already have a Cursor<Vec<u8>>. For gRPC, we simply reject going backwards, and skip n bytes for now. Once the gRPC protocol gets support for offsets and verified streaming, this can be improved. Change-Id: I734066a514aed287ea3db64bfb1680911ac1eeb0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8885 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/store/src/blobservice/mod.rs')
-rw-r--r-- | tvix/store/src/blobservice/mod.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tvix/store/src/blobservice/mod.rs b/tvix/store/src/blobservice/mod.rs index c159ce95a544..027b34eb4c6f 100644 --- a/tvix/store/src/blobservice/mod.rs +++ b/tvix/store/src/blobservice/mod.rs @@ -2,6 +2,7 @@ use std::io; use crate::{B3Digest, Error}; +mod dumb_seeker; mod from_addr; mod grpc; mod memory; @@ -30,7 +31,7 @@ pub trait BlobService: Send + Sync { fn has(&self, digest: &B3Digest) -> Result<bool, Error>; /// Request a blob from the store, by its content hash. - fn open_read(&self, digest: &B3Digest) -> Result<Option<Box<dyn io::Read + Send>>, Error>; + fn open_read(&self, digest: &B3Digest) -> Result<Option<Box<dyn BlobReader>>, Error>; /// Insert a new blob into the store. Returns a [BlobWriter], which /// implements [io::Write] and a [BlobWriter::close]. @@ -46,3 +47,9 @@ pub trait BlobWriter: io::Write + Send + Sync + 'static { /// Closing a already-closed BlobWriter is a no-op. fn close(&mut self) -> Result<B3Digest, Error>; } + +/// A [io::Read] that also allows seeking. +pub trait BlobReader: io::Read + io::Seek + Send + 'static {} + +/// A Cursor<Vec<u8>> can be used as a BlobReader. +impl BlobReader for io::Cursor<Vec<u8>> {} |