Skip to main content

systemprompt_files/models/
image_metadata.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4pub struct ImageMetadata {
5    #[serde(default, skip_serializing_if = "Option::is_none")]
6    pub width: Option<u32>,
7
8    #[serde(default, skip_serializing_if = "Option::is_none")]
9    pub height: Option<u32>,
10
11    #[serde(default, skip_serializing_if = "Option::is_none")]
12    pub alt_text: Option<String>,
13
14    #[serde(default, skip_serializing_if = "Option::is_none")]
15    pub description: Option<String>,
16
17    #[serde(default, skip_serializing_if = "Option::is_none")]
18    pub generation: Option<ImageGenerationInfo>,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct ImageGenerationInfo {
23    pub prompt: String,
24    pub model: String,
25    pub provider: String,
26
27    #[serde(default, skip_serializing_if = "Option::is_none")]
28    pub resolution: Option<String>,
29
30    #[serde(default, skip_serializing_if = "Option::is_none")]
31    pub aspect_ratio: Option<String>,
32
33    #[serde(default, skip_serializing_if = "Option::is_none")]
34    pub generation_time_ms: Option<i32>,
35
36    #[serde(default, skip_serializing_if = "Option::is_none")]
37    pub cost_estimate: Option<f32>,
38
39    #[serde(default, skip_serializing_if = "Option::is_none")]
40    pub request_id: Option<String>,
41}
42
43impl ImageMetadata {
44    pub const fn new() -> Self {
45        Self {
46            width: None,
47            height: None,
48            alt_text: None,
49            description: None,
50            generation: None,
51        }
52    }
53
54    pub const fn with_dimensions(mut self, width: u32, height: u32) -> Self {
55        self.width = Some(width);
56        self.height = Some(height);
57        self
58    }
59
60    pub fn with_alt_text(mut self, alt: impl Into<String>) -> Self {
61        self.alt_text = Some(alt.into());
62        self
63    }
64
65    pub fn with_description(mut self, desc: impl Into<String>) -> Self {
66        self.description = Some(desc.into());
67        self
68    }
69
70    pub fn with_generation(mut self, gen: ImageGenerationInfo) -> Self {
71        self.generation = Some(gen);
72        self
73    }
74}
75
76impl ImageGenerationInfo {
77    pub fn new(
78        prompt: impl Into<String>,
79        model: impl Into<String>,
80        provider: impl Into<String>,
81    ) -> Self {
82        Self {
83            prompt: prompt.into(),
84            model: model.into(),
85            provider: provider.into(),
86            resolution: None,
87            aspect_ratio: None,
88            generation_time_ms: None,
89            cost_estimate: None,
90            request_id: None,
91        }
92    }
93
94    pub fn with_resolution(mut self, resolution: impl Into<String>) -> Self {
95        self.resolution = Some(resolution.into());
96        self
97    }
98
99    pub fn with_aspect_ratio(mut self, aspect_ratio: impl Into<String>) -> Self {
100        self.aspect_ratio = Some(aspect_ratio.into());
101        self
102    }
103
104    pub const fn with_generation_time(mut self, time_ms: i32) -> Self {
105        self.generation_time_ms = Some(time_ms);
106        self
107    }
108
109    pub const fn with_cost_estimate(mut self, cost: f32) -> Self {
110        self.cost_estimate = Some(cost);
111        self
112    }
113
114    pub fn with_request_id(mut self, request_id: impl Into<String>) -> Self {
115        self.request_id = Some(request_id.into());
116        self
117    }
118}