datarun

package
v0.0.0-...-2776432 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTruncatedData is returned when attempting to read data from a buffer
	// or reader with insufficient data.
	ErrTruncatedData = errors.New("insufficient or truncated data")

	// ErrInvalidHeader is returned when attempting to decode a data run
	// header that has an invalid size.
	ErrInvalidHeader = errors.New("invalid data run header")
)

Functions

This section is empty.

Types

type Decoder

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

Decoder decodes data in an underlying reader as a serires of data run mapping pairs.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new decoder that reads from r until it encounters an end-of-stream header.

func (*Decoder) Read

func (d *Decoder) Read() (MappingPair, error)

Read returns the next mapping pair from d. It returns io.EOF when there is no more data to return.

type Header byte

Header describes the allocation of bytes in a mapping pair.

const EOF Header = 0

EOF is a sentinel header value indicating the end of a series of mapping pairs.

It is not to be confused with io.EOF, which is a sentinel error value.

func (Header) DataBytes

func (h Header) DataBytes() int

DataBytes returns the number of data bytes in a mapping pair, excluding the header itself.

func (Header) LengthBytes

func (h Header) LengthBytes() int

LengthBytes returns the number of length bytes in a mapping pair.

func (Header) OffsetBytes

func (h Header) OffsetBytes() int

OffsetBytes returns the number of offset bytes in a mapping pair.

func (Header) Valid

func (h Header) Valid() bool

Valid returns false if the header contains invalid data.

type MappingPair

type MappingPair struct {
	Length uint64 // In clusters
	Offset int64  // Relative to previous data run, may be negative
}

MappingPair stores the length and offset of a logical cluster number so that it can be mapped to a virtual cluster number.

func Decode

func Decode(data []byte) (pairs []MappingPair, err error)

Decode decodes data until it encounters EOF in the data stream or encounters an error. It returns a slice of all the mapping pairs it decoded. If the data is decoded successfully err will be nil.

Jump to

Keyboard shortcuts

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