-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrunner_option.go
61 lines (55 loc) · 1.56 KB
/
runner_option.go
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
package run
// RunnerOption configures a Runner.
type RunnerOption[RunnerConfig, Input, Option, Solution any] func(
Runner[RunnerConfig, Input, Option, Solution],
)
// InputDecode sets the input decoder of a runner.
func InputDecode[
RunnerConfig, Input, Option, Solution any,
](i Decoder[Input]) func(
Runner[RunnerConfig, Input, Option, Solution],
) {
return func(r Runner[RunnerConfig, Input, Option, Solution]) {
r.SetInputDecoder(i)
}
}
// InputValidate sets the input validator of a runner.
func InputValidate[
RunnerConfig, Input, Option, Solution any,
](v Validator[Input]) func(
Runner[RunnerConfig, Input, Option, Solution],
) {
return func(r Runner[RunnerConfig, Input, Option, Solution]) {
r.SetInputValidator(v)
}
}
// OptionDecode sets the options decoder of a runner.
func OptionDecode[
RunnerConfig, Input, Option, Solution any,
](o Decoder[Option]) func(
Runner[RunnerConfig, Input, Option, Solution],
) {
return func(r Runner[RunnerConfig, Input, Option, Solution]) {
r.SetOptionDecoder(o)
}
}
// Encode sets the encoder of a runner.
func Encode[
RunnerConfig, Input, Option, Solution any,
](e Encoder[Solution, Option]) func(
Runner[RunnerConfig, Input, Option, Solution],
) {
return func(r Runner[RunnerConfig, Input, Option, Solution]) {
r.SetEncoder(e)
}
}
// IOProduce sets the IOProducer of a runner.
func IOProduce[
RunnerConfig, Input, Option, Solution any,
](i IOProducer[RunnerConfig]) func(
Runner[RunnerConfig, Input, Option, Solution],
) {
return func(r Runner[RunnerConfig, Input, Option, Solution]) {
r.SetIOProducer(i)
}
}