use std::fmt;
#[derive(Clone, Debug)]
pub struct PublishResult {
pub repo_url: String,
pub repo_id: String,
pub files_uploaded: usize,
pub model_card_generated: bool,
}
impl fmt::Display for PublishResult {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"Published to {} ({} files{})",
self.repo_url,
self.files_uploaded,
if self.model_card_generated { " + model card" } else { "" }
)
}
}
#[derive(Debug, thiserror::Error)]
pub enum PublishError {
#[error("Failed to create repository '{repo_id}': {message}")]
RepoCreationFailed { repo_id: String, message: String },
#[error("Failed to upload '{path}': {message}")]
UploadFailed { path: String, message: String },
#[error("Authentication required: set HF_TOKEN or use with_token()")]
AuthRequired,
#[error("Invalid repository ID '{repo_id}': must be 'owner/name'")]
InvalidRepoId { repo_id: String },
#[error("HTTP error: {message}")]
Http { message: String },
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization error: {0}")]
Serialization(String),
}