tape

package
v0.0.0-...-d5de3f3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WalkStack

func WalkStack(bytes []byte, fn func(i int, op Operand) (bool, error)) error

WalkStack will walk the encoded stack and yield the operands. ErrBreak may be returned to stop execution.

Types

type Cell

type Cell struct {
	Type  CellType
	Value []byte
}

Cell represents a value stored at a key. It is either a raw cell, that holds a user supplied value or a stack cell that holds a list of operator operands.

func (*Cell) Decode

func (v *Cell) Decode(bytes []byte, clone bool) error

Decode will decode the cell.

func (*Cell) Encode

func (v *Cell) Encode(borrow bool) ([]byte, fpack.Ref, error)

Encode will encode the cell.

type CellType

type CellType uint8

CellType represents the type of cell.

const (
	// RawCell holds a user supplied value.
	RawCell CellType = 1

	// StackCell holds a list of operator operands.
	StackCell CellType = 2
)

func (CellType) Valid

func (k CellType) Valid() bool

Valid returns whether the cell type is valid.

type Operand

type Operand struct {
	Name  string
	Value []byte
}

Operand represents a single operator operand.

type Stack

type Stack struct {
	Operands []Operand
}

Stack represents a list of operator operands.

func (*Stack) Decode

func (s *Stack) Decode(bytes []byte, clone bool) error

Decode will decode the stack.

func (*Stack) Encode

func (s *Stack) Encode(borrow bool) ([]byte, fpack.Ref, error)

Encode will encode the stack.

type State

type State struct {
	// The index of the last fully applied batch.
	Index uint64

	// The index of the batch currently being processed.
	Batch uint64

	// The sequence of the last fully applied instruction.
	Last uint16
}

State represents the current state of a database.

func (*State) Decode

func (s *State) Decode(bytes []byte) error

Decode will decode the state.

func (*State) Encode

func (s *State) Encode(borrow bool) ([]byte, fpack.Ref, error)

Encode will encode the state.

Jump to

Keyboard shortcuts

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