goutilsgit.wntrmute.dev/kyle/goutils/seekbuf Index | Files

package seekbuf

import "git.wntrmute.dev/kyle/goutils/seekbuf"

Package seekbuf implements a read-seekable buffer.

Index

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

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

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)

Source Files

seekbuf.go

Version
v1.7.7 (latest)
Published
Jun 15, 2024
Platform
linux/amd64
Imports
1 packages
Last checked
4 days ago

Tools for package owners.