diff options
Diffstat (limited to 'tvix/castore/src/fs')
-rw-r--r-- | tvix/castore/src/fs/mod.rs | 13 | ||||
-rw-r--r-- | tvix/castore/src/fs/root_nodes.rs | 10 | ||||
-rw-r--r-- | tvix/castore/src/fs/tests.rs | 5 |
3 files changed, 14 insertions, 14 deletions
diff --git a/tvix/castore/src/fs/mod.rs b/tvix/castore/src/fs/mod.rs index 2da072329d34..632dad84cf86 100644 --- a/tvix/castore/src/fs/mod.rs +++ b/tvix/castore/src/fs/mod.rs @@ -23,7 +23,6 @@ use fuse_backend_rs::abi::fuse_abi::stat64; use fuse_backend_rs::api::filesystem::{Context, FileSystem, FsOptions, ROOT_ID}; use futures::StreamExt; use parking_lot::RwLock; -use std::ops::Deref; use std::{ collections::HashMap, io, @@ -101,8 +100,8 @@ pub struct TvixStoreFs<BS, DS, RN> { impl<BS, DS, RN> TvixStoreFs<BS, DS, RN> where - BS: Deref<Target = dyn BlobService> + Clone + Send, - DS: Deref<Target = dyn DirectoryService> + Clone + Send + 'static, + BS: AsRef<dyn BlobService> + Clone + Send, + DS: AsRef<dyn DirectoryService> + Clone + Send + 'static, RN: RootNodes + Clone + 'static, { pub fn new( @@ -157,7 +156,7 @@ where .block_on(self.tokio_handle.spawn({ let directory_service = self.directory_service.clone(); let parent_digest = parent_digest.to_owned(); - async move { directory_service.get(&parent_digest).await } + async move { directory_service.as_ref().get(&parent_digest).await } })) .unwrap()? .ok_or_else(|| { @@ -270,8 +269,8 @@ where impl<BS, DS, RN> FileSystem for TvixStoreFs<BS, DS, RN> where - BS: Deref<Target = dyn BlobService> + Clone + Send + 'static, - DS: Deref<Target = dyn DirectoryService> + Send + Clone + 'static, + BS: AsRef<dyn BlobService> + Clone + Send + 'static, + DS: AsRef<dyn DirectoryService> + Send + Clone + 'static, RN: RootNodes + Clone + 'static, { type Handle = u64; @@ -496,7 +495,7 @@ where let task = self .tokio_handle - .spawn(async move { blob_service.open_read(&blob_digest).await }); + .spawn(async move { blob_service.as_ref().open_read(&blob_digest).await }); let blob_reader = self.tokio_handle.block_on(task).unwrap(); diff --git a/tvix/castore/src/fs/root_nodes.rs b/tvix/castore/src/fs/root_nodes.rs index 312a0b2cdd7e..a603fd1b37d5 100644 --- a/tvix/castore/src/fs/root_nodes.rs +++ b/tvix/castore/src/fs/root_nodes.rs @@ -1,4 +1,4 @@ -use std::{collections::BTreeMap, ops::Deref, pin::Pin}; +use std::{collections::BTreeMap, pin::Pin}; use crate::{proto::node::Node, Error}; use bytes::Bytes; @@ -23,13 +23,15 @@ pub trait RootNodes: Send + Sync { /// the key is the node name. impl<T> RootNodes for T where - T: Deref<Target = BTreeMap<Bytes, Node>> + Send + Sync, + T: AsRef<BTreeMap<Bytes, Node>> + Send + Sync, { async fn get_by_basename(&self, name: &[u8]) -> Result<Option<Node>, Error> { - Ok(self.get(name).cloned()) + Ok(self.as_ref().get(name).cloned()) } fn list(&self) -> Pin<Box<dyn Stream<Item = Result<Node, Error>> + Send + '_>> { - Box::pin(tokio_stream::iter(self.iter().map(|(_, v)| Ok(v.clone())))) + Box::pin(tokio_stream::iter( + self.as_ref().iter().map(|(_, v)| Ok(v.clone())), + )) } } diff --git a/tvix/castore/src/fs/tests.rs b/tvix/castore/src/fs/tests.rs index 5f2916abd44f..2f27c3c1c8e4 100644 --- a/tvix/castore/src/fs/tests.rs +++ b/tvix/castore/src/fs/tests.rs @@ -1,7 +1,6 @@ use std::{ collections::BTreeMap, io::{self, Cursor}, - ops::Deref, os::unix::fs::MetadataExt, path::Path, sync::Arc, @@ -43,8 +42,8 @@ fn do_mount<P: AsRef<Path>, BS, DS>( list_root: bool, ) -> io::Result<FuseDaemon> where - BS: Deref<Target = dyn BlobService> + Send + Sync + Clone + 'static, - DS: Deref<Target = dyn DirectoryService> + Send + Sync + Clone + 'static, + BS: AsRef<dyn BlobService> + Send + Sync + Clone + 'static, + DS: AsRef<dyn DirectoryService> + Send + Sync + Clone + 'static, { let fs = TvixStoreFs::new( blob_service, |