#[cfg(feature = "ipfs-live")]
mod live;
#[cfg(feature = "ipfs-live")]
pub use live::IpfsRegistry;
#[cfg(not(feature = "ipfs-live"))]
use crate::image_ref::ImageRef;
#[cfg(not(feature = "ipfs-live"))]
use crate::registry::{LayerSet, Registry, RegistryError};
#[cfg(not(feature = "ipfs-live"))]
use async_trait::async_trait;
#[cfg(not(feature = "ipfs-live"))]
use pf_core::cas::BlobStore;
#[cfg(not(feature = "ipfs-live"))]
use pf_core::manifest::Manifest;
#[cfg(not(feature = "ipfs-live"))]
#[derive(Debug, Default)]
pub struct IpfsRegistry {
_endpoint: String,
}
#[cfg(not(feature = "ipfs-live"))]
impl IpfsRegistry {
pub fn new(endpoint: String) -> Self {
Self {
_endpoint: endpoint,
}
}
}
#[cfg(not(feature = "ipfs-live"))]
fn err() -> RegistryError {
RegistryError::UnsupportedScheme(
"ipfs:// — pf-registry built without `ipfs-live`. Rebuild with \
`--features ipfs-live` (default since v1.0.2) to enable IPFS."
.into(),
)
}
#[cfg(not(feature = "ipfs-live"))]
#[async_trait]
impl Registry for IpfsRegistry {
async fn push(
&self,
_: &ImageRef,
_: &Manifest,
_: &dyn BlobStore,
) -> Result<(), RegistryError> {
Err(err())
}
async fn pull(&self, _: &ImageRef) -> Result<LayerSet, RegistryError> {
Err(err())
}
async fn exists(&self, _: &ImageRef) -> Result<bool, RegistryError> {
Err(err())
}
}