about summary refs log tree commit diff
path: root/tvix/store/src/store_io.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-05-25T14·52+0300
committerclbot <clbot@tvl.fyi>2023-06-12T10·15+0000
commit27ff98000b0cdf0ed30eb8837c7d44cd3e79d32f (patch)
tree09fcb40135001d35717ce176d8b473f5e634bdcf /tvix/store/src/store_io.rs
parent5139cc45c2ce1736509f3f0ebf68a71c10ace939 (diff)
feat(tvix/store): eliminate generics in BlobStore r/6269
To construct various stores at runtime, we need to eliminate associated
types from the BlobService trait, and return Box<dyn …> instead of
specific types.

This also means we can't consume self in the close() method, so
everything we write to is put in an Option<>, and during the first close
we take from there.

Change-Id: Ia523b6ab2f2a5276f51cb5d17e81a5925bce69b6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8647
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/store/src/store_io.rs')
-rw-r--r--tvix/store/src/store_io.rs19
1 files changed, 7 insertions, 12 deletions
diff --git a/tvix/store/src/store_io.rs b/tvix/store/src/store_io.rs
index fb46204e505f..a2967c06ff98 100644
--- a/tvix/store/src/store_io.rs
+++ b/tvix/store/src/store_io.rs
@@ -29,24 +29,19 @@ use crate::{
 /// This is to both cover cases of syntactically valid store paths, that exist
 /// on the filesystem (still managed by Nix), as well as being able to read
 /// files outside store paths.
-pub struct TvixStoreIO<
-    BS: BlobService,
-    DS: DirectoryService,
-    PS: PathInfoService,
-    NCS: NARCalculationService,
-> {
-    blob_service: BS,
+pub struct TvixStoreIO<DS: DirectoryService, PS: PathInfoService, NCS: NARCalculationService> {
+    blob_service: Box<dyn BlobService>,
     directory_service: DS,
     path_info_service: PS,
     nar_calculation_service: NCS,
     std_io: StdIO,
 }
 
-impl<BS: BlobService, DS: DirectoryService, PS: PathInfoService, NCS: NARCalculationService>
-    TvixStoreIO<BS, DS, PS, NCS>
+impl<DS: DirectoryService, PS: PathInfoService, NCS: NARCalculationService>
+    TvixStoreIO<DS, PS, NCS>
 {
     pub fn new(
-        blob_service: BS,
+        blob_service: Box<dyn BlobService>,
         directory_service: DS,
         path_info_service: PS,
         nar_calculation_service: NCS,
@@ -183,8 +178,8 @@ fn calculate_nar_based_store_path(nar_sha256_digest: &[u8; 32], name: &str) -> S
     build_regular_ca_path(name, &nar_hash_with_mode, Vec::<String>::new(), false).unwrap()
 }
 
-impl<BS: BlobService, DS: DirectoryService, PS: PathInfoService, NCS: NARCalculationService> EvalIO
-    for TvixStoreIO<BS, DS, PS, NCS>
+impl<DS: DirectoryService, PS: PathInfoService, NCS: NARCalculationService> EvalIO
+    for TvixStoreIO<DS, PS, NCS>
 {
     #[instrument(skip(self), ret, err)]
     fn path_exists(&self, path: &Path) -> Result<bool, io::Error> {