imgbb/model.rs
1use serde::Deserialize;
2
3/// Response from the ImgBB API
4///
5/// The API returns a JSON structure that includes the upload data,
6/// as well as status and success information.
7#[derive(Debug, Deserialize, Clone)]
8pub struct Response {
9 /// The image data information if the upload was successful
10 pub data: Option<Data>,
11 /// Boolean indicating if the request was successful
12 pub success: Option<bool>,
13 /// HTTP status code
14 pub status: Option<u16>,
15 /// Error message if the request failed
16 pub error: Option<ErrorResponse>,
17}
18
19/// Error information returned by the ImgBB API when a request fails
20#[derive(Debug, Deserialize, Clone)]
21pub struct ErrorResponse {
22 /// Error message
23 pub message: Option<String>,
24 /// Error code
25 pub code: Option<u16>,
26}
27
28/// Detailed information about an uploaded image
29#[derive(Debug, Deserialize, Clone)]
30pub struct Data {
31 /// Unique ID of the uploaded image
32 pub id: Option<String>,
33 /// Title of the image (if provided during upload)
34 pub title: Option<String>,
35 /// URL to view the image on ImgBB website
36 pub url_viewer: Option<String>,
37 /// Direct URL to the image
38 pub url: Option<String>,
39 /// Display URL (typically used in HTML)
40 pub display_url: Option<String>,
41 /// Width of the image in pixels
42 pub width: Option<u16>,
43 /// Height of the image in pixels
44 pub height: Option<u16>,
45 /// Size of the image in bytes
46 pub size: Option<u32>,
47 /// Unix timestamp of when the image was uploaded
48 pub time: Option<u64>,
49 /// Expiration time in seconds, if set
50 pub expiration: Option<u64>,
51 /// Full-size image information
52 pub image: Option<Image>,
53 /// Thumbnail image information
54 pub thumb: Option<Image>,
55 /// Medium-size image information
56 pub medium: Option<Image>,
57 /// URL to delete the image
58 pub delete_url: Option<String>,
59}
60
61/// Information about a specific image variant (original, thumbnail, etc.)
62#[derive(Debug, Deserialize, Clone)]
63pub struct Image {
64 /// Original filename
65 pub filename: Option<String>,
66 /// Name of the image
67 pub name: Option<String>,
68 /// MIME type (e.g., "image/jpeg")
69 pub mime: Option<String>,
70 /// File extension (e.g., "jpg")
71 pub extension: Option<String>,
72 /// Direct URL to this image variant
73 pub url: Option<String>,
74}