use std::path::PathBuf;
use crate::platform::{Arch, Os};
#[derive(Debug, thiserror::Error)]
pub enum ImageError {
#[error("registry error: {0}")]
Registry(#[from] oci_client::errors::OciDistributionError),
#[error("no manifest for platform {os}/{arch} in {reference}")]
PlatformNotFound {
reference: String,
os: Os,
arch: Arch,
},
#[error("manifest parse error: {0}")]
ManifestParse(String),
#[error("config parse error: {0}")]
ConfigParse(String),
#[error("digest mismatch for layer {digest}: expected {expected}, got {actual}")]
DigestMismatch {
digest: String,
expected: String,
actual: String,
},
#[error("extraction failed for layer {digest}: {message}")]
Extraction {
digest: String,
message: String,
#[source]
source: Option<Box<dyn std::error::Error + Send + Sync>>,
},
#[error("index generation failed for layer {0}: {1}")]
IndexBuild(String, #[source] std::io::Error),
#[error("cache error at {}: {source}", path.display())]
Cache {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("image not cached: {reference}")]
NotCached {
reference: String,
},
#[error(transparent)]
Io(#[from] std::io::Error),
}
pub type ImageResult<T> = Result<T, ImageError>;