Decode decodes the given header from the provided byte slice. Returns the number of bytes read.
(buf []byte)
| 94 | // Decode decodes the given header from the provided byte slice. |
| 95 | // Returns the number of bytes read. |
| 96 | func (h *header) Decode(buf []byte) int { |
| 97 | h.meta, h.userMeta = buf[0], buf[1] |
| 98 | index := 2 |
| 99 | klen, count := binary.Uvarint(buf[index:]) |
| 100 | h.klen = uint32(klen) |
| 101 | index += count |
| 102 | vlen, count := binary.Uvarint(buf[index:]) |
| 103 | h.vlen = uint32(vlen) |
| 104 | index += count |
| 105 | h.expiresAt, count = binary.Uvarint(buf[index:]) |
| 106 | return index + count |
| 107 | } |
| 108 | |
| 109 | // DecodeFrom reads the header from the hashReader. |
| 110 | // Returns the number of bytes read. |
no outgoing calls
no test coverage detected