replicate_client/models/
common.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct ApiResponse<T> {
8 #[serde(flatten)]
10 pub data: T,
11}
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct PaginatedResponse<T> {
16 pub results: Vec<T>,
18 pub next: Option<String>,
20 pub previous: Option<String>,
22}
23
24impl<T> PaginatedResponse<T> {
25 pub fn has_next(&self) -> bool {
27 self.next.is_some()
28 }
29
30 pub fn has_previous(&self) -> bool {
32 self.previous.is_some()
33 }
34
35 pub fn len(&self) -> usize {
37 self.results.len()
38 }
39
40 pub fn is_empty(&self) -> bool {
42 self.results.is_empty()
43 }
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48pub struct Hardware {
49 pub sku: String,
51 pub name: String,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct ModelVersion {
58 pub id: String,
60 pub created_at: String,
62 pub cog_version: Option<String>,
64 pub openapi_schema: Option<serde_json::Value>,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct Model {
71 pub owner: String,
73 pub name: String,
75 pub description: Option<String>,
77 pub visibility: String,
79 pub github_url: Option<String>,
81 pub paper_url: Option<String>,
83 pub license_url: Option<String>,
85 pub cover_image_url: Option<String>,
87 pub latest_version: Option<ModelVersion>,
89}
90
91impl Model {
92 pub fn identifier(&self) -> String {
94 format!("{}/{}", self.owner, self.name)
95 }
96}