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

Method Array

encoding/resp/resp.go:248–268  ·  view source on GitHub ↗

Array parses a RESP array

()

Source from the content-addressed store, hash-verified

246
247//Array parses a RESP array
248func (r *Decoder) Array() (int, error) {
249 hdr, err := r.r.ReadBytes('\n')
250 if err != nil {
251 return -1, err
252 }
253 l := len(hdr)
254 if l < len("*\r\n") {
255 return -1, ErrInvalidProtocol
256 }
257 if hdr[l-2] != '\r' {
258 return -1, ErrInvalidProtocol
259 }
260 if hdr[0] != '*' {
261 return -1, ErrInvalidProtocol
262 }
263 remain, err := strconv.Atoi(string(hdr[1 : l-2]))
264 if err != nil || remain < 0 {
265 return -1, ErrInvalidProtocol
266 }
267 return remain, nil
268}
269
270//Integer parses a RESP integer
271func (r *Decoder) Integer() (int64, error) {

Callers 1

TestArray_DecodeFunction · 0.95

Implementers 2

Encoderencoding/resp/resp.go
Decoderencoding/resp/resp.go

Calls 1

ReadBytesMethod · 0.80

Tested by 1

TestArray_DecodeFunction · 0.76