state

package module
v0.0.0-...-36bb858 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MPL-2.0 Imports: 4 Imported by: 16

README

State

State is a package for managing state.

Cells

Cells are compare-and-swap cells. They support reading and compare-and-swapping the data.

Content-Addressed Data

Content-addressed data stores identify pieces of data by their hash. Posting to the store returns the hash of the data, which can be used later to retrieve the data, and verify that it is correct.

Key-Value Stores

Interfaces for Key-Value and transactional Key-Value stores are defined at state.KVStore and state.KVStoreTx.

POSIXFS

Interfaces and utility functions for dealing with filesystems as defined by POSIX.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrNotFound

func IsErrNotFound[K any](err error) bool

Types

type ByteSpan

type ByteSpan struct {
	Begin []byte
	End   []byte
}

ByteSpan represents a lexicographically sorted span of []byte. The span is [Begin, End), meaning Begin is included, and End is excluded. End is ignored if set to nil, and the span is assumed to have no upper bound. When Begin is the empty []byte, it implies no lower bound, since it is inclusive.

func (ByteSpan) AllGt

func (s ByteSpan) AllGt(x []byte) bool

AllGt returns true if every key in the span is greater than x

func (ByteSpan) AllLt

func (s ByteSpan) AllLt(x []byte) bool

AllLt returns true if every key in the span is less than x

func (ByteSpan) Contains

func (s ByteSpan) Contains(x []byte) bool

Contains returns true if x is in the Span

func (ByteSpan) String

func (s ByteSpan) String() string

String implements fmt.Stringer

func (ByteSpan) ToSpan

func (s ByteSpan) ToSpan() Span[[]byte]

type ErrNotFound

type ErrNotFound[K any] struct {
	Key K
}

func (ErrNotFound[K]) Error

func (e ErrNotFound[K]) Error() string

type Span

type Span[T any] struct {
	// contains filtered or unexported fields
}

Span is a specification for iteration through values of type T. It includes begin and end bounds, which can be inclusive or exclusive of the bounding value. The empty Span is equivalent to TotalSpan() and includes all elements of type T.

func PointSpan

func PointSpan[T any](x T) Span[T]

PointSpan returns a Span that contains 1 element.

func TotalSpan

func TotalSpan[T any]() Span[T]

TotalSpan returns a Span[T] which contains all elements of T

func (Span[T]) Compare

func (s Span[T]) Compare(x T, cmp func(a, b T) int) int

Compare determines if an element T is below the Span, in the Span or above the Span. The output should be interpretted as s - x. Similar to bytes.Compare and strings.Compare. If the span > x then 1. If the span < x then -1. If the span contains x then 0.

func (Span[T]) Contains

func (s Span[T]) Contains(x T, cmp func(a, b T) int) bool

Contains returns true if the span contains x.

func (Span[T]) IncludesLower

func (s Span[T]) IncludesLower() bool

IncludesLower returns true if there is a lower bound and it is inclusive

func (Span[T]) IncludesUpper

func (s Span[T]) IncludesUpper() bool

IncludesUpper returns true if there is an upper bound and it is inclusive

func (Span[T]) IsDesc

func (s Span[T]) IsDesc() bool

func (Span[T]) LowerBound

func (s Span[T]) LowerBound() (T, bool)

LowerBound returns the Span's lower bound and true if the span has a lower bound.

func (Span[T]) String

func (s Span[T]) String() string

func (Span[T]) UpperBound

func (s Span[T]) UpperBound() (T, bool)

UpperBound returns the Span's upper bound and true if the span has an upper bound.

func (Span[T]) WithLowerExcl

func (s Span[T]) WithLowerExcl(x T) Span[T]

WithLower returns a copy of s with an exclusive lower bound.

func (Span[T]) WithLowerIncl

func (s Span[T]) WithLowerIncl(x T) Span[T]

WithLowerIncl returns a copy of s with an inclusive lower bound

func (Span[T]) WithUpperExcl

func (s Span[T]) WithUpperExcl(x T) Span[T]

WithLowerExcl returns a copy of s with an exclusive lower bound

func (Span[T]) WithUpperIncl

func (s Span[T]) WithUpperIncl(x T) Span[T]

WithUpperIncl returns a copy of s with an inclusive upper bound

func (Span[T]) WithoutLower

func (s Span[T]) WithoutLower() Span[T]

WithoutLower returns a copy of s with no lower bound.

func (Span[T]) WithoutUpper

func (s Span[T]) WithoutUpper() Span[T]

WithoutUpper returns a copy of s with no upper bound.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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