storage

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGoLevelDB

func NewGoLevelDB(path string) (*goLevelDB, error)

func NewMemory

func NewMemory() *memory

func PutFloat32

func PutFloat32(dst []byte, v float32) []byte

PutFloat32 appens a float32 to the byte slice

func PutFloat64

func PutFloat64(dst []byte, v float64) []byte

PutFloat64 appends a float64 to the byte slice

func PutUInt32

func PutUInt32(dst []byte, v uint32) []byte

PutUInt32 appends an uint32 to the byte slice

func PutUInt64

func PutUInt64(dst []byte, v uint64) []byte

PutUInt64 appends an uint64 to the byte slice

func ReadFloat32

func ReadFloat32(src []byte) float32

ReadFloat32 reads a float32 from the byte slice

func ReadFloat64

func ReadFloat64(src []byte) float64

ReadFloat64 reads a float64 from the byte slice

func ReadUInt32

func ReadUInt32(src []byte) uint32

ReadUInt32 reads an uint32 from the byte slice

func ReadUInt64

func ReadUInt64(src []byte) uint64

ReadUInt64 reads an uint64 from the byte slice

Types

type Batch

type Batch interface {
	Delete([]byte)
	Put([]byte, []byte)
}

type Combined

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

Combined is a combination of storage modes

func NewCombined

func NewCombined(path string) (*Combined, error)

NewCombined returns a combined instance of disk and memory

func NewMemOnly

func NewMemOnly() *Combined

func (*Combined) Clear

func (c *Combined) Clear(mode DBMode)

func (*Combined) Close

func (c *Combined) Close()

func (*Combined) Delete

func (c *Combined) Delete(mode DBMode, key []byte) error

func (*Combined) Get

func (c *Combined) Get(mode DBMode, key []byte) ([]byte, error)

func (*Combined) GetFromAll

func (c *Combined) GetFromAll(key []byte) ([]byte, error)

func (*Combined) PrefixStream

func (c *Combined) PrefixStream(mode DBMode, prefix []byte, onData func(Iterator))

func (*Combined) PrefixStreamFromAll

func (c *Combined) PrefixStreamFromAll(prefix []byte, onData func(Iterator))

func (*Combined) Put

func (c *Combined) Put(mode DBMode, key []byte, value []byte) error

func (*Combined) WriteBatch

func (c *Combined) WriteBatch(mode DBMode, f func(Batch) error) error

type DB

type DB interface {
	Close()
	Clear()
	Delete([]byte) error
	Get([]byte) ([]byte, error)
	PrefixStream([]byte, func(Iterator))
	Put([]byte, []byte) error
	WriteBatch(func(Batch) error) error
}

type DBMode

type DBMode int

DBMode is the mode of the DB

const (
	// ModeMemory indicates memory
	ModeMemory = iota
	// ModeDisk indicates disk
	ModeDisk DBMode = iota
)

type Decoder

type Decoder coder

Decoder is a coder to decode byte slice into primitives

func NewDecoder

func NewDecoder(b []byte) *Decoder

NewDecoder creates a decoder

func (*Decoder) ReadBool

func (d *Decoder) ReadBool() bool

ReadBool reads a bool

func (*Decoder) ReadBytes

func (d *Decoder) ReadBytes() []byte

ReadBytes reads bytes

func (*Decoder) ReadFloat32

func (d *Decoder) ReadFloat32() float32

ReadFloat32 reads a float32

func (*Decoder) ReadFloat64

func (d *Decoder) ReadFloat64() float64

ReadFloat64 reads a float64

func (*Decoder) ReadInt

func (d *Decoder) ReadInt() int

ReadInt reads an int

func (*Decoder) ReadLocation

func (d *Decoder) ReadLocation() protocol.Location

ReadLocation reads a LSP location

func (*Decoder) ReadPosition

func (d *Decoder) ReadPosition() protocol.Position

ReadPosition reads a LSP position

func (*Decoder) ReadString

func (d *Decoder) ReadString() string

ReadString reads a string

func (*Decoder) ReadUInt32

func (d *Decoder) ReadUInt32() uint32

ReadUInt32 reads an uint32

func (*Decoder) ReadUInt64

func (d *Decoder) ReadUInt64() uint64

ReadUInt64 reads an uint64

type Encoder

type Encoder coder

Encoder is an encoder to encode primitives to byte slice

func NewEncoder

func NewEncoder() *Encoder

NewEncoder creates an encoder

func (*Encoder) Bytes

func (e *Encoder) Bytes() []byte

Bytes returns the underlying byte slice

func (*Encoder) WriteBool

func (e *Encoder) WriteBool(b bool)

WriteBool writes bool

func (*Encoder) WriteBytes

func (e *Encoder) WriteBytes(b []byte)

WriteBytes writes bytes

func (*Encoder) WriteFloat32

func (e *Encoder) WriteFloat32(v float32)

WriteFloat32 writes a float32

func (*Encoder) WriteFloat64

func (e *Encoder) WriteFloat64(v float64)

WriteFloat64 writes a float64

func (*Encoder) WriteInt

func (e *Encoder) WriteInt(v int)

WriteInt writes an int

func (*Encoder) WriteLocation

func (e *Encoder) WriteLocation(v protocol.Location)

WriteLocation writes a LSP location

func (*Encoder) WritePosition

func (e *Encoder) WritePosition(v protocol.Position)

WritePosition writes a LSP position

func (*Encoder) WriteString

func (e *Encoder) WriteString(v string)

WriteString writes string

func (*Encoder) WriteUInt32

func (e *Encoder) WriteUInt32(v uint32)

WriteUInt32 writes an uint32

func (*Encoder) WriteUInt64

func (e *Encoder) WriteUInt64(v uint64)

WriteUInt64 writes an uint64

type Iterator

type Iterator interface {
	Key() []byte
	Value() []byte
	Stop()
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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