#[cfg(feature = "hf-live")]
mod live;
#[cfg(feature = "hf-live")]
pub use live::HfRegistry;
#[cfg(not(feature = "hf-live"))]
use crate::image_ref::ImageRef;
#[cfg(not(feature = "hf-live"))]
use crate::registry::{LayerSet, Registry, RegistryError};
#[cfg(not(feature = "hf-live"))]
use async_trait::async_trait;
#[cfg(not(feature = "hf-live"))]
use pf_core::cas::BlobStore;
#[cfg(not(feature = "hf-live"))]
use pf_core::manifest::Manifest;
#[cfg(not(feature = "hf-live"))]
#[derive(Debug, Default)]
pub struct HfRegistry {
_token: Option<String>,
}
#[cfg(not(feature = "hf-live"))]
impl HfRegistry {
pub fn new(token: Option<String>) -> Self {
Self { _token: token }
}
}
#[cfg(not(feature = "hf-live"))]
fn err() -> RegistryError {
RegistryError::UnsupportedScheme(
"hf:// — pf-registry built without `hf-live`. Rebuild with \
`--features hf-live` (default since v1.0.2) to enable HF Hub."
.into(),
)
}
#[cfg(not(feature = "hf-live"))]
#[async_trait]
impl Registry for HfRegistry {
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())
}
}