Skip to content

Commit 27b7ad3

Browse files
committed
comments
1 parent 64a8d4a commit 27b7ad3

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

options/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package options provides an optional standard implementation of [github.com/RangelReale/instruct] options.
2+
package options

options/option.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,76 @@ package options
22

33
import "github.com/RangelReale/instruct"
44

5+
// AnyOption states that the option can be used in any instruct.Decoder function.
56
type AnyOption[IT any, DC instruct.DecodeContext] interface {
67
isAnyOption()
78
}
89

10+
// AnyTypeOption states that the option can be used in any instruct.TypeDecoder function.
911
type AnyTypeOption[IT any, DC instruct.DecodeContext] interface {
1012
isAnyTypeOption()
1113
}
1214

15+
// DefaultOption states that the option can be used in the instruct.NewDecoder function.
1316
type DefaultOption[IT any, DC instruct.DecodeContext, DOPTT any] interface {
1417
AnyOption[IT, DC]
1518
ApplyDefaultOption(*DOPTT)
1619
}
1720

21+
// TypeDefaultOption states that the option can be used in the instruct.NewTypeDecoder function.
1822
type TypeDefaultOption[IT any, DC instruct.DecodeContext, TOPTT any] interface {
1923
AnyTypeOption[IT, DC]
2024
ApplyTypeDefaultOption(*TOPTT)
2125
}
2226

27+
// DecodeOption states that the option can be used in the [instruct.Decoder.Decode] function.
2328
type DecodeOption[IT any, DC instruct.DecodeContext, COPTT any] interface {
2429
AnyOption[IT, DC]
2530
ApplyDecodeOption(*COPTT)
2631
}
2732

33+
// TypeDecodeOption states that the option can be used in the [instruct.TypeDecoder.Decode] function.
2834
type TypeDecodeOption[IT any, DC instruct.DecodeContext, COPTT any] interface {
2935
AnyTypeOption[IT, DC]
3036
ApplyTypeDecodeOption(*COPTT)
3137
}
3238

39+
// DefaultAndTypeDefaultOption states that the option can be used in the instruct.NewDecoder and
40+
// instruct.NewTypeDecoder functions.
3341
type DefaultAndTypeDefaultOption[IT any, DC instruct.DecodeContext, DOPTT any, TOPTT any] interface {
3442
DefaultOption[IT, DC, DOPTT]
3543
TypeDefaultOption[IT, DC, TOPTT]
3644
}
3745

46+
// DefaultAndDecodeOption states that the option can be used in the instruct.NewDecoder and
47+
// [instruct.Decoder.Decode] functions.
3848
type DefaultAndDecodeOption[IT any, DC instruct.DecodeContext, DOPTT any, COPTT any] interface {
3949
DefaultOption[IT, DC, DOPTT]
4050
DecodeOption[IT, DC, COPTT]
4151
}
4252

53+
// TypeDefaultAndTypeDecodeOption states that the option can be used in the instruct.NewTypeDecoder and
54+
// [instruct.TypeDecoder.Decode] functions.
4355
type TypeDefaultAndTypeDecodeOption[IT any, DC instruct.DecodeContext, TOPTT any, COPTT any] interface {
4456
TypeDefaultOption[IT, DC, TOPTT]
4557
TypeDecodeOption[IT, DC, COPTT]
4658
}
4759

60+
// DefaultAndTypeDefaultDecodeOption states that the option can be used in the [instruct.Decoder.Decode] and
61+
// [instruct.TypeDecoder.Decode] functions.
4862
type DefaultAndTypeDefaultDecodeOption[IT any, DC instruct.DecodeContext, DCOPTT any, TCOPTT any] interface {
4963
DecodeOption[IT, DC, DCOPTT]
5064
TypeDecodeOption[IT, DC, TCOPTT]
5165
}
5266

67+
// TypeDefaultAndDecodeOption states that the option can be used in the instruct.NewTypeDecoder and
68+
// [instruct.Decoder.Decode] functions.
5369
type TypeDefaultAndDecodeOption[IT any, DC instruct.DecodeContext, TOPTT any, DCOPTT any] interface {
5470
TypeDefaultOption[IT, DC, TOPTT]
5571
DecodeOption[IT, DC, DCOPTT]
5672
}
5773

