1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct CollectionsResponse {
6 pub collections: Vec<Collection>,
7 pub page: u32,
8 pub per_page: u32,
9 pub total_results: u32,
10 pub next_page: Option<String>,
11 pub prev_page: Option<String>,
12}
13
14#[derive(Serialize, Deserialize, Debug, Clone)]
16pub struct Collection {
17 pub id: String,
18 pub title: String,
19 pub description: Option<String>,
20 pub private: bool,
21 pub media_count: u32,
22 pub photos_count: u32,
23 pub videos_count: u32,
24}
25
26#[derive(Serialize, Deserialize, Debug, Clone)]
28pub struct MediaResponse {
29 pub id: String,
30 pub media: Vec<MediaType>, pub page: u32,
32 pub per_page: u32,
33 pub total_results: u32,
34 pub next_page: Option<String>,
35 pub prev_page: Option<String>,
36}
37
38#[derive(Serialize, Deserialize, Debug, Clone)]
41#[serde(tag = "type")]
42pub enum MediaType {
43 Photo(MediaPhoto),
44 Video(MediaVideo),
45}
46
47impl From<MediaType> for MediaPhoto {
49 fn from(media: MediaType) -> Self {
50 match media {
51 MediaType::Photo(photo) => MediaPhoto { type_: "Photo".to_string(), ..photo },
52 _ => panic!("Expected Photo"),
53 }
54 }
55}
56
57impl From<MediaType> for MediaVideo {
58 fn from(media: MediaType) -> Self {
59 match media {
60 MediaType::Video(video) => MediaVideo { type_: "Video".to_string(), ..video },
61 _ => panic!("Expected Video"),
62 }
63 }
64}
65
66#[derive(Serialize, Deserialize, Debug, Clone)]
68pub struct MediaPhoto {
69 #[serde(skip)]
70 pub type_: String,
71 pub id: u32,
72 pub width: u32,
73 pub height: u32,
74 pub url: Option<String>,
75 pub photographer: Option<String>,
76 pub photographer_url: Option<String>,
77 pub photographer_id: u32,
78 pub avg_color: String,
79 pub src: PhotoSrc,
80 pub liked: bool,
81 pub alt: String,
82}
83
84#[derive(Serialize, Deserialize, Debug, Clone)]
86pub struct MediaVideo {
87 #[serde(skip)]
88 pub type_: String,
89 pub id: u32,
90 pub width: u32,
91 pub height: u32,
92 pub duration: u32,
93 pub full_res: Option<String>,
94 pub tags: Vec<String>,
95 pub url: Option<String>,
96 pub image: Option<String>,
97 pub avg_color: Option<String>,
98 pub user: User,
99 pub video_files: Vec<VideoFile>,
100 pub video_pictures: Vec<VideoPicture>,
101}
102
103#[derive(Serialize, Deserialize, Debug, Clone)]
105pub struct Photo {
106 pub id: u32,
107 pub width: u32,
108 pub height: u32,
109 pub url: String,
110 pub photographer: String,
111 pub photographer_url: String,
112 pub photographer_id: u32,
113 pub avg_color: String,
114 pub src: PhotoSrc,
115 pub liked: bool,
116 pub alt: String,
117}
118
119#[derive(Serialize, Deserialize, Debug, Clone)]
121pub struct PhotoSrc {
122 pub original: String,
123 pub large2x: String,
124 pub large: String,
125 pub medium: String,
126 pub small: String,
127 pub portrait: String,
128 pub landscape: String,
129 pub tiny: String,
130}
131
132#[derive(Serialize, Deserialize, Debug, Clone)]
134pub struct PhotosResponse {
135 pub total_results: u32,
136 pub page: u32,
137 pub per_page: u32,
138 pub photos: Vec<Photo>,
139 pub next_page: Option<String>,
140 pub prev_page: Option<String>,
141}
142
143#[derive(Serialize, Deserialize, Debug, Clone)]
145pub struct VideoResponse {
146 pub page: u32,
147 pub per_page: u32,
148 pub total_results: u32,
149 pub url: String,
150 pub videos: Vec<Video>,
151 pub prev_page: Option<String>,
152 pub next_page: Option<String>,
153}
154
155#[derive(Serialize, Deserialize, Debug, Clone)]
157pub struct Video {
158 #[serde(default)]
159 pub avg_color: Option<String>,
160 pub duration: u32,
161 #[serde(default)]
162 pub full_res: Option<String>,
163 pub height: u32,
164 pub id: u32,
165 #[serde(rename = "image")]
166 pub image_url: String,
167 pub tags: Vec<String>,
168 #[serde(rename = "url")]
169 pub video_url: String,
170 pub user: User,
171 pub video_files: Vec<VideoFile>,
172 pub video_pictures: Vec<VideoPicture>,
173 pub width: u32,
174}
175
176#[derive(Serialize, Deserialize, Debug, Clone)]
178pub struct User {
179 pub id: u32,
180 pub name: String,
181 #[serde(rename = "url")]
182 pub user_url: String,
183}
184
185#[derive(Serialize, Deserialize, Debug, Clone)]
187pub struct VideoFile {
188 pub file_type: String,
189 pub fps: f64,
190 pub height: u32,
191 pub id: u32,
192 #[serde(rename = "link")]
193 pub file_link: String,
194 #[serde(default)]
195 pub quality: Option<String>,
196 pub size: u64,
197 pub width: u32,
198}
199
200#[derive(Serialize, Deserialize, Debug, Clone)]
202pub struct VideoPicture {
203 pub id: u32,
204 pub nr: u32,
205 #[serde(rename = "picture")]
206 pub picture_url: String,
207}