use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApiResponse<T> {
#[serde(flatten)]
pub data: T,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaginatedResponse<T> {
pub results: Vec<T>,
pub next: Option<String>,
pub previous: Option<String>,
}
impl<T> PaginatedResponse<T> {
pub fn has_next(&self) -> bool {
self.next.is_some()
}
pub fn has_previous(&self) -> bool {
self.previous.is_some()
}
pub fn len(&self) -> usize {
self.results.len()
}
pub fn is_empty(&self) -> bool {
self.results.is_empty()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Hardware {
pub sku: String,
pub name: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModelVersion {
pub id: String,
pub created_at: String,
pub cog_version: Option<String>,
pub openapi_schema: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Model {
pub owner: String,
pub name: String,
pub description: Option<String>,
pub visibility: String,
pub github_url: Option<String>,
pub paper_url: Option<String>,
pub license_url: Option<String>,
pub cover_image_url: Option<String>,
pub latest_version: Option<ModelVersion>,
}
impl Model {
pub fn identifier(&self) -> String {
format!("{}/{}", self.owner, self.name)
}
}