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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
use crate::models::*;

use super::Getter;

/// A `Setter` for setting the prompt text.
#[derive(Clone, Debug, Default)]
pub(crate) struct Prompt;

/// A `Setter` for setting the negative prompt text.
#[derive(Clone, Debug, Default)]
pub(crate) struct NegativePrompt;

/// A `Setter` for setting the model.
#[derive(Clone, Debug, Default)]
pub(crate) struct Model;

/// A `Setter` for setting the image width.
#[derive(Clone, Debug, Default)]
pub(crate) struct Width;

/// A `Setter` for setting the image height.
#[derive(Clone, Debug, Default)]
pub(crate) struct Height;

/// A `Setter` for setting the seed. Generic over the node type.
#[derive(Clone, Debug)]
pub(crate) struct SeedT<N>
where
    N: Node + 'static,
{
    pub _phantom: std::marker::PhantomData<N>,
}

impl<N> Default for SeedT<N>
where
    N: Node + 'static,
{
    fn default() -> Self {
        Self {
            _phantom: std::marker::PhantomData,
        }
    }
}

/// A `Setter` for setting the seed.
pub(crate) type Seed =
    Delegating<SeedT<KSampler>, SeedT<SamplerCustom>, i64, KSampler, SamplerCustom>;

#[derive(Clone, Debug)]
pub(crate) struct StepsT<N>
where
    N: Node + 'static,
{
    pub _phantom: std::marker::PhantomData<N>,
}

impl<N> Default for StepsT<N>
where
    N: Node + 'static,
{
    fn default() -> Self {
        Self {
            _phantom: std::marker::PhantomData,
        }
    }
}

/// A `Setter` for setting the steps.
pub(crate) type Steps =
    Delegating<StepsT<KSampler>, StepsT<SDTurboScheduler>, u32, KSampler, SDTurboScheduler>;

/// A `Setter` that delegates to two other `Setter`s.
#[derive(Clone, Debug)]
pub(crate) struct Delegating<S1, S2, T, N1, N2>
where
    S1: Getter<T, N1>,
    S2: Getter<T, N2>,
    N1: Node + 'static,
    N2: Node + 'static,
    T: Clone + Default,
{
    _phantom: std::marker::PhantomData<(S1, S2, T, N1, N2)>,
}

impl<S1, S2, T, N1, N2> Default for Delegating<S1, S2, T, N1, N2>
where
    S1: Getter<T, N1>,
    S2: Getter<T, N2>,
    N1: Node + 'static,
    N2: Node + 'static,
    T: Clone + Default,
{
    fn default() -> Self {
        Self {
            _phantom: std::marker::PhantomData,
        }
    }
}

#[derive(Clone, Debug)]
pub(crate) struct CfgT<N>
where
    N: Node + 'static,
{
    pub _phantom: std::marker::PhantomData<N>,
}

impl<N> Default for CfgT<N>
where
    N: Node + 'static,
{
    fn default() -> Self {
        Self {
            _phantom: std::marker::PhantomData,
        }
    }
}

/// A `Setter` for setting the Cfg scale.
pub(crate) type Cfg = Delegating<CfgT<KSampler>, CfgT<SamplerCustom>, f32, KSampler, SamplerCustom>;

#[derive(Clone, Debug, Default)]
pub(crate) struct Denoise;

#[derive(Clone, Debug)]
pub(crate) struct SamplerT<N>
where
    N: Node + 'static,
{
    pub _phantom: std::marker::PhantomData<N>,
}

impl<N> Default for SamplerT<N>
where
    N: Node + 'static,
{
    fn default() -> Self {
        Self {
            _phantom: std::marker::PhantomData,
        }
    }
}

/// A `Setter` for setting the Cfg sampler.
pub(crate) type Sampler =
    Delegating<SamplerT<KSampler>, SamplerT<KSamplerSelect>, String, KSampler, KSamplerSelect>;

#[derive(Clone, Debug, Default)]
pub(crate) struct BatchSize;

#[derive(Clone, Debug, Default)]
pub(crate) struct LoadImage;