Documentation ¶
Overview ¶
Package bufseek provides a buffered io.Reader that also implements io.Seeker.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReadWriter ¶
type ReadWriter struct {
// contains filtered or unexported fields
}
ReadWriter implements buffering for an io.ReadWriter or an io.ReadWriteSeeker object.
func NewReadWriter ¶
func NewReadWriter(rw io.ReadWriteSeeker) *ReadWriter
NewReadWriter returns a new ReadWriter that has the default size.
func NewReadWriterSize ¶
func NewReadWriterSize(rw io.ReadWriteSeeker, size int) *ReadWriter
NewReadWriterSize returns a new ReadWriter whose buffer has at least the specified size. If the argument io.ReadWriter is already a *ReadWriter with large enough size, it returns the underlying *ReadWriter.
func (*ReadWriter) Read ¶
func (b *ReadWriter) Read(p []byte) (n int, err error)
Read reads data into p. It returns the number of bytes read into p. The bytes are taken from at most one Read on the underlying Reader, hence n may be less than len(p). To read exactly len(p) bytes, use io.ReadFull(b, p). If the underlying Reader can return a non-zero count with io.EOF, then this Read method can do so as well; see the io.Reader docs.
func (*ReadWriter) ReadByte ¶
func (b *ReadWriter) ReadByte() (byte, error)
ReadByte reads and returns a single byte. If no byte is available, returns an error.
func (*ReadWriter) Seek ¶
func (b *ReadWriter) Seek(offset int64, whence int) (int64, error)
Seek sets the offset for the next Read to offset, interpreted according to whence; see the io.Seeker docs.
func (*ReadWriter) Write ¶
func (b *ReadWriter) Write(p []byte) (n int, err error)
Write writes data from p. It returns the number of bytes written from p and any error encountered that caused the write to stop early.
func (*ReadWriter) WriteString ¶
func (b *ReadWriter) WriteString(s string) (n int, err error)
WriteString writes data from s. It returns the number of bytes written from s and any error encountered that caused the write to stop early.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader implements buffering for an io.ReadSeeker object.
func NewReader ¶
func NewReader(rd io.ReadSeeker) *Reader
NewReader returns a new Reader whose buffer has the default size.
func NewReaderSize ¶
func NewReaderSize(rd io.ReadSeeker, size int) *Reader
NewReaderSize returns a new Reader whose buffer has at least the specified size. If the argument io.Reader is already a *Reader or *ReadWriter with large enough size, it returns the underlying *Reader.
func (*Reader) Buffered ¶
Buffered returns the number of bytes that can be read from the current buffer.
func (*Reader) Read ¶
Read reads data into p. It returns the number of bytes read into p. The bytes are taken from at most one Read on the underlying Reader, hence n may be less than len(p). To read exactly len(p) bytes, use io.ReadFull(b, p). If the underlying Reader can return a non-zero count with io.EOF, then this Read method can do so as well; see the io.Reader docs.