async_openai/types/images/
impls.rs1#![allow(deprecated)]
2use std::fmt::Display;
3
4#[cfg(not(target_family = "wasm"))]
5use std::path::{Path, PathBuf};
6
7use crate::types::images::{
8 DallE2ImageSize, ImageBackground, ImageEditInput, ImageInput, ImageModel, ImageOutputFormat,
9 ImageQuality, ImageResponseFormat, ImageSize, InputFidelity,
10};
11
12impl Display for ImageSize {
13 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14 write!(
15 f,
16 "{}",
17 match self {
18 Self::S256x256 => "256x256",
19 Self::S512x512 => "512x512",
20 Self::S1024x1024 => "1024x1024",
21 Self::S1792x1024 => "1792x1024",
22 Self::S1024x1792 => "1024x1792",
23 Self::S1536x1024 => "1536x1024",
24 Self::S1024x1536 => "1024x1536",
25 Self::Auto => "auto",
26 Self::Other(other) => other,
27 }
28 )
29 }
30}
31
32impl Display for DallE2ImageSize {
33 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34 write!(
35 f,
36 "{}",
37 match self {
38 Self::S256x256 => "256x256",
39 Self::S512x512 => "512x512",
40 Self::S1024x1024 => "1024x1024",
41 }
42 )
43 }
44}
45
46impl Display for ImageModel {
47 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
48 write!(
49 f,
50 "{}",
51 match self {
52 Self::GptImage2 => "gpt-image-2",
53 Self::GptImage2_2026_04_21 => "gpt-image-2-2026-04-21",
54 Self::GptImage2_5Sunburst => "gpt-image-2.5-sunburst",
55 Self::GptImage2_5Sunburst2026_09_08 => "gpt-image-2.5-sunburst-2026-09-08",
56 Self::GptImage2_5Flare => "gpt-image-2.5-flare",
57 Self::GptImage2_5Flare2026_09_08 => "gpt-image-2.5-flare-2026-09-08",
58 Self::GptImage1dot5 => "gpt-image-1.5",
59 Self::GptImage1Mini => "gpt-image-1-mini",
60 Self::ChatGptImageLatest => "chatgpt-image-latest",
61 Self::Other(other) => other,
62 }
63 )
64 }
65}
66
67impl Display for ImageBackground {
68 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
69 write!(
70 f,
71 "{}",
72 match self {
73 Self::Transparent => "transparent",
74 Self::Opaque => "opaque",
75 Self::Auto => "auto",
76 }
77 )
78 }
79}
80
81impl Display for ImageOutputFormat {
82 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
83 write!(
84 f,
85 "{}",
86 match self {
87 Self::Png => "png",
88 Self::Jpeg => "jpeg",
89 Self::Webp => "webp",
90 }
91 )
92 }
93}
94
95impl Display for InputFidelity {
96 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
97 write!(
98 f,
99 "{}",
100 match self {
101 Self::High => "high",
102 Self::Low => "low",
103 }
104 )
105 }
106}
107
108impl Display for ImageQuality {
109 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
110 write!(
111 f,
112 "{}",
113 match self {
114 Self::Low => "low",
115 Self::Medium => "medium",
116 Self::High => "high",
117 Self::XHigh => "xhigh",
118 Self::Max => "max",
119 Self::Auto => "auto",
120 Self::Standard => "standard",
121 Self::HD => "hd",
122 }
123 )
124 }
125}
126
127impl Display for ImageResponseFormat {
128 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
129 write!(
130 f,
131 "{}",
132 match self {
133 Self::Url => "url",
134 Self::B64Json => "b64_json",
135 }
136 )
137 }
138}
139
140impl Default for ImageEditInput {
141 fn default() -> Self {
142 Self::Image(ImageInput::default())
143 }
144}
145
146impl From<ImageInput> for ImageEditInput {
147 fn from(value: ImageInput) -> Self {
148 Self::Image(value)
149 }
150}
151
152impl From<Vec<ImageInput>> for ImageEditInput {
153 fn from(value: Vec<ImageInput>) -> Self {
154 Self::Images(value)
155 }
156}
157
158#[cfg(not(target_family = "wasm"))]
160impl From<&str> for ImageEditInput {
161 fn from(value: &str) -> Self {
162 Self::Image(value.into())
163 }
164}
165
166#[cfg(not(target_family = "wasm"))]
167impl From<String> for ImageEditInput {
168 fn from(value: String) -> Self {
169 Self::Image(value.into())
170 }
171}
172
173#[cfg(not(target_family = "wasm"))]
174impl From<&Path> for ImageEditInput {
175 fn from(value: &Path) -> Self {
176 Self::Image(value.into())
177 }
178}
179
180#[cfg(not(target_family = "wasm"))]
181impl From<PathBuf> for ImageEditInput {
182 fn from(value: PathBuf) -> Self {
183 Self::Image(value.into())
184 }
185}
186
187#[cfg(not(target_family = "wasm"))]
189impl<const N: usize> From<[&str; N]> for ImageEditInput {
190 fn from(value: [&str; N]) -> Self {
191 Self::Images(value.into_iter().map(ImageInput::from).collect())
192 }
193}
194
195#[cfg(not(target_family = "wasm"))]
196impl<const N: usize> From<[String; N]> for ImageEditInput {
197 fn from(value: [String; N]) -> Self {
198 Self::Images(value.into_iter().map(ImageInput::from).collect())
199 }
200}
201
202#[cfg(not(target_family = "wasm"))]
203impl<const N: usize> From<[&Path; N]> for ImageEditInput {
204 fn from(value: [&Path; N]) -> Self {
205 Self::Images(value.into_iter().map(ImageInput::from).collect())
206 }
207}
208
209#[cfg(not(target_family = "wasm"))]
210impl<const N: usize> From<[PathBuf; N]> for ImageEditInput {
211 fn from(value: [PathBuf; N]) -> Self {
212 Self::Images(value.into_iter().map(ImageInput::from).collect())
213 }
214}
215
216#[cfg(not(target_family = "wasm"))]
218impl<'a> From<Vec<&'a str>> for ImageEditInput {
219 fn from(value: Vec<&'a str>) -> Self {
220 Self::Images(value.into_iter().map(ImageInput::from).collect())
221 }
222}
223
224#[cfg(not(target_family = "wasm"))]
225impl From<Vec<String>> for ImageEditInput {
226 fn from(value: Vec<String>) -> Self {
227 Self::Images(value.into_iter().map(ImageInput::from).collect())
228 }
229}
230
231#[cfg(not(target_family = "wasm"))]
232impl From<Vec<&Path>> for ImageEditInput {
233 fn from(value: Vec<&Path>) -> Self {
234 Self::Images(value.into_iter().map(ImageInput::from).collect())
235 }
236}
237
238#[cfg(not(target_family = "wasm"))]
239impl From<Vec<PathBuf>> for ImageEditInput {
240 fn from(value: Vec<PathBuf>) -> Self {
241 Self::Images(value.into_iter().map(ImageInput::from).collect())
242 }
243}