bufseek

package
v0.0.0-...-290725f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 3 Imported by: 0

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

func (b *Reader) Buffered() int

Buffered returns the number of bytes that can be read from the current buffer.

func (*Reader) Read

func (b *Reader) 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 (*Reader) ReadByte

func (b *Reader) ReadByte() (byte, error)

ReadByte reads and returns a single byte. If no byte is available, returns an error.

func (*Reader) Seek

func (b *Reader) Seek(offset int64, whence int) (pos int64, err error)

Seek sets the offset for the next Read to offset, interpreted according to whence; see the io.Seeker docs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL