segment

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package segment provides the data segment.

Index

Constants

View Source
const (
	Uint8Size = 1 << iota
	Uint16Size
	Uint32Size
	Uint64Size
)

Sizes of the unsigned integer types in bytes.

Variables

View Source
var ErrUnknown = fmt.Errorf("segment: unknown value")

ErrUnknown is the error which returns when the given value has an unknown type.

Functions

This section is empty.

Types

type ReadWriterAt

type ReadWriterAt interface {
	io.ReaderAt
	io.WriterAt
}

ReadWriterAt is the interface that groups the basic io.ReadAt and io.WriteAt methods.

type Segment

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

Segment is a data segment. The supported data types are uint8, uint16, uint32 and uint64. All numeric values stored in the big-endian byte order.

func New

func New(driver ReadWriterAt) *Segment

New returns a new data segment based on the given data access driver.

func (*Segment) Dec

func (seg *Segment) Dec(offset int64, d ...interface{}) error

Dec sequentially decreases values starting from the given offset using deltas specified by d.

func (*Segment) Get

func (seg *Segment) Get(offset int64, v ...interface{}) error

Get sequentially reads values pointed by v starting from the given offset.

func (*Segment) Inc

func (seg *Segment) Inc(offset int64, d ...interface{}) error

Inc sequentially increases values starting from the given offset using deltas specified by d.

func (*Segment) Set

func (seg *Segment) Set(offset int64, v ...interface{}) error

Set sequentially writes values specified by v starting from the given offset.

func (*Segment) Swap

func (seg *Segment) Swap(offset int64, v ...interface{}) error

Swap sequentially swaps values pointed by v with stored ones starting from the given offset.

Jump to

Keyboard shortcuts

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