1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Image {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub b64_json: Option<String>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ImageResponse {
    pub created: f32,
    pub data: Vec<Image>,
}

#[allow(non_camel_case_types)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum Size {
    #[serde(rename = "256x256")]
    SIZE_256,
    #[serde(rename = "512x512")]
    SIZE_512,
    #[serde(rename = "1024x1024")]
    SIZE_1024,
}

impl Into<&'static str> for Size {
    fn into(self) -> &'static str {
        match self {
            Self::SIZE_256 => "256x256",
            Self::SIZE_512 => "512x512",
            Self::SIZE_1024 => "1024x1024",
        }
    }
}

#[allow(non_camel_case_types)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum Format {
    #[serde(rename = "url")]
    Url,
    #[serde(rename = "b64_json")]
    B64_JSON,
}

impl Into<&'static str> for Format {
    fn into(self) -> &'static str {
        match self {
            Self::B64_JSON => "b64_json",
            Self::Url => "url",
        }
    }
}