-
Notifications
You must be signed in to change notification settings - Fork 4
/
helpers.go
54 lines (45 loc) · 1.28 KB
/
helpers.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
package tarantool
import (
"github.com/vmihailenco/msgpack/v5"
)
// IntKey is utility type for passing integer key to Select, Update and Delete.
// It serializes to array with single integer element.
type IntKey struct {
I int64
}
func (k IntKey) EncodeMsgpack(enc *msgpack.Encoder) error {
_ = enc.EncodeArrayLen(1)
_ = enc.EncodeInt(k.I)
return nil
}
// UintKey is utility type for passing unsigned integer key to Select, Update and Delete.
// It serializes to array with single integer element.
type UintKey struct {
I uint64
}
func (k UintKey) EncodeMsgpack(enc *msgpack.Encoder) error {
_ = enc.EncodeArrayLen(1)
_ = enc.EncodeUint(k.I)
return nil
}
// StringKey is utility type for passing string key to Select, Update and Delete.
// It serializes to array with single string element.
type StringKey struct {
S string
}
func (k StringKey) EncodeMsgpack(enc *msgpack.Encoder) error {
_ = enc.EncodeArrayLen(1)
_ = enc.EncodeString(k.S)
return nil
}
// IntIntKey is utility type for passing two integer keys to Select, Update and Delete.
// It serializes to array with two integer elements
type IntIntKey struct {
I1, I2 int64
}
func (k IntIntKey) EncodeMsgpack(enc *msgpack.Encoder) error {
_ = enc.EncodeArrayLen(2)
_ = enc.EncodeInt(k.I1)
_ = enc.EncodeInt(k.I2)
return nil
}