blob: ec125a348af276877e7f03a572ecfc1a173c85ea (
plain)
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
|
package libolmpickle
import (
"encoding/binary"
)
func PickleUInt8(value uint8, target []byte) int {
target[0] = value
return 1
}
func PickleUInt8Len(value uint8) int {
return 1
}
func PickleBool(value bool, target []byte) int {
if value {
target[0] = 0x01
} else {
target[0] = 0x00
}
return 1
}
func PickleBoolLen(value bool) int {
return 1
}
func PickleBytes(value, target []byte) int {
return copy(target, value)
}
func PickleBytesLen(value []byte) int {
return len(value)
}
func PickleUInt32(value uint32, target []byte) int {
res := make([]byte, 4) //4 bytes for int32
binary.BigEndian.PutUint32(res, value)
return copy(target, res)
}
func PickleUInt32Len(value uint32) int {
return 4
}
|