use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct PublishConfig {
pub repo_id: String,
pub repo_type: RepoType,
pub private: bool,
#[serde(skip)]
pub token: Option<String>,
pub license: Option<String>,
pub tags: Vec<String>,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum RepoType {
#[default]
Model,
Dataset,
Space,
}
impl RepoType {
#[must_use]
pub fn api_path(&self) -> &'static str {
match self {
Self::Model => "models",
Self::Dataset => "datasets",
Self::Space => "spaces",
}
}
}
impl std::fmt::Display for RepoType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Model => write!(f, "model"),
Self::Dataset => write!(f, "dataset"),
Self::Space => write!(f, "space"),
}
}
}