-
Notifications
You must be signed in to change notification settings - Fork 95
/
feat_metadata.gen.go
91 lines (71 loc) · 2 KB
/
feat_metadata.gen.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
package iotago
// Code generated by go generate; DO NOT EDIT. Check gen/ directory instead.
import (
"bytes"
"cmp"
"github.com/iotaledger/hive.go/lo"
"github.com/iotaledger/hive.go/serializer/v2"
)
type MetadataFeatureEntriesKey string
type MetadataFeatureEntriesValue []byte
type MetadataFeatureEntries map[MetadataFeatureEntriesKey]MetadataFeatureEntriesValue
// MetadataFeature is a feature which holds a map of key-value pairs.
// The keys must consist of ASCII characters only.
// The values are arbitrary byte slices.
type MetadataFeature struct {
Entries MetadataFeatureEntries `serix:""`
}
func (m MetadataFeature) Clone() Feature {
copiedMap := make(MetadataFeatureEntries)
for key, value := range m.Entries {
copiedMap[key] = lo.CopySlice(value)
}
return &MetadataFeature{
Entries: copiedMap,
}
}
func (m MetadataFeature) StorageScore(_ *StorageScoreStructure, _ StorageScoreFunc) StorageScore {
return 0
}
func (m MetadataFeature) WorkScore(_ *WorkScoreParameters) (WorkScore, error) {
return 0, nil
}
func (m MetadataFeature) Compare(other Feature) int {
return cmp.Compare(m.Type(), other.Type())
}
func (m MetadataFeature) Equal(other Feature) bool {
otherFeat, is := other.(*MetadataFeature)
if !is {
return false
}
if len(m.Entries) != len(otherFeat.Entries) {
return false
}
for key, value := range m.Entries {
otherValue, exists := otherFeat.Entries[key]
if !exists {
return false
}
if !bytes.Equal(value, otherValue) {
return false
}
}
return true
}
func (m MetadataFeature) Type() FeatureType {
return FeatureMetadata
}
func (m MetadataFeature) mapSize() int {
var size int
// Map Length
size += serializer.SmallTypeDenotationByteSize
for key, value := range m.Entries {
// Key Length + Key + Value Length + Value
size += serializer.SmallTypeDenotationByteSize + len(key) + serializer.UInt16ByteSize + len(value)
}
return size
}
func (m MetadataFeature) Size() int {
// FeatureType + Entries
return serializer.SmallTypeDenotationByteSize + m.mapSize()
}