fixbuffer

package
v0.0.0-...-cb5804f Latest Latest
Warning

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

Go to latest
Published: May 23, 2016 License: BSD-3-Clause Imports: 3 Imported by: 1

Documentation

Overview

Package fixbuffer implements a buffered reader over a fixed size buffer

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a search does not return data
	ErrNotFound = errors.New("fixbuffer: Seperator not found")
	// ErrBuffer is returned if there is an issue with the buffer
	ErrBuffer = errors.New("fixbuffer: Buffer error")
	// ErrFull is returned if the buffer is filled
	ErrFull = errors.New("fixbuffer: Buffer full")
)

Functions

This section is empty.

Types

type FixBuffer

type FixBuffer struct {
	Sep []byte // Read until encountering Sep.
	// contains filtered or unexported fields
}

FixBuffer implements a buffered reader over a fixed size buffer

func New

func New(reader io.Reader, size int, sep []byte) *FixBuffer

New returns a FixBuffer of size oveErrBufferFullr the reader. Sep is the seperator for reads.

func (*FixBuffer) FindSep

func (fb *FixBuffer) FindSep() (d []byte, err error)

FindSep finds the seperator in the buffer and returns all bytes up and including the seperator. If not found, it returns ErrNotFound. Should

func (*FixBuffer) ReadBytes

func (fb *FixBuffer) ReadBytes() (d []byte, err error)

ReadBytes returns a byteslice up to and including Sep. If Sep isnt found, it returns nil and ErrNotFound. If the buffer is filled without finding Sep, ErrFull is returned.

Jump to

Keyboard shortcuts

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