diff --git a/crates/spfs/src/storage/blob.rs b/crates/spfs/src/storage/blob.rs index 1cabc80ea..6dc5722ca 100644 --- a/crates/spfs/src/storage/blob.rs +++ b/crates/spfs/src/storage/blob.rs @@ -40,4 +40,5 @@ pub trait BlobStorage: graph::Database + Sync + Send { } } -impl BlobStorage for &T {} +/// Blanket implementation. +impl BlobStorage for T where T: graph::Database + Sync + Send {} diff --git a/crates/spfs/src/storage/fallback/repository.rs b/crates/spfs/src/storage/fallback/repository.rs index 6de26c4a6..7413b8375 100644 --- a/crates/spfs/src/storage/fallback/repository.rs +++ b/crates/spfs/src/storage/fallback/repository.rs @@ -362,10 +362,6 @@ impl TagStorageMut for FallbackProxy { } } -impl BlobStorage for FallbackProxy {} -impl ManifestStorage for FallbackProxy {} -impl LayerStorage for FallbackProxy {} -impl PlatformStorage for FallbackProxy {} impl Address for FallbackProxy { fn address(&self) -> Cow<'_, url::Url> { let config = Config { @@ -383,7 +379,6 @@ impl Address for FallbackProxy { ) } } -impl Repository for FallbackProxy {} impl LocalRepository for FallbackProxy { #[inline] diff --git a/crates/spfs/src/storage/fs/repository.rs b/crates/spfs/src/storage/fs/repository.rs index a90daf4a1..829b36b00 100644 --- a/crates/spfs/src/storage/fs/repository.rs +++ b/crates/spfs/src/storage/fs/repository.rs @@ -258,16 +258,11 @@ impl FsRepository { } } -impl BlobStorage for FsRepository {} -impl ManifestStorage for FsRepository {} -impl LayerStorage for FsRepository {} -impl PlatformStorage for FsRepository {} impl Address for FsRepository { fn address(&self) -> Cow<'_, url::Url> { Cow::Owned(url::Url::from_directory_path(self.root()).unwrap()) } } -impl Repository for FsRepository {} impl std::fmt::Debug for FsRepository { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -535,16 +530,11 @@ impl OpenFsRepository { } } -impl BlobStorage for OpenFsRepository {} -impl ManifestStorage for OpenFsRepository {} -impl LayerStorage for OpenFsRepository {} -impl PlatformStorage for OpenFsRepository {} impl Address for OpenFsRepository { fn address(&self) -> Cow<'_, url::Url> { Cow::Owned(url::Url::from_directory_path(self.root()).unwrap()) } } -impl Repository for OpenFsRepository {} impl std::fmt::Debug for OpenFsRepository { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/crates/spfs/src/storage/handle.rs b/crates/spfs/src/storage/handle.rs index 12c44d5a1..f588f1adb 100644 --- a/crates/spfs/src/storage/handle.rs +++ b/crates/spfs/src/storage/handle.rs @@ -3,7 +3,6 @@ // https://github.com/spkenv/spk use std::borrow::Cow; -use std::collections::HashSet; use std::pin::Pin; use std::sync::Arc; @@ -13,7 +12,6 @@ use relative_path::RelativePath; use spfs_encoding as encoding; use super::prelude::*; -use super::repository::Ref; use super::tag::TagSpecAndTagStream; use super::{RepositoryHandle, TagNamespace, TagNamespaceBuf, TagStorageMut}; use crate::graph::ObjectProto; @@ -42,29 +40,6 @@ impl Address for RepositoryHandle { } } -#[async_trait::async_trait] -impl Repository for RepositoryHandle { - async fn has_ref(&self, reference: &str) -> bool { - each_variant!(self, repo, { repo.has_ref(reference).await }) - } - - async fn resolve_ref(&self, reference: &str) -> Result { - each_variant!(self, repo, { repo.resolve_ref(reference).await }) - } - - async fn read_ref(&self, reference: &str) -> Result { - each_variant!(self, repo, { repo.read_ref(reference).await }) - } - - async fn find_aliases(&self, reference: &str) -> Result> { - each_variant!(self, repo, { repo.find_aliases(reference).await }) - } - - async fn commit_blob(&self, reader: Pin>) -> Result { - each_variant!(self, repo, { repo.commit_blob(reader).await }) - } -} - #[async_trait::async_trait] impl TagStorage for RepositoryHandle { #[inline] @@ -197,11 +172,6 @@ impl PayloadStorage for RepositoryHandle { } } -impl BlobStorage for RepositoryHandle {} -impl ManifestStorage for RepositoryHandle {} -impl LayerStorage for RepositoryHandle {} -impl PlatformStorage for RepositoryHandle {} - #[async_trait::async_trait] impl DatabaseView for RepositoryHandle { async fn has_object(&self, digest: encoding::Digest) -> bool { @@ -256,34 +226,6 @@ impl Address for Arc { } } -#[async_trait::async_trait] -impl Repository for Arc { - /// Return true if this repository contains the given reference. - async fn has_ref(&self, reference: &str) -> bool { - each_variant!(&**self, repo, { repo.has_ref(reference).await }) - } - - /// Resolve a tag or digest string into its absolute digest. - async fn resolve_ref(&self, reference: &str) -> Result { - each_variant!(&**self, repo, { repo.resolve_ref(reference).await }) - } - - /// Read an object of unknown type by tag or digest. - async fn read_ref(&self, reference: &str) -> Result { - each_variant!(&**self, repo, { repo.read_ref(reference).await }) - } - - /// Return the other identifiers that can be used for 'reference'. - async fn find_aliases(&self, reference: &str) -> Result> { - each_variant!(&**self, repo, { repo.find_aliases(reference).await }) - } - - /// Commit the data from 'reader' as a blob in this repository - async fn commit_blob(&self, reader: Pin>) -> Result { - each_variant!(&**self, repo, { repo.commit_blob(reader).await }) - } -} - #[async_trait::async_trait] impl TagStorage for Arc { #[inline] @@ -402,11 +344,6 @@ impl PayloadStorage for Arc { } } -impl BlobStorage for Arc {} -impl ManifestStorage for Arc {} -impl LayerStorage for Arc {} -impl PlatformStorage for Arc {} - #[async_trait::async_trait] impl DatabaseView for Arc { async fn has_object(&self, digest: encoding::Digest) -> bool { diff --git a/crates/spfs/src/storage/layer.rs b/crates/spfs/src/storage/layer.rs index 9ea8df6b3..8103c5177 100644 --- a/crates/spfs/src/storage/layer.rs +++ b/crates/spfs/src/storage/layer.rs @@ -57,4 +57,5 @@ pub trait LayerStorage: graph::Database + Sync + Send { } } -impl LayerStorage for &T {} +/// Blanket implementation. +impl LayerStorage for T where T: graph::Database + Sync + Send {} diff --git a/crates/spfs/src/storage/manifest.rs b/crates/spfs/src/storage/manifest.rs index 253fd3a27..a0647dfa1 100644 --- a/crates/spfs/src/storage/manifest.rs +++ b/crates/spfs/src/storage/manifest.rs @@ -43,4 +43,5 @@ pub trait ManifestStorage: graph::Database + Sync + Send { } } -impl ManifestStorage for &T {} +/// Blanket implementation. +impl ManifestStorage for T where T: graph::Database + Sync + Send {} diff --git a/crates/spfs/src/storage/pinned/repository.rs b/crates/spfs/src/storage/pinned/repository.rs index bf7a33ee4..69747dac1 100644 --- a/crates/spfs/src/storage/pinned/repository.rs +++ b/crates/spfs/src/storage/pinned/repository.rs @@ -150,10 +150,6 @@ where } } -impl BlobStorage for PinnedRepository where T: BlobStorage + 'static {} -impl ManifestStorage for PinnedRepository where T: ManifestStorage + 'static {} -impl LayerStorage for PinnedRepository where T: LayerStorage + 'static {} -impl PlatformStorage for PinnedRepository where T: PlatformStorage + 'static {} impl Address for PinnedRepository where T: Repository + 'static, @@ -165,7 +161,6 @@ where Cow::Owned(base) } } -impl Repository for PinnedRepository where T: Repository + 'static {} impl std::fmt::Debug for PinnedRepository where diff --git a/crates/spfs/src/storage/platform.rs b/crates/spfs/src/storage/platform.rs index d0d5bdf63..06d5eb9a0 100644 --- a/crates/spfs/src/storage/platform.rs +++ b/crates/spfs/src/storage/platform.rs @@ -47,4 +47,5 @@ pub trait PlatformStorage: graph::Database + Sync + Send { } } -impl PlatformStorage for &T {} +/// Blanket implementation. +impl PlatformStorage for T where T: graph::Database + Sync + Send {} diff --git a/crates/spfs/src/storage/proxy/repository.rs b/crates/spfs/src/storage/proxy/repository.rs index c59f4e132..e22d28a93 100644 --- a/crates/spfs/src/storage/proxy/repository.rs +++ b/crates/spfs/src/storage/proxy/repository.rs @@ -331,10 +331,6 @@ impl TagStorageMut for ProxyRepository { } } -impl BlobStorage for ProxyRepository {} -impl ManifestStorage for ProxyRepository {} -impl LayerStorage for ProxyRepository {} -impl PlatformStorage for ProxyRepository {} impl Address for ProxyRepository { fn address(&self) -> Cow<'_, url::Url> { let config = Config { @@ -348,4 +344,3 @@ impl Address for ProxyRepository { Cow::Owned(config.to_address().expect("config creates a valid url")) } } -impl Repository for ProxyRepository {} diff --git a/crates/spfs/src/storage/repository.rs b/crates/spfs/src/storage/repository.rs index 984a63d7d..ea52d749c 100644 --- a/crates/spfs/src/storage/repository.rs +++ b/crates/spfs/src/storage/repository.rs @@ -111,27 +111,21 @@ pub trait Repository: } } -#[async_trait::async_trait] -impl Repository for &T { - async fn has_ref(&self, reference: &str) -> bool { - (**self).has_ref(reference).await - } - - async fn resolve_ref(&self, reference: &str) -> Result { - (**self).resolve_ref(reference).await - } - - async fn read_ref(&self, reference: &str) -> Result { - (**self).read_ref(reference).await - } - - async fn find_aliases(&self, reference: &str) -> Result> { - (**self).find_aliases(reference).await - } - - async fn commit_blob(&self, reader: Pin>) -> Result { - (**self).commit_blob(reader).await - } +/// Blanket implementation. +impl Repository for T where + T: super::Address + + super::TagStorage + + super::PayloadStorage + + super::ManifestStorage + + super::BlobStorage + + super::LayerStorage + + super::PlatformStorage + + graph::Database + + graph::DatabaseView + + std::fmt::Debug + + Send + + Sync +{ } /// Accessor methods for types only applicable to repositories that have diff --git a/crates/spfs/src/storage/rpc/database.rs b/crates/spfs/src/storage/rpc/database.rs index 7b44ad670..c0afa685f 100644 --- a/crates/spfs/src/storage/rpc/database.rs +++ b/crates/spfs/src/storage/rpc/database.rs @@ -9,7 +9,7 @@ use futures::{Stream, TryStreamExt}; use proto::RpcResult; use crate::graph::{self, ObjectProto}; -use crate::{encoding, proto, storage, Result}; +use crate::{encoding, proto, Result}; #[async_trait::async_trait] impl graph::DatabaseView for super::RpcRepository { @@ -112,8 +112,3 @@ impl graph::Database for super::RpcRepository { .to_result()?) } } - -impl storage::PlatformStorage for super::RpcRepository {} -impl storage::LayerStorage for super::RpcRepository {} -impl storage::ManifestStorage for super::RpcRepository {} -impl storage::BlobStorage for super::RpcRepository {} diff --git a/crates/spfs/src/storage/rpc/repository.rs b/crates/spfs/src/storage/rpc/repository.rs index 1cc66afb0..cdaa952a6 100644 --- a/crates/spfs/src/storage/rpc/repository.rs +++ b/crates/spfs/src/storage/rpc/repository.rs @@ -175,5 +175,3 @@ impl storage::Address for RpcRepository { Cow::Borrowed(&self.address) } } - -impl storage::Repository for RpcRepository {} diff --git a/crates/spfs/src/storage/tar/repository.rs b/crates/spfs/src/storage/tar/repository.rs index 32487fe28..14ec2396b 100644 --- a/crates/spfs/src/storage/tar/repository.rs +++ b/crates/spfs/src/storage/tar/repository.rs @@ -406,10 +406,6 @@ impl TagStorageMut for TarRepository { } } -impl BlobStorage for TarRepository {} -impl ManifestStorage for TarRepository {} -impl LayerStorage for TarRepository {} -impl PlatformStorage for TarRepository {} impl Address for TarRepository { fn address(&self) -> Cow<'_, url::Url> { Cow::Owned( @@ -417,4 +413,3 @@ impl Address for TarRepository { ) } } -impl Repository for TarRepository {}