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)
| 465 | // the reader and returns the value as a []byte. It uses |
| 466 | // scratch for storage if it is large enough. |
| 467 | func (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 |