forked from coming-chat/lcs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
37 lines (29 loc) · 1.17 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
package bcs
const (
bcsTagName = "bcs"
/// Variable length sequences in BCS are limited to max length of 2^31 - 1.
maxSequenceLength = 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
}