-
Notifications
You must be signed in to change notification settings - Fork 6
/
interface.go
38 lines (31 loc) · 1.06 KB
/
interface.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
// Package serialize for transforming between json serialized []byte and go structs
package serialize
const TypeInt = 1
const TypeString = ``
const TypeBool = true
type (
// Serializer generic interface for serializing
Serializer interface {
ToBytesConverter
FromBytesConverter
}
Serializable interface {
ToBytes(ToBytesConverter) ([]byte, error)
}
// FromByter interface supports FromBytes func for converting from slice of bytes to some defined target type
FromByter interface {
FromBytes([]byte) (interface{}, error)
}
// ToByter interface supports ToBytes func for converting to slice of bytes from source type
ToByter interface {
ToBytes() ([]byte, error)
}
// FromBytesConverter interface supports FromBytesConverter func for converting from slice of bytes to target type
FromBytesConverter interface {
FromBytesTo(from []byte, target interface{}) (interface{}, error)
}
// ToBytesConverter supports ToBytesConverter func converting from some interface to bytes
ToBytesConverter interface {
ToBytesFrom(from interface{}) ([]byte, error)
}
)