Encode encodes the header into []byte. The provided []byte should be atleast 5 bytes. The function will panic if out []byte isn't large enough to hold all the values. The encoded header looks like +------+----------+------------+--------------+-----------+ | Meta | UserMeta | Key Length | Value Leng
(out []byte)
| 83 | // | Meta | UserMeta | Key Length | Value Length | ExpiresAt | |
| 84 | // +------+----------+------------+--------------+-----------+ |
| 85 | func (h header) Encode(out []byte) int { |
| 86 | out[0], out[1] = h.meta, h.userMeta |
| 87 | index := 2 |
| 88 | index += binary.PutUvarint(out[index:], uint64(h.klen)) |
| 89 | index += binary.PutUvarint(out[index:], uint64(h.vlen)) |
| 90 | index += binary.PutUvarint(out[index:], h.expiresAt) |
| 91 | return index |
| 92 | } |
| 93 | |
| 94 | // Decode decodes the given header from the provided byte slice. |
| 95 | // Returns the number of bytes read. |
no outgoing calls
no test coverage detected