-
Notifications
You must be signed in to change notification settings - Fork 2
/
primitive_exporters.go
59 lines (46 loc) · 1.14 KB
/
primitive_exporters.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
package exporters
import (
"fmt"
"database/sql/driver"
"github.com/emacsway/grade/grade/internal/domain/seedwork/uuid"
)
type ExporterSetter[T any] interface {
SetState(T)
}
type Exportable[T any] interface {
Export(ExporterSetter[T])
}
type Uint8Exporter uint8
func (ex *Uint8Exporter) SetState(value uint8) {
*ex = Uint8Exporter(value)
}
func (ex Uint8Exporter) Value() (driver.Value, error) {
return uint8(ex), nil
}
func (ex Uint8Exporter) String() string {
return fmt.Sprintf("%d", uint8(ex))
}
type UintExporter uint
func (ex *UintExporter) SetState(value uint) {
*ex = UintExporter(value)
}
func (ex UintExporter) Value() (driver.Value, error) {
return uint(ex), nil
}
func (ex UintExporter) String() string {
return fmt.Sprintf("%d", uint(ex))
}
type UuidExporter uuid.Uuid
func (ex *UuidExporter) SetState(value uuid.Uuid) {
*ex = UuidExporter(value)
}
func (ex UuidExporter) Value() (driver.Value, error) {
return uuid.Uuid(ex).Value()
}
type StringExporter string
func (ex *StringExporter) SetState(value string) {
*ex = StringExporter(value)
}
func (ex StringExporter) Value() (driver.Value, error) {
return string(ex), nil
}