MCPcopy
hub / github.com/pquerna/ffjson / Read

Method Read

fflib/v1/buffer.go:304–316  ·  view source on GitHub ↗

Read reads the next len(p) bytes from the buffer or until the buffer is drained. The return value n is the number of bytes read. If the buffer has no data to return, err is io.EOF (unless len(p) is zero); otherwise it is nil.

(p []byte)

Source from the content-addressed store, hash-verified

302// buffer has no data to return, err is io.EOF (unless len(p) is zero);
303// otherwise it is nil.
304func (b *Buffer) Read(p []byte) (n int, err error) {
305 if b.off >= len(b.buf) {
306 // Buffer is empty, reset to recover space.
307 b.Truncate(0)
308 if len(p) == 0 {
309 return
310 }
311 return 0, io.EOF
312 }
313 n = copy(p, b.buf[b.off:])
314 b.off += n
315 return
316}
317
318// Next returns a slice containing the next n bytes from the buffer,
319// advancing the buffer as if the bytes had been returned by Read.

Callers 1

ReadFromMethod · 0.80

Calls 1

TruncateMethod · 0.95

Tested by

no test coverage detected