Documentation
¶
Index ¶
Constants ¶
const ( ListElementSize_Small = 2 ListElementSize_Big = 4 )
const ( MessageFieldSize_Small = 1 + 2 // tag(1) + offset(2) MessageFieldSize_Big = 2 + 4 // tag(2) + offset(4) )
const (
MaxSize = math.MaxInt32
)
Variables ¶
This section is empty.
Functions ¶
func IsBigList ¶
func IsBigList(elements []ListElement) bool
IsBigList returns true if table count > uint8 or element offset > uint16.
func IsBigMessage ¶
func IsBigMessage(fields []MessageField) bool
IsBigList returns true if any field tag > uint8 or offset > uint16.
Types ¶
type Bytes ¶
type Bytes []byte
Bytes is a spec byte slice backed by a buffer. Clone it if you need to keep it around.
type ListElement ¶
type ListElement struct {
Offset uint32
}
ListElement specifies a value offset in a list byte array.
+-------------------+ | offset(2/4) | +-------------------+
func TestElements ¶
func TestElements() []ListElement
func TestElementsN ¶
func TestElementsN(n int) []ListElement
func TestElementsSize ¶
func TestElementsSize(big bool) []ListElement
func TestElementsSizeN ¶
func TestElementsSizeN(big bool, n int) []ListElement
type ListTable ¶
type ListTable struct {
// contains filtered or unexported fields
}
ListTable is a serialized array of list element offsets ordered by index. The serialization format depends on whether the list is big or small, see IsBigList().
+----------------+----------------+----------------+ | off0(2/4) | off1(2/4) | off2(2/4) | +----------------+----------------+----------------+
func NewListTable ¶
func (ListTable) Elements ¶
func (t ListTable) Elements() []ListElement
Elements parses the table and returns a slice of elements.
type MessageField ¶
MessageField specifies a tag and a value offset in a message byte array.
+----------+-------------------+ | tag(1/2) | offset(2/4) | +----------+-------------------+
func TestFields ¶
func TestFields() []MessageField
func TestFieldsN ¶
func TestFieldsN(n int) []MessageField
func TestFieldsSize ¶
func TestFieldsSize(big bool) []MessageField
func TestFieldsSizeN ¶
func TestFieldsSizeN(big bool, n int) []MessageField
type MessageTable ¶
type MessageTable struct {
// contains filtered or unexported fields
}
MessageTable is a table of message fields ordered by tags. The serialization format depends on whether the message is big or small, see isBigMessage().
field0 field1 field2 +---------------------+---------------------+---------------------+ | tag0 | offset0 | tag1 | offset1 | tag2 | offset3 | +---------------------+---------------------+---------------------+
func NewMessageTable ¶
func NewMessageTable(table messageTable, data uint32, big bool) MessageTable
func (MessageTable) DataSize ¶
func (t MessageTable) DataSize() uint32
DataSize returns the message data size.
func (MessageTable) Field ¶
func (t MessageTable) Field(i int) (MessageField, bool)
Field returns a field by an index or false,
func (MessageTable) Fields ¶
func (t MessageTable) Fields() []MessageField
Fields parses the table and returns a slice of fields.
func (MessageTable) Len ¶
func (t MessageTable) Len() int
Len returns the number of fields in the message.
func (MessageTable) Offset ¶
func (t MessageTable) Offset(tag uint16) int
Offset returns field end offset by a tag or -1.
func (MessageTable) OffsetByIndex ¶
func (t MessageTable) OffsetByIndex(i int) int
OffsetByIndex returns field end offset by an index or -1.
type String ¶
type String string
String is a spec string backed by a buffer. Clone it if you need to keep it around.
type Type ¶
type Type byte
Type specifies a value type.
const ( TypeUndefined Type = 0 TypeTrue Type = 01 TypeFalse Type = 02 TypeByte Type = 03 TypeInt16 Type = 10 TypeInt32 Type = 11 TypeInt64 Type = 12 TypeUint16 Type = 20 TypeUint32 Type = 21 TypeUint64 Type = 22 TypeFloat32 Type = 40 TypeFloat64 Type = 41 TypeBin64 Type = 30 TypeBin128 Type = 31 TypeBin256 Type = 32 TypeBytes Type = 50 TypeString Type = 60 TypeList Type = 70 TypeBigList Type = 71 TypeMessage Type = 80 TypeBigMessage Type = 81 TypeStruct Type = 90 )