diff options
author | Florian Klink <flokli@flokli.de> | 2024-10-18T12·41+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-10-18T21·45+0000 |
commit | 9c223450199b466c535f2b715ad68f1f295fa7dc (patch) | |
tree | 18834efec0cefeb1a6362095e6b2b4e7e094cfe1 /tvix/store/src/pathinfoservice/mod.rs | |
parent | 47efebfc6fcbce028c0f3df5f9d584119e8e8ffe (diff) |
refactor(tvix/[ca]store): use auto_impl r/8835
This implements BS, DS, PS for Box'ed or Arc'ed variants of it with less code, and less potential to accidentially forget to proxy default trait methods for blanked impls, as fixed in cl/12658. Change-Id: If2cdbb563a73792038ebe7bff45d6f880214855b Reviewed-on: https://cl.tvl.fyi/c/depot/+/12661 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: edef <edef@edef.eu>
Diffstat (limited to 'tvix/store/src/pathinfoservice/mod.rs')
-rw-r--r-- | tvix/store/src/pathinfoservice/mod.rs | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/tvix/store/src/pathinfoservice/mod.rs b/tvix/store/src/pathinfoservice/mod.rs index a0c48f5cc9d5..d31a1e652e3b 100644 --- a/tvix/store/src/pathinfoservice/mod.rs +++ b/tvix/store/src/pathinfoservice/mod.rs @@ -13,6 +13,7 @@ mod fs; #[cfg(test)] mod tests; +use auto_impl::auto_impl; use futures::stream::BoxStream; use tonic::async_trait; use tvix_castore::composition::{Registry, ServiceBuilder}; @@ -45,6 +46,7 @@ pub use self::fs::make_fs; /// The base trait all PathInfo services need to implement. #[async_trait] +#[auto_impl(&, &mut, Arc, Box)] pub trait PathInfoService: Send + Sync { /// Retrieve a PathInfo message by the output digest. async fn get(&self, digest: [u8; 20]) -> Result<Option<PathInfo>, Error>; @@ -69,28 +71,6 @@ pub trait PathInfoService: Send + Sync { } } -#[async_trait] -impl<A> PathInfoService for A -where - A: AsRef<dyn PathInfoService> + Send + Sync + 'static, -{ - 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 - } - - fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>> { - self.as_ref().list() - } - - fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>> { - self.as_ref().nar_calculation_service() - } -} - /// Registers the builtin PathInfoService implementations with the registry pub(crate) fn register_pathinfo_services(reg: &mut Registry) { reg.register::<Box<dyn ServiceBuilder<Output = dyn PathInfoService>>, CachePathInfoServiceConfig>("cache"); |