filebuffer

package
v1.24.0-dev Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidMemorySize occurs if the memory size is not in a valid range
	ErrInvalidMemorySize = errors.New("Memory size must be greater 0 and lower math.MaxInt32")
	// ErrWriteAfterRead occurs if Write is called after a read operation
	ErrWriteAfterRead = errors.New("Write is unsupported after a read operation")
)

Functions

This section is empty.

Types

type FileBackedBuffer

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

FileBackedBuffer uses a memory buffer with a fixed size. If more data is written a temporary file is used instead. It implements io.ReadWriteCloser, io.ReadSeekCloser and io.ReaderAt

func CreateFromReader

func CreateFromReader(r io.Reader, maxMemorySize int) (*FileBackedBuffer, error)

CreateFromReader creates a file backed buffer and copies the provided reader data into it.

func New

func New(maxMemorySize int) (*FileBackedBuffer, error)

New creates a file backed buffer with a specific maximum memory size

func (*FileBackedBuffer) Close

func (b *FileBackedBuffer) Close() error

Close implements io.Closer

func (*FileBackedBuffer) Read

func (b *FileBackedBuffer) Read(p []byte) (int, error)

Read implements io.Reader

func (*FileBackedBuffer) ReadAt

func (b *FileBackedBuffer) ReadAt(p []byte, off int64) (int, error)

ReadAt implements io.ReaderAt

func (*FileBackedBuffer) Seek

func (b *FileBackedBuffer) Seek(offset int64, whence int) (int64, error)

Seek implements io.Seeker

func (*FileBackedBuffer) Size

func (b *FileBackedBuffer) Size() int64

Size returns the byte size of the buffered data

func (*FileBackedBuffer) Write

func (b *FileBackedBuffer) Write(p []byte) (int, error)

Write implements io.Writer

Jump to

Keyboard shortcuts

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