MCPcopy Create free account
hub / github.com/distributedio/titan / EncodeObject

Function EncodeObject

db/codec.go:10–18  ·  view source on GitHub ↗

EncodeObject encode the object to binary

(obj *Object)

Source from the content-addressed store, hash-verified

8
9// EncodeObject encode the object to binary
10func EncodeObject(obj *Object) []byte {
11 b := make([]byte, 42)
12 copy(b, obj.ID[:16])
13 binary.BigEndian.PutUint64(b[16:], uint64(obj.CreatedAt))
14 binary.BigEndian.PutUint64(b[24:], uint64(obj.UpdatedAt))
15 binary.BigEndian.PutUint64(b[32:], uint64(obj.ExpireAt))
16 b[40], b[41] = byte(obj.Type), byte(obj.Encoding)
17 return b
18}
19
20// DecodeObject decode the object from binary
21func DecodeObject(b []byte) (obj *Object, err error) {

Callers 9

MarshalMethod · 0.85
encodeSetMetaFunction · 0.85
EncodeHashMetaFunction · 0.85
ExpireAtMethod · 0.85
TouchMethod · 0.85
encodeMethod · 0.85
MarshalMethod · 0.85
encodeMetaMethod · 0.85
TestCodecObjectFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestCodecObjectFunction · 0.68