MCPcopy Create free account
hub / github.com/apache/thrift / ReadString

Method ReadString

lib/go/thrift/binary_protocol.go:467–487  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

465}
466
467func (p *TBinaryProtocol) ReadString(ctx context.Context) (value string, err error) {
468 size, e := p.ReadI32(ctx)
469 if e != nil {
470 return "", e
471 }
472 err = checkSizeForProtocol(size, p.cfg)
473 if err != nil {
474 return
475 }
476 if size == 0 {
477 return "", nil
478 }
479 if size < int32(len(p.buffer)) {
480 // Avoid allocation on small reads
481 buf := p.buffer[:size]
482 read, e := io.ReadFull(p.trans, buf)
483 return string(buf[:read]), NewTProtocolException(e)
484 }
485
486 return p.readStringBody(size)
487}
488
489func (p *TBinaryProtocol) ReadBinary(ctx context.Context) ([]byte, error) {
490 size, e := p.ReadI32(ctx)

Callers 1

ReadMessageBeginMethod · 0.95

Calls 5

ReadI32Method · 0.95
readStringBodyMethod · 0.95
checkSizeForProtocolFunction · 0.85
stringFunction · 0.85
NewTProtocolExceptionFunction · 0.85

Tested by

no test coverage detected