MCPcopy
hub / github.com/tinylib/msgp / ReadMapKey

Method ReadMapKey

msgp/read.go:467–480  ·  view source on GitHub ↗

ReadMapKey reads either a 'str' or 'bin' field from the reader and returns the value as a []byte. It uses scratch for storage if it is large enough.

(scratch []byte)

Source from the content-addressed store, hash-verified

465// the reader and returns the value as a []byte. It uses
466// scratch for storage if it is large enough.
467func (m *Reader) ReadMapKey(scratch []byte) ([]byte, error) {
468 out, err := m.ReadStringAsBytes(scratch)
469 if err != nil {
470 if tperr, ok := err.(TypeError); ok && tperr.Encoded == BinType {
471 key, err := m.ReadBytes(scratch)
472 if uint64(len(key)) > m.GetMaxStringLength() {
473 return nil, ErrLimitExceeded
474 }
475 return key, err
476 }
477 return nil, err
478 }
479 return out, nil
480}
481
482// ReadMapKeyPtr returns a []byte pointing to the contents
483// of a valid map key. The key cannot be empty, and it

Callers 2

FuzzReaderFunction · 0.95
checkExtMinusOneFunction · 0.95

Calls 3

ReadStringAsBytesMethod · 0.95
ReadBytesMethod · 0.95
GetMaxStringLengthMethod · 0.95

Tested by 2

FuzzReaderFunction · 0.76
checkExtMinusOneFunction · 0.76