comfyui_api/comfy/
accessors.rs

1use crate::models::*;
2
3use super::Getter;
4
5/// A `Setter` for setting the prompt text.
6#[derive(Clone, Debug, Default)]
7pub(crate) struct Prompt;
8
9/// A `Setter` for setting the negative prompt text.
10#[derive(Clone, Debug, Default)]
11pub(crate) struct NegativePrompt;
12
13/// A `Setter` for setting the model.
14#[derive(Clone, Debug, Default)]
15pub(crate) struct Model;
16
17/// A `Setter` for setting the image width.
18#[derive(Clone, Debug, Default)]
19pub(crate) struct Width;
20
21/// A `Setter` for setting the image height.
22#[derive(Clone, Debug, Default)]
23pub(crate) struct Height;
24
25/// A `Setter` for setting the seed. Generic over the node type.
26#[derive(Clone, Debug)]
27pub(crate) struct SeedT<N>
28where
29    N: Node + 'static,
30{
31    pub _phantom: std::marker::PhantomData<N>,
32}
33
34impl<N> Default for SeedT<N>
35where
36    N: Node + 'static,
37{
38    fn default() -> Self {
39        Self {
40            _phantom: std::marker::PhantomData,
41        }
42    }
43}
44
45/// A `Setter` for setting the seed.
46pub(crate) type Seed =
47    Delegating<SeedT<KSampler>, SeedT<SamplerCustom>, i64, KSampler, SamplerCustom>;
48
49#[derive(Clone, Debug)]
50pub(crate) struct StepsT<N>
51where
52    N: Node + 'static,
53{
54    pub _phantom: std::marker::PhantomData<N>,
55}
56
57impl<N> Default for StepsT<N>
58where
59    N: Node + 'static,
60{
61    fn default() -> Self {
62        Self {
63            _phantom: std::marker::PhantomData,
64        }
65    }
66}
67
68/// A `Setter` for setting the steps.
69pub(crate) type Steps =
70    Delegating<StepsT<KSampler>, StepsT<SDTurboScheduler>, u32, KSampler, SDTurboScheduler>;
71
72/// A `Setter` that delegates to two other `Setter`s.
73#[derive(Clone, Debug)]
74pub(crate) struct Delegating<S1, S2, T, N1, N2>
75where
76    S1: Getter<T, N1>,
77    S2: Getter<T, N2>,
78    N1: Node + 'static,
79    N2: Node + 'static,
80    T: Clone + Default,
81{
82    _phantom: std::marker::PhantomData<(S1, S2, T, N1, N2)>,
83}
84
85impl<S1, S2, T, N1, N2> Default for Delegating<S1, S2, T, N1, N2>
86where
87    S1: Getter<T, N1>,
88    S2: Getter<T, N2>,
89    N1: Node + 'static,
90    N2: Node + 'static,
91    T: Clone + Default,
92{
93    fn default() -> Self {
94        Self {
95            _phantom: std::marker::PhantomData,
96        }
97    }
98}
99
100#[derive(Clone, Debug)]
101pub(crate) struct CfgT<N>
102where
103    N: Node + 'static,
104{
105    pub _phantom: std::marker::PhantomData<N>,
106}
107
108impl<N> Default for CfgT<N>
109where
110    N: Node + 'static,
111{
112    fn default() -> Self {
113        Self {
114            _phantom: std::marker::PhantomData,
115        }
116    }
117}
118
119/// A `Setter` for setting the Cfg scale.
120pub(crate) type Cfg = Delegating<CfgT<KSampler>, CfgT<SamplerCustom>, f32, KSampler, SamplerCustom>;
121
122#[derive(Clone, Debug, Default)]
123pub(crate) struct Denoise;
124
125#[derive(Clone, Debug)]
126pub(crate) struct SamplerT<N>
127where
128    N: Node + 'static,
129{
130    pub _phantom: std::marker::PhantomData<N>,
131}
132
133impl<N> Default for SamplerT<N>
134where
135    N: Node + 'static,
136{
137    fn default() -> Self {
138        Self {
139            _phantom: std::marker::PhantomData,
140        }
141    }
142}
143
144/// A `Setter` for setting the Cfg sampler.
145pub(crate) type Sampler =
146    Delegating<SamplerT<KSampler>, SamplerT<KSamplerSelect>, String, KSampler, KSamplerSelect>;
147
148#[derive(Clone, Debug, Default)]
149pub(crate) struct BatchSize;
150
151#[derive(Clone, Debug, Default)]
152pub(crate) struct LoadImage;