-
Notifications
You must be signed in to change notification settings - Fork 12
/
datastore_get_specific_meta_info_v1.go
143 lines (113 loc) · 4.77 KB
/
datastore_get_specific_meta_info_v1.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Package types implements all the types used by the DataStore protocol
package types
import (
"fmt"
"strings"
"github.com/PretendoNetwork/nex-go"
)
// DataStoreSpecificMetaInfoV1 is a data structure used by the DataStore protocol
type DataStoreSpecificMetaInfoV1 struct {
nex.Structure
DataID uint32
OwnerID uint32
Size uint32
DataType uint16
Version uint16
}
// ExtractFromStream extracts a DataStoreSpecificMetaInfoV1 structure from a stream
func (dataStoreSpecificMetaInfoV1 *DataStoreSpecificMetaInfoV1) ExtractFromStream(stream *nex.StreamIn) error {
var err error
dataStoreSpecificMetaInfoV1.DataID, err = stream.ReadUInt32LE()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreSpecificMetaInfoV1.DataID. %s", err.Error())
}
dataStoreSpecificMetaInfoV1.OwnerID, err = stream.ReadUInt32LE()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreSpecificMetaInfoV1.OwnerID. %s", err.Error())
}
dataStoreSpecificMetaInfoV1.Size, err = stream.ReadUInt32LE()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreSpecificMetaInfoV1.Size. %s", err.Error())
}
dataStoreSpecificMetaInfoV1.DataType, err = stream.ReadUInt16LE()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreSpecificMetaInfoV1.DataType. %s", err.Error())
}
dataStoreSpecificMetaInfoV1.Version, err = stream.ReadUInt16LE()
if err != nil {
return fmt.Errorf("Failed to extract DataStoreSpecificMetaInfoV1.Version. %s", err.Error())
}
return nil
}
// Bytes encodes the DataStoreSpecificMetaInfoV1 and returns a byte array
func (dataStoreSpecificMetaInfoV1 *DataStoreSpecificMetaInfoV1) Bytes(stream *nex.StreamOut) []byte {
stream.WriteUInt32LE(dataStoreSpecificMetaInfoV1.DataID)
stream.WriteUInt32LE(dataStoreSpecificMetaInfoV1.OwnerID)
stream.WriteUInt32LE(dataStoreSpecificMetaInfoV1.Size)
stream.WriteUInt16LE(dataStoreSpecificMetaInfoV1.DataType)
stream.WriteUInt16LE(dataStoreSpecificMetaInfoV1.Version)
return stream.Bytes()
}
// Copy returns a new copied instance of DataStoreSpecificMetaInfoV1
func (dataStoreSpecificMetaInfoV1 *DataStoreSpecificMetaInfoV1) Copy() nex.StructureInterface {
copied := NewDataStoreSpecificMetaInfoV1()
copied.SetStructureVersion(dataStoreSpecificMetaInfoV1.StructureVersion())
copied.DataID = dataStoreSpecificMetaInfoV1.DataID
copied.OwnerID = dataStoreSpecificMetaInfoV1.OwnerID
copied.Size = dataStoreSpecificMetaInfoV1.Size
copied.DataType = dataStoreSpecificMetaInfoV1.DataType
copied.Version = dataStoreSpecificMetaInfoV1.Version
return copied
}
// Equals checks if the passed Structure contains the same data as the current instance
func (dataStoreSpecificMetaInfoV1 *DataStoreSpecificMetaInfoV1) Equals(structure nex.StructureInterface) bool {
other := structure.(*DataStoreSpecificMetaInfoV1)
if dataStoreSpecificMetaInfoV1.StructureVersion() != other.StructureVersion() {
return false
}
if dataStoreSpecificMetaInfoV1.DataID != other.DataID {
return false
}
if dataStoreSpecificMetaInfoV1.OwnerID != other.OwnerID {
return false
}
if dataStoreSpecificMetaInfoV1.Size != other.Size {
return false
}
if dataStoreSpecificMetaInfoV1.DataType != other.DataType {
return false
}
if dataStoreSpecificMetaInfoV1.Version != other.Version {
return false
}
return true
}
// String returns a string representation of the struct
func (dataStoreSpecificMetaInfoV1 *DataStoreSpecificMetaInfoV1) String() string {
return dataStoreSpecificMetaInfoV1.FormatToString(0)
}
// FormatToString pretty-prints the struct data using the provided indentation level
func (dataStoreSpecificMetaInfoV1 *DataStoreSpecificMetaInfoV1) FormatToString(indentationLevel int) string {
indentationValues := strings.Repeat("\t", indentationLevel+1)
indentationEnd := strings.Repeat("\t", indentationLevel)
var b strings.Builder
b.WriteString("DataStoreSpecificMetaInfoV1{\n")
b.WriteString(fmt.Sprintf("%sstructureVersion: %d,\n", indentationValues, dataStoreSpecificMetaInfoV1.StructureVersion()))
b.WriteString(fmt.Sprintf("%sDataID: %d,\n", indentationValues, dataStoreSpecificMetaInfoV1.DataID))
b.WriteString(fmt.Sprintf("%sOwnerID: %d,\n", indentationValues, dataStoreSpecificMetaInfoV1.OwnerID))
b.WriteString(fmt.Sprintf("%sSize: %d,\n", indentationValues, dataStoreSpecificMetaInfoV1.Size))
b.WriteString(fmt.Sprintf("%sDataType: %d,\n", indentationValues, dataStoreSpecificMetaInfoV1.DataType))
b.WriteString(fmt.Sprintf("%sVersion: %d\n", indentationValues, dataStoreSpecificMetaInfoV1.Version))
b.WriteString(fmt.Sprintf("%s}", indentationEnd))
return b.String()
}
// NewDataStoreSpecificMetaInfoV1 returns a new DataStoreSpecificMetaInfoV1
func NewDataStoreSpecificMetaInfoV1() *DataStoreSpecificMetaInfoV1 {
return &DataStoreSpecificMetaInfoV1{
DataID: 0,
OwnerID: 0,
Size: 0,
DataType: 0,
Version: 0,
}
}