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<Path>>.

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 <flokli@flokli.de>
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2023-12-11 22:11:01 +02:00 committed by clbot
parent 9748543f1c
commit ccaf10b4a6
6 changed files with 10 additions and 11 deletions

View file

@ -2,7 +2,7 @@ use super::{BlobReader, BlobService, BlobWriter};
use crate::{B3Digest, Error};
use std::{
io::{self, Cursor, Write},
path::PathBuf,
path::Path,
task::Poll,
};
use tonic::async_trait;
@ -14,7 +14,7 @@ pub struct SledBlobService {
}
impl SledBlobService {
pub fn new(p: PathBuf) -> Result<Self, sled::Error> {
pub fn new<P: AsRef<Path>>(p: P) -> Result<Self, sled::Error> {
let config = sled::Config::default()
.use_compression(false) // is a required parameter
.path(p);