feat(tvix/store): AsRef<dyn PathInfoService> impl PathInfoService
Change-Id: I7fc06ae97a50d04b8c36292b3457c112242a7a70 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11270 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: Connor Brewster <cbrewster@hey.com>
This commit is contained in:
parent
ac88c52be3
commit
bfc5b209a6
1 changed files with 25 additions and 0 deletions
|
@ -50,3 +50,28 @@ pub trait PathInfoService: Send + Sync {
|
||||||
/// [async_trait] generates, but for streams instead of futures.
|
/// [async_trait] generates, but for streams instead of futures.
|
||||||
fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>>;
|
fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl<A> PathInfoService for A
|
||||||
|
where
|
||||||
|
A: AsRef<dyn PathInfoService> + Send + Sync,
|
||||||
|
{
|
||||||
|
async fn get(&self, digest: [u8; 20]) -> Result<Option<PathInfo>, Error> {
|
||||||
|
self.as_ref().get(digest).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn put(&self, path_info: PathInfo) -> Result<PathInfo, Error> {
|
||||||
|
self.as_ref().put(path_info).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn calculate_nar(
|
||||||
|
&self,
|
||||||
|
root_node: &castorepb::node::Node,
|
||||||
|
) -> Result<(u64, [u8; 32]), Error> {
|
||||||
|
self.as_ref().calculate_nar(root_node).await
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>> {
|
||||||
|
self.as_ref().list()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue