From ccaf10b4a6f7768294e41fcb6fbcd768a1e1c143 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 11 Dec 2023 22:11:01 +0200 Subject: refactor(tvix/*store/sled): make ::new() more generic We don't really require the Path to be a PathBuf, we don't even require it to be a Path, we only need it to be AsRef>. This removes some conversion in the from_addr cases, which can just reuse `url.path()` (a `&str`). Change-Id: I38d536dbaf0b44421e41f211a9ad2b13605179e9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10258 Autosubmit: flokli Reviewed-by: raitobezarius Tested-by: BuildkiteCI --- tvix/castore/src/directoryservice/from_addr.rs | 2 +- tvix/castore/src/directoryservice/sled.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tvix/castore/src/directoryservice') diff --git a/tvix/castore/src/directoryservice/from_addr.rs b/tvix/castore/src/directoryservice/from_addr.rs index 8f79fa6158cc..bd1bf584cf29 100644 --- a/tvix/castore/src/directoryservice/from_addr.rs +++ b/tvix/castore/src/directoryservice/from_addr.rs @@ -51,7 +51,7 @@ pub async fn from_addr(uri: &str) -> Result, crate::Er )); } return Ok(Arc::new( - SledDirectoryService::new(url.path().into()) + SledDirectoryService::new(url.path()) .map_err(|e| Error::StorageError(e.to_string()))?, )); } else if url.scheme().starts_with("grpc+") { diff --git a/tvix/castore/src/directoryservice/sled.rs b/tvix/castore/src/directoryservice/sled.rs index 50e58e7e768c..9e6749a753c2 100644 --- a/tvix/castore/src/directoryservice/sled.rs +++ b/tvix/castore/src/directoryservice/sled.rs @@ -3,7 +3,7 @@ use crate::proto::Directory; use crate::{proto, B3Digest, Error}; use futures::Stream; use prost::Message; -use std::path::PathBuf; +use std::path::Path; use std::pin::Pin; use tonic::async_trait; use tracing::{instrument, warn}; @@ -17,7 +17,7 @@ pub struct SledDirectoryService { } impl SledDirectoryService { - pub fn new(p: PathBuf) -> Result { + pub fn new>(p: P) -> Result { let config = sled::Config::default() .use_compression(false) // is a required parameter .path(p); -- cgit 1.4.1