entrenar/hf_pipeline/publish/
result.rs1use std::fmt;
4
5#[derive(Clone, Debug)]
7pub struct PublishResult {
8 pub repo_url: String,
10 pub repo_id: String,
12 pub files_uploaded: usize,
14 pub model_card_generated: bool,
16}
17
18impl fmt::Display for PublishResult {
19 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20 write!(
21 f,
22 "Published to {} ({} files{})",
23 self.repo_url,
24 self.files_uploaded,
25 if self.model_card_generated { " + model card" } else { "" }
26 )
27 }
28}
29
30#[derive(Debug, thiserror::Error)]
32pub enum PublishError {
33 #[error("Failed to create repository '{repo_id}': {message}")]
35 RepoCreationFailed { repo_id: String, message: String },
36
37 #[error("Failed to upload '{path}': {message}")]
39 UploadFailed { path: String, message: String },
40
41 #[error("Authentication required: set HF_TOKEN or use with_token()")]
43 AuthRequired,
44
45 #[error("Invalid repository ID '{repo_id}': must be 'owner/name'")]
47 InvalidRepoId { repo_id: String },
48
49 #[error("HTTP error: {message}")]
51 Http { message: String },
52
53 #[error("IO error: {0}")]
55 Io(#[from] std::io::Error),
56
57 #[error("Serialization error: {0}")]
59 Serialization(String),
60}