From 89882ff9b13ff1c25fc64605e3fc87ae7b9ab877 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 9 Jan 2024 11:04:29 +0200 Subject: refactor(tvix): use AsRef instead of Deref MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes some more needs for Arcs. Change-Id: I9a9f4b81641c271de260e9ffa98313a32944d760 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10578 Autosubmit: flokli Tested-by: BuildkiteCI Reviewed-by: raitobezarius --- tvix/glue/src/tvix_store_io.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'tvix/glue/src') diff --git a/tvix/glue/src/tvix_store_io.rs b/tvix/glue/src/tvix_store_io.rs index eba8cee7336f..56e3feb674f3 100644 --- a/tvix/glue/src/tvix_store_io.rs +++ b/tvix/glue/src/tvix_store_io.rs @@ -3,7 +3,6 @@ use nix_compat::store_path::StorePath; use std::{ io, - ops::Deref, path::{Path, PathBuf}, }; use tokio::io::AsyncReadExt; @@ -35,8 +34,8 @@ pub struct TvixStoreIO { impl TvixStoreIO where - DS: Deref, - PS: Deref, + DS: AsRef, + PS: AsRef, { pub fn new( blob_service: BS, @@ -70,7 +69,7 @@ where .tokio_handle .block_on(async { self.path_info_service - .deref() + .as_ref() .get(*store_path.digest()) .await }) @@ -93,7 +92,7 @@ where // with the root_node and sub_path, descend to the node requested. Ok(self.tokio_handle.block_on({ async { - directoryservice::descend_to(self.directory_service.deref(), root_node, sub_path) + directoryservice::descend_to(self.directory_service.as_ref(), root_node, sub_path) .await } })?) @@ -102,9 +101,9 @@ where impl EvalIO for TvixStoreIO where - BS: Deref + Clone, - DS: Deref, - PS: Deref, + BS: AsRef + Clone, + DS: AsRef, + PS: AsRef, { #[instrument(skip(self), ret, err)] fn path_exists(&self, path: &Path) -> io::Result { @@ -154,7 +153,7 @@ where self.tokio_handle.block_on(async { let mut reader = { - let resp = self.blob_service.deref().open_read(&digest).await?; + let resp = self.blob_service.as_ref().open_read(&digest).await?; match resp { Some(blob_reader) => blob_reader, None => { @@ -212,10 +211,9 @@ where ) })?; - if let Some(directory) = self - .tokio_handle - .block_on(async { self.directory_service.deref().get(&digest).await })? - { + if let Some(directory) = self.tokio_handle.block_on(async { + self.directory_service.as_ref().get(&digest).await + })? { let mut children: Vec<(bytes::Bytes, FileType)> = Vec::new(); for node in directory.nodes() { children.push(match node { @@ -263,9 +261,9 @@ where let output_path = self.tokio_handle.block_on(async { tvix_store::utils::import_path( path, - self.blob_service.deref(), - self.directory_service.deref(), - self.path_info_service.deref(), + &self.blob_service, + &self.directory_service, + &self.path_info_service, ) .await })?; -- cgit 1.4.1