bump

package module
v0.0.0-...-31a74cb Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: Apache-2.0 Imports: 1 Imported by: 3

README

bump

An efficient buffering library for Go (Golang).

Features
  • Simple and efficient buffering
  • Reuse readers and writers repeatedly
  • Write to io.Writer, or directly to a byte slice
  • Read from io.Reader, or directly from a byte slice
  • Reading directly from byte slice requires no allocations
Installation
go get github.com/abcum/bump

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

Reader represents a buffer for reading from an io.Reader, or a byte slice.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader creates a new Reader which reads from an underlying io.Reader.

func NewReaderBytes

func NewReaderBytes(b []byte) *Reader

NewReaderBytes creates a new Reader which reads from a byte slice.

func (*Reader) PeekByte

func (r *Reader) PeekByte() (byte, error)

PeekByte returns the next byte in the stream without advancing the position of the reader.

func (*Reader) ReadByte

func (r *Reader) ReadByte() (byte, error)

ReadByte reads a single byte from the underlying io.Reader, or byte slice, and advances the position.

func (*Reader) ReadBytes

func (r *Reader) ReadBytes(l int) ([]byte, error)

ReadBytes reads the specified number of bytes from the underlying io.Reader, or byte slice, and advances the position.

func (*Reader) ReadString

func (r *Reader) ReadString(l int) (string, error)

ReadString reads the specified length string from the underlying io.Reader, or byte slice, and advances the position.

func (*Reader) Reset

func (r *Reader) Reset(i io.Reader) error

Reset resets the Reader, and instructs it to read from the specified io.Reader.

func (*Reader) ResetBytes

func (r *Reader) ResetBytes(b []byte) error

ResetBytes resets the Reader, and instructs it to read from the specified byte slice.

type Writer

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

Writer represents a buffer for writing to an io.Writer, or a byte slice.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter creates a new Writer which writes to an underlying io.Writer.

func NewWriterBytes

func NewWriterBytes(b *[]byte) *Writer

NewWriterBytes creates a new Writer which writes to a byte slice.

func (*Writer) Flush

func (w *Writer) Flush() error

Flush flushes any remaining buffered data to the underlying io.Writer. When writing to a byte slice, this function does not do anything, as data is written immediately.

func (*Writer) Reset

func (w *Writer) Reset(i io.Writer) error

Reset resets the Writer, and instructs it to write to the specified io.Writer.

func (*Writer) ResetBytes

func (w *Writer) ResetBytes(b *[]byte) error

ResetBytes resets the Writer, and instructs it to write to the specified byte slice.

func (*Writer) WriteByte

func (w *Writer) WriteByte(v byte) error

WriteByte writes a single byte to the underlying io.Writer, or byte slice.

func (*Writer) WriteBytes

func (w *Writer) WriteBytes(v []byte) error

WriteBytes writes a slice of bytes to the underlying io.Writer, or byte slice.

func (*Writer) WriteString

func (w *Writer) WriteString(v string) error

WriteString writes a string to the underlying io.Writer, or byte slice.

Jump to

Keyboard shortcuts

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