This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
types.go
43 lines (35 loc) · 1.43 KB
/
types.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
package lcs
const (
lcsTagName = "lcs"
// maxByteSliceSize is the maximum size of byte slice that can be decoded.
//
// When decoding a byte slice, we will get the length first, and then we will allocate
// enough space according to the length. We don't want a wrong length leads to out-of-memory
// error. So maxByteSliceSize is a hard limit.
//
// It is set to 100MB by default.
maxByteSliceSize = 100 * 1024 * 1024
// sliceAndMapInitSize is the initial allocation size for non-byte slices.
//
// When decoding a non-byte slice, we will allocate an initial space, and then append to it.
sliceAndMapInitSize = 100
)
type EnumKeyType = uint64
// EnumVariant is a definition of a variant of enum type.
type EnumVariant struct {
// Name of the enum type. Different variants of a same enum type should have same name.
// This name should match the name defined in the struct field tag.
Name string
// Value is the numeric value of the enum variant. Should be unique within the same enum type.
Value EnumKeyType
// Template object for the enum variant. Should be the zero value of the variant type.
//
// Example values: (*SomeStruct)(nil), MyUint32(0).
Template interface{}
}
// EnumTypeUser is an interface of struct with enum type definition. Struct with enum type should
// implement this interface.
type EnumTypeUser interface {
// EnumTypes return the ingredients used for all enum types in the struct.
EnumTypes() []EnumVariant
}