-
Notifications
You must be signed in to change notification settings - Fork 0
/
resolve_value.go
31 lines (23 loc) · 1.01 KB
/
resolve_value.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
package debefix
import "context"
// ResolveValue is a value that should be resolved by the user of the library in a callback.
// Usually this is used to return values generated by the database, like last insert id or created date.
type ResolveValue interface {
ResolveValueParse(ctx context.Context, value any) (any, error)
}
// ResolveValueFunc is a functional implementation of ResolveValue.
type ResolveValueFunc func(ctx context.Context, value any) (any, error)
func (f ResolveValueFunc) ResolveValueParse(ctx context.Context, value any) (any, error) {
return f(ctx, value)
}
// ResolveValueResolveData is a value to be resolved, without any parsing.
type ResolveValueResolveData struct {
}
var _ ResolveValue = ResolveValueResolveData{}
// ResolveValueResolve is a value to be resolved, without any parsing.
func ResolveValueResolve() ResolveValueResolveData {
return ResolveValueResolveData{}
}
func (v ResolveValueResolveData) ResolveValueParse(ctx context.Context, value any) (any, error) {
return value, nil
}