buffer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReadWriteBuffer

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

ReadWriteBuffer is a simple type that implements io.WriterAt on an in-memory buffer. The zero value of this type is an empty buffer ready to use.

func NewReadWriteBuffer

func NewReadWriteBuffer(size, max int) *ReadWriteBuffer

NewReadWriteBuffer creates and returns a new ReadWriteBuffer with the given initial size and maximum. If maximum is <= 0 it is unlimited.

func (*ReadWriteBuffer) Bytes

func (rw *ReadWriteBuffer) Bytes() []byte

Bytes returns the ReadWriteBuffer's underlying data. This value will remain valid so long as no other methods are called on the ReadWriteBuffer.

func (*ReadWriteBuffer) Len

func (rw *ReadWriteBuffer) Len() int

Len returns the number of bytes of the unread portion of the slice.

func (*ReadWriteBuffer) Read

func (rw *ReadWriteBuffer) Read(b []byte) (n int, err error)

Read implements the io.Reader interface.

func (*ReadWriteBuffer) ReadAt

func (rw *ReadWriteBuffer) ReadAt(b []byte, off int64) (n int, err error)

ReadAt implements the io.ReaderAt interface.

func (*ReadWriteBuffer) Reset

func (rw *ReadWriteBuffer) Reset(b []byte)

Reset resets the Reader to be reading from b.

func (*ReadWriteBuffer) Seek

func (rw *ReadWriteBuffer) Seek(offset int64, whence int) (int64, error)

Seek implements the io.Seeker interface.

func (*ReadWriteBuffer) SetMax

func (rw *ReadWriteBuffer) SetMax(max int)

SetMax sets the maximum capacity of the ReadWriteBuffer. If the provided maximum is lower than the current capacity but greater than 0 it is set to the current capacity, if less than or equal to zero it is unlimited..

func (*ReadWriteBuffer) Shape

func (rw *ReadWriteBuffer) Shape() (int, int)

Shape returns the current ReadWriteBuffer size and its maximum if one was provided.

func (*ReadWriteBuffer) Size

func (rw *ReadWriteBuffer) Size() int64

Size returns the original length of the underlying byte slice. Size is the number of bytes available for reading via ReadAt. The returned value is always the same and is not affected by calls to any other method.

func (*ReadWriteBuffer) WriteAt

func (rw *ReadWriteBuffer) WriteAt(dat []byte, off int64) (int, error)

WriteAt implements the io.WriterAt interface.

Jump to

Keyboard shortcuts

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