Documentation
¶
Index ¶
- func ReadBytesLimitedPrealloc(r io.Reader, size uint64) ([]byte, error)
- func ReadStringLimitedPrealloc(r io.Reader, size uint64) (string, error)
- type ByteReader
- type SubReader
- func (b *SubReader) Available() int
- func (b *SubReader) Consumed() int
- func (b *SubReader) Deflate() (*SubReader, int, error)
- func (b *SubReader) Empty() bool
- func (b *SubReader) HasAtLeast(n int) bool
- func (b *SubReader) Peek(w io.Writer, n int) error
- func (b *SubReader) Read(p []byte) (n int, err error)
- func (b *SubReader) ReadByte() (byte, error)
- func (b *SubReader) Skip(n int) error
- func (b *SubReader) SubReader(offset uint64, size uint64) (*SubReader, error)
- func (b *SubReader) SubReaderOffset(offset uint64) (*SubReader, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ByteReader ¶
type ByteReader interface {
io.Reader
io.ByteReader
}
func TeeReader ¶
func TeeReader(r ByteReader, w io.Writer) ByteReader
TeeReader returns a [Reader] that writes to w what it reads from r. All reads from r performed through it are matched with corresponding writes to w. There is no internal buffering - the write must complete before the read completes. Any error encountered while writing is reported as a read error.
type SubReader ¶
type SubReader struct {
// contains filtered or unexported fields
}
SubReader is a zero-copy reader over a []byte. All sub-reader views share the same backing slice; no copies are made on fork or sub-view creation.
*SubReader is a live, shared cursor: mutations through one pointer are visible to all holders. Copying the value (SubReader, not *SubReader) snapshots the cursor at its current position — equivalent to a fork — without any allocation. Callers that want an independent cursor should copy the value rather than the pointer.
func NewSubReader ¶
NewSubReader creates a SubReader over data. data is not copied.
func (*SubReader) Consumed ¶
Consumed returns the total bytes advanced via Read or Skip since creation.
func (*SubReader) Deflate ¶
Deflate decompresses the remaining bytes using DEFLATE and returns a new SubReader over the decompressed data and the decompressed size.
func (*SubReader) HasAtLeast ¶
HasAtLeast reports whether at least n bytes remain.