iobuf

package
v3.80.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferedReadSeeker

type BufferedReadSeeker struct {
	// contains filtered or unexported fields
}

BufferedReadSeeker provides a buffered reading interface with seeking capabilities. It wraps an io.Reader and optionally an io.Seeker, allowing for efficient reading and seeking operations, even on non-seekable underlying readers.

func NewBufferedReaderSeeker

func NewBufferedReaderSeeker(r io.Reader) *BufferedReadSeeker

NewBufferedReaderSeeker creates and initializes a BufferedReadSeeker. It takes an io.Reader and checks if it supports seeking. If the reader supports seeking, it is stored in the seeker field.

func (*BufferedReadSeeker) DisableBuffering

func (br *BufferedReadSeeker) DisableBuffering()

DisableBuffering stops the buffering process. This is useful after initial reads (e.g., for MIME type detection and format identification) to prevent further writes to the buffer, optimizing subsequent reads.

func (*BufferedReadSeeker) Read

func (br *BufferedReadSeeker) Read(out []byte) (int, error)

Read reads len(out) bytes from the reader starting at the current index. It handles both seekable and non-seekable underlying readers efficiently.

func (*BufferedReadSeeker) ReadAt

func (br *BufferedReadSeeker) ReadAt(out []byte, offset int64) (int, error)

ReadAt reads len(out) bytes into out starting at offset off in the underlying input source. It uses Seek and Read to implement random access reading.

func (*BufferedReadSeeker) Seek

func (br *BufferedReadSeeker) Seek(offset int64, whence int) (int64, error)

Seek sets the offset for the next Read or Write to offset. It supports both seekable and non-seekable underlying readers.

Jump to

Keyboard shortcuts

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