From bfc5b209a68d8668939bc20b89b9ecd7dd6b6b6d Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 27 Mar 2024 10:23:55 +0100 Subject: feat(tvix/store): AsRef impl PathInfoService Change-Id: I7fc06ae97a50d04b8c36292b3457c112242a7a70 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11270 Tested-by: BuildkiteCI Autosubmit: flokli Reviewed-by: Connor Brewster --- tvix/store/src/pathinfoservice/mod.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tvix/store/src/pathinfoservice') diff --git a/tvix/store/src/pathinfoservice/mod.rs b/tvix/store/src/pathinfoservice/mod.rs index 55ada92b7e88..1f52d20caed7 100644 --- a/tvix/store/src/pathinfoservice/mod.rs +++ b/tvix/store/src/pathinfoservice/mod.rs @@ -50,3 +50,28 @@ pub trait PathInfoService: Send + Sync { /// [async_trait] generates, but for streams instead of futures. fn list(&self) -> BoxStream<'static, Result>; } + +#[async_trait] +impl PathInfoService for A +where + A: AsRef + Send + Sync, +{ + async fn get(&self, digest: [u8; 20]) -> Result, Error> { + self.as_ref().get(digest).await + } + + async fn put(&self, path_info: PathInfo) -> Result { + 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> { + self.as_ref().list() + } +} -- cgit 1.4.1