sal_e_api/
image_params.rs1use comfyui_api::models::AsAny;
2use dyn_clone::DynClone;
3use stable_diffusion_api::ImgInfo;
4
5dyn_clone::clone_trait_object!(ImageParams);
6
7pub trait ImageParams: std::fmt::Debug + AsAny + Send + Sync + DynClone {
9 fn seed(&self) -> Option<i64>;
11 fn steps(&self) -> Option<u32>;
13 fn cfg(&self) -> Option<f32>;
15 fn width(&self) -> Option<u32>;
17 fn height(&self) -> Option<u32>;
19 fn prompt(&self) -> Option<String>;
21 fn negative_prompt(&self) -> Option<String>;
23 fn denoising(&self) -> Option<f32>;
25 fn model(&self) -> Option<String>;
27 fn sampler(&self) -> Option<String>;
29}
30
31impl ImageParams for comfyui_api::models::Prompt {
32 fn seed(&self) -> Option<i64> {
33 comfyui_api::comfy::getter::SeedExt::seed(self)
34 .ok()
35 .copied()
36 }
37
38 fn steps(&self) -> Option<u32> {
39 comfyui_api::comfy::getter::StepsExt::steps(self)
40 .ok()
41 .copied()
42 }
43
44 fn cfg(&self) -> Option<f32> {
45 comfyui_api::comfy::getter::CfgExt::cfg(self).ok().copied()
46 }
47
48 fn width(&self) -> Option<u32> {
49 comfyui_api::comfy::getter::WidthExt::width(self)
50 .ok()
51 .copied()
52 }
53
54 fn height(&self) -> Option<u32> {
55 comfyui_api::comfy::getter::HeightExt::height(self)
56 .ok()
57 .copied()
58 }
59
60 fn prompt(&self) -> Option<String> {
61 comfyui_api::comfy::getter::PromptExt::prompt(self)
62 .ok()
63 .cloned()
64 }
65
66 fn negative_prompt(&self) -> Option<String> {
67 comfyui_api::comfy::getter::NegativePromptExt::negative_prompt(self)
68 .ok()
69 .cloned()
70 }
71
72 fn denoising(&self) -> Option<f32> {
73 comfyui_api::comfy::getter::DenoiseExt::denoise(self)
74 .ok()
75 .copied()
76 }
77
78 fn model(&self) -> Option<String> {
79 comfyui_api::comfy::getter::ModelExt::ckpt_name(self)
80 .ok()
81 .cloned()
82 }
83
84 fn sampler(&self) -> Option<String> {
85 comfyui_api::comfy::getter::SamplerExt::sampler_name(self)
86 .ok()
87 .cloned()
88 }
89}
90
91impl ImageParams for ImgInfo {
92 fn seed(&self) -> Option<i64> {
93 self.seed
94 }
95
96 fn steps(&self) -> Option<u32> {
97 self.steps
98 }
99
100 fn cfg(&self) -> Option<f32> {
101 self.cfg_scale.map(|c| c as f32)
102 }
103
104 fn width(&self) -> Option<u32> {
105 self.width.map(|w| w as u32)
106 }
107
108 fn height(&self) -> Option<u32> {
109 self.height.map(|h| h as u32)
110 }
111
112 fn prompt(&self) -> Option<String> {
113 self.prompt.clone()
114 }
115
116 fn negative_prompt(&self) -> Option<String> {
117 self.negative_prompt.clone()
118 }
119
120 fn denoising(&self) -> Option<f32> {
121 self.denoising_strength.map(|d| d as f32)
122 }
123
124 fn model(&self) -> Option<String> {
125 self.sd_model_name.clone()
126 }
127
128 fn sampler(&self) -> Option<String> {
129 self.sampler_name.clone()
130 }
131}