-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.go
More file actions
61 lines (46 loc) · 1.18 KB
/
parser.go
File metadata and controls
61 lines (46 loc) · 1.18 KB
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
package gsr
// Serializer interface definition
type Serializer interface {
Serialize(v any) ([]byte, error)
Deserialize(data []byte, v any) error
}
// GoSerializer interface definition
type GoSerializer interface {
Marshal(v any) ([]byte, error)
Unmarshal(v []byte, ptr any) error
}
// DataParser interface
// Deperacted
type DataParser = GoSerializer
// Codec interface definition
type Codec interface {
Decode(blob []byte, v any) (err error)
Encode(v any) (out []byte, err error)
}
//
//
//
// Marshaler interface
type Marshaler interface {
Marshal(v any) ([]byte, error)
}
// Unmarshaler interface
type Unmarshaler interface {
Unmarshal(v []byte, ptr any) error
}
// MarshalFunc define
type MarshalFunc func(v any) ([]byte, error)
// Marshal implements the Marshaler
func (m MarshalFunc) Marshal(v any) ([]byte, error) {
return m(v)
}
// UnmarshalFunc define
type UnmarshalFunc func(v []byte, ptr any) error
// Unmarshal implements the Unmarshaler
func (u UnmarshalFunc) Unmarshal(v []byte, ptr any) error {
return u(v, ptr)
}
// DecodeFunc definition
type DecodeFunc func(blob []byte, v any) (err error)
// EncodeFunc definition
type EncodeFunc func(v any) (out []byte, err error)