Reads a []byte (via readBinary), and then UTF-8 decodes it.
(ctx context.Context)
| 613 | |
| 614 | // Reads a []byte (via readBinary), and then UTF-8 decodes it. |
| 615 | func (p *TCompactProtocol) ReadString(ctx context.Context) (value string, err error) { |
| 616 | length, e := p.readVarint32() |
| 617 | if e != nil { |
| 618 | return "", NewTProtocolException(e) |
| 619 | } |
| 620 | err = checkSizeForProtocol(length, p.cfg) |
| 621 | if err != nil { |
| 622 | return |
| 623 | } |
| 624 | if length == 0 { |
| 625 | return "", nil |
| 626 | } |
| 627 | if length < int32(len(p.buffer)) { |
| 628 | // Avoid allocation on small reads |
| 629 | buf := p.buffer[:length] |
| 630 | read, e := io.ReadFull(p.trans, buf) |
| 631 | return string(buf[:read]), NewTProtocolException(e) |
| 632 | } |
| 633 | |
| 634 | buf, e := safeReadBytes(length, p.trans) |
| 635 | return string(buf), NewTProtocolException(e) |
| 636 | } |
| 637 | |
| 638 | // Read a []byte from the wire. |
| 639 | func (p *TCompactProtocol) ReadBinary(ctx context.Context) (value []byte, err error) { |
no test coverage detected