refactor(tvix/castore): make directorysvc more generic
This works on Box<dyn DirectoryService> too. Change-Id: Ib869f0f4d963ef4dbaeab22db03ff6afb71ede04 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10513 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
This commit is contained in:
parent
2c2fdfedc6
commit
54fe97e725
1 changed files with 7 additions and 4 deletions
|
@ -1,16 +1,19 @@
|
||||||
use super::DirectoryService;
|
use super::DirectoryService;
|
||||||
use crate::{proto::NamedNode, B3Digest, Error};
|
use crate::{proto::NamedNode, B3Digest, Error};
|
||||||
use std::{os::unix::ffi::OsStrExt, sync::Arc};
|
use std::{ops::Deref, os::unix::ffi::OsStrExt};
|
||||||
use tracing::{instrument, warn};
|
use tracing::{instrument, warn};
|
||||||
|
|
||||||
/// This descends from a (root) node to the given (sub)path, returning the Node
|
/// This descends from a (root) node to the given (sub)path, returning the Node
|
||||||
/// at that path, or none, if there's nothing at that path.
|
/// at that path, or none, if there's nothing at that path.
|
||||||
#[instrument(skip(directory_service))]
|
#[instrument(skip(directory_service))]
|
||||||
pub async fn descend_to(
|
pub async fn descend_to<DS>(
|
||||||
directory_service: Arc<dyn DirectoryService>,
|
directory_service: DS,
|
||||||
root_node: crate::proto::node::Node,
|
root_node: crate::proto::node::Node,
|
||||||
path: &std::path::Path,
|
path: &std::path::Path,
|
||||||
) -> Result<Option<crate::proto::node::Node>, Error> {
|
) -> Result<Option<crate::proto::node::Node>, Error>
|
||||||
|
where
|
||||||
|
DS: Deref<Target = dyn DirectoryService>,
|
||||||
|
{
|
||||||
// strip a possible `/` prefix from the path.
|
// strip a possible `/` prefix from the path.
|
||||||
let path = {
|
let path = {
|
||||||
if path.starts_with("/") {
|
if path.starts_with("/") {
|
||||||
|
|
Loading…
Add table
Reference in a new issue