trailingbuf

package
v0.0.0-...-44c758a Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooFarBehind = errors.New("trailbuf: read too far behind")

ErrTooFarBehind is returned if a read goes too far behind the current position. It's set as a cause (which callers can unwrap) on some errors returned by ReadAt.

Functions

This section is empty.

Types

type ReaderAt

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

func New

func New(r ioctx.Reader, off int64, trailSize int) *ReaderAt

New creates a ReaderAt that can respond to arbitrary reads as long as they're close to the current position. trailSize controls the max distance (controlling buffer space usage). Reads too far behind the current position return an error with cause ErrTooFarBehind. off is the current position of r (for example, zero for the start of a file, or non-zero for reading somewhere in the middle). Note: Alternatively, callers could manipulate the offsets in their ReadAt calls to be relative to r's initial position. However, since we put offsets in our error message strings, users may find debugging easier if they don't need to de-relativize the errors.

func (*ReaderAt) ReadAt

func (r *ReaderAt) ReadAt(ctx context.Context, dst []byte, off int64) (int, error)

ReadAt implements io.ReaderAt.

func (*ReaderAt) Size

func (r *ReaderAt) Size(ctx context.Context) (size int64, known bool, err error)

Size returns the final number of bytes obtained from the underlying stream, if we've already found EOF, else _, false.

Jump to

Keyboard shortcuts

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