seekbuf

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: BSD-2-Clause, ISC Imports: 1 Imported by: 0

Documentation

Overview

Package seekbuf implements a read-seekable buffer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer is a ReadWriteCloser that supports seeking. It's intended to replicate the functionality of bytes.Buffer that I use in my projects.

Note that the seeking is limited to the read marker; all writes are append-only.

func New

func New(data []byte) *Buffer

func (*Buffer) Bytes added in v1.7.4

func (b *Buffer) Bytes() []byte

Bytes returns the underlying bytes from the current position.

func (*Buffer) Close

func (b *Buffer) Close() error

Close clears all the data out of the buffer and sets the read position to 0.

func (*Buffer) Len added in v1.6.2

func (b *Buffer) Len() int

Len returns the length of data remaining to be read.

func (*Buffer) Read

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

func (*Buffer) Rewind

func (b *Buffer) Rewind()

Rewind resets the read pointer to 0.

func (*Buffer) Seek

func (b *Buffer) Seek(pos int)

Seek sets the read pointer to pos.

func (*Buffer) Write

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

Jump to

Keyboard shortcuts

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