use oci_client::errors::OciDistributionError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum RegistryError {
#[error("OCI distribution error: {0}")]
Oci(#[from] OciDistributionError),
#[error("cache error: {0}")]
Cache(#[from] CacheError),
#[error("image {image} not found in registry {registry}")]
NotFound { registry: String, image: String },
#[error("authentication failed for registry {registry}: {reason}")]
AuthFailed { registry: String, reason: String },
#[error("pull cancelled for image {image}")]
PullCancelled { image: String },
}
#[derive(Debug, Error)]
pub enum CacheError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("database error: {0}")]
Database(String),
#[error("blob {digest} not found in cache")]
NotFound { digest: String },
#[error("cache corrupted: {0}")]
Corrupted(String),
#[error("invalid digest format: {0}")]
InvalidDigest(String),
}
pub type Result<T, E = RegistryError> = std::result::Result<T, E>;