EncodeObject encode the object to binary
(obj *Object)
| 8 | |
| 9 | // EncodeObject encode the object to binary |
| 10 | func 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 |
| 21 | func DecodeObject(b []byte) (obj *Object, err error) { |
no outgoing calls