74+
// FullOption states that the option can be used in all New functions and Decode methods.
5875
type FullOption[IT any, DC instruct.DecodeContext, DOPTT any, TOPTT any, DCOPTT any, TCOPTT any] interface {
5976
DefaultOption[IT, DC, DOPTT]
6077
TypeDefaultOption[IT, DC, TOPTT]

options/option_func.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func (f DefaultOptionImpl[IT, DC, DOPTT]) ApplyDefaultOption(o *DOPTT) {
1818
f.f(o)
1919
}
2020

21+
// DefaultOptionFunc is the option constructor for DefaultOption.
2122
func DefaultOptionFunc[IT any, DC instruct.DecodeContext, DOPTT any](f func(o *DOPTT)) *DefaultOptionImpl[IT, DC, DOPTT] {
2223
return &DefaultOptionImpl[IT, DC, DOPTT]{f}
2324
}
@@ -36,6 +37,7 @@ func (f TypeDefaultOptionImpl[IT, DC, TOPTT]) ApplyTypeDefaultOption(o *TOPTT) {
3637
f.tf(o)
3738
}
3839

40+
// TypeDefaultOptionFunc is the option constructor for TypeDefaultOption.
3941
func TypeDefaultOptionFunc[IT any, DC instruct.DecodeContext, TOPTT any](tf func(o *TOPTT)) *TypeDefaultOptionImpl[IT, DC, TOPTT] {
4042
return &TypeDefaultOptionImpl[IT, DC, TOPTT]{tf}
4143
}
@@ -54,6 +56,7 @@ func (f DecodeOptionImpl[IT, DC, COPTT]) ApplyDecodeOption(o *COPTT) {
5456
f.f(o)
5557
}
5658

59+
// DecodeOptionFunc is the option constructor for DecodeOption.
5760
func DecodeOptionFunc[IT any, DC instruct.DecodeContext, COPTT any](f func(o *COPTT)) *DecodeOptionImpl[IT, DC, COPTT] {
5861
return &DecodeOptionImpl[IT, DC, COPTT]{f}
5962
}
@@ -72,6 +75,7 @@ func (f TypeDecodeOptionImpl[IT, DC, COPTT]) ApplyTypeDecodeOption(o *COPTT) {
7275
f.f(o)
7376
}
7477

78+
// TypeDecodeOptionFunc is the option constructor for TypeDecodeOption.
7579
func TypeDecodeOptionFunc[IT any, DC instruct.DecodeContext, COPTT any](f func(o *COPTT)) *TypeDecodeOptionImpl[IT, DC, COPTT] {
7680
return &TypeDecodeOptionImpl[IT, DC, COPTT]{f}
7781
}
@@ -96,6 +100,7 @@ func (f DefaultAndTypeDefaultOptionImpl[IT, DC, DOPTT, TOPTT]) ApplyTypeDefaultO
96100
f.tf(o)
97101
}
98102

103+
// DefaultAndTypeDefaultOptionFunc is the option constructor for DefaultAndTypeDefaultOption.
99104
func DefaultAndTypeDefaultOptionFunc[IT any, DC instruct.DecodeContext, DOPTT any, TOPTT any](df func(o *DOPTT), tf func(o *TOPTT)) *DefaultAndTypeDefaultOptionImpl[IT, DC, DOPTT, TOPTT] {
100105
return &DefaultAndTypeDefaultOptionImpl[IT, DC, DOPTT, TOPTT]{df, tf}
101106
}
@@ -119,6 +124,7 @@ func (f DefaultAndDecodeOptionImpl[IT, DC, TOPTT, COPTT]) ApplyDecodeOption(o *C
119124
f.cf(o)
120125
}
121126

127+
// DefaultAndDecodeOptionFunc is the option constructor for DefaultAndDecodeOption.
122128
func DefaultAndDecodeOptionFunc[IT any, DC instruct.DecodeContext, TOPTT any, COPTT any](tf func(o *TOPTT), cf func(o *COPTT)) *DefaultAndDecodeOptionImpl[IT, DC, TOPTT, COPTT] {
123129
return &DefaultAndDecodeOptionImpl[IT, DC, TOPTT, COPTT]{tf, cf}
124130
}
@@ -142,6 +148,7 @@ func (f TypeDefaultAndTypeDecodeOptionImpl[IT, DC, TOPTT, COPTT]) ApplyTypeDecod
142148
f.cf(o)
143149
}
144150

151+
// TypeDefaultAndTypeDecodeOptionFunc is the option constructor for TypeDefaultAndTypeDecodeOption.
145152
func TypeDefaultAndTypeDecodeOptionFunc[IT any, DC instruct.DecodeContext, TOPTT any, COPTT any](tf func(o *TOPTT), cf func(o *COPTT)) *TypeDefaultAndTypeDecodeOptionImpl[IT, DC, TOPTT, COPTT] {
146153
return &TypeDefaultAndTypeDecodeOptionImpl[IT, DC, TOPTT, COPTT]{tf, cf}
147154
}
@@ -166,6 +173,7 @@ func (f TypeDefaultAndDecodeOptionImpl[IT, DC, TOPTT, COPTT]) ApplyDecodeOption(
166173
f.cf(o)
167174
}
168175

176+
// TypeDefaultAndDecodeOptionFunc is the option constructor for TypeDefaultAndDecodeOption.
169177
func TypeDefaultAndDecodeOptionFunc[IT any, DC instruct.DecodeContext, TOPTT any, COPTT any](tf func(o *TOPTT), cf func(o *COPTT)) *TypeDefaultAndDecodeOptionImpl[IT, DC, TOPTT, COPTT] {
170178
return &TypeDefaultAndDecodeOptionImpl[IT, DC, TOPTT, COPTT]{tf, cf}
171179
}
@@ -200,6 +208,7 @@ func (f FullOptionImpl[IT, DC, DOPTT, TOPTT, DCOPTT, TCOPTT]) ApplyTypeDecodeOpt
200208
f.tcf(o)
201209
}
202210

211+
// FullOptionFunc is the option constructor for FullOption.
203212
func FullOptionFunc[IT any, DC instruct.DecodeContext, DOPTT any, TOPTT any, DCOPTT any, TCOPTT any](df func(o *DOPTT),
204213
tf func(o *TOPTT), dcf func(o *DCOPTT), tcf func(o *TCOPTT)) *FullOptionImpl[IT, DC, DOPTT, TOPTT, DCOPTT, TCOPTT] {
205214
return &FullOptionImpl[IT, DC, DOPTT, TOPTT, DCOPTT, TCOPTT]{df, tf, dcf, tcf}

0 commit comments

Comments
 (0)