Documentation
¶
Overview ¶
zerocopy.Reader gives a reading interface for a byte slice or a file, which doesn't make a copy of the underlying byte slice. To achieve this, a new "Read" interface is required, where the data storage is not specified by the caller, but by the callee. This is so that the implementation is at liberty to return a byte slice
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReadCloser ¶
func NewReader ¶
func NewReader(r io.Reader) (ReadCloser, error)
Construct a new Zero-Copy reader on `r`. `r` must be an *os.File or a *bytes.Reader, otherwise an error is returned.
func NewReaderFromBytes ¶
func NewReaderFromBytes(b []byte) (ReadCloser, error)
Helper to construct a zero-copy reader directly from a byte slice.
type Reader ¶
type Reader interface {
// Read `size` bytes from the underlying stream, and return a byte slice
// to those bytes. The returned []byte is a slice which references the
// underlying bytes, and must not be written to.
Read(size uint64) ([]byte, error)
}
The zero-copy Reader interface. It has a different Read() method than the usual because the semantics are different.
Click to show internal directories.
Click to hide internal directories.