Documentation
¶
Index ¶
- func IteratorFromRange[K Key](store sdk.KVStore, r Range[K]) (iter sdk.Iterator, prefixBytes []byte)
- type Bound
- type Key
- type Order
- type Pair
- type PairRange
- func (p PairRange[K1, K2]) Descending() PairRange[K1, K2]
- func (p PairRange[K1, K2]) EndExclusive(end K2) PairRange[K1, K2]
- func (p PairRange[K1, K2]) EndInclusive(end K2) PairRange[K1, K2]
- func (p PairRange[K1, K2]) Prefix(prefix K1) PairRange[K1, K2]
- func (p PairRange[K1, K2]) RangeValues() (prefix *Pair[K1, K2], start *Bound[Pair[K1, K2]], end *Bound[Pair[K1, K2]], ...)
- func (p PairRange[K1, K2]) StartExclusive(start K2) PairRange[K1, K2]
- func (p PairRange[K1, K2]) StartInclusive(start K2) PairRange[K1, K2]
- type Range
- type RawRange
- type StringKey
- type Uint64Key
- type Uint8Key
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bound ¶
type Bound[K Key] struct { // contains filtered or unexported fields }
Bound defines a key bound.
type Key ¶
type Key interface { // KeyBytes returns the key as bytes. KeyBytes() []byte // FromKeyBytes parses the Key from bytes. // returns i which is the numbers of bytes read from the buffer. // Constraint: Key == Self (aka the interface implementer). // NOTE(mercilex): we in theory should return Key[T any] and constrain // in the collections.Map, collections.IndexedMap, collections.Set // that T is in fact the Key itself. // We don't do it otherwise all our APIs would get messy // due to golang's compiler type inference. FromKeyBytes(buf []byte) (i int, k Key) // Stringer is implemented to allow human-readable formats, especially important in errors. fmt.Stringer }
Key defines a type which can be converted to and from bytes. Constraints:
- It's ordered, meaning, for example: StringKey("a").KeyBytes() < StringKey("b").KeyBytes(). Int64Key(100).KeyBytes() > Int64Key(-100).KeyBytes()
- Going back and forth using KeyBytes and FromKeyBytes produces the same results.
- It's prefix safe, meaning that bytes.Contains(StringKey("a").KeyBytes(), StringKey("aa").KeyBytes()) = false.
type Pair ¶
Pair represents a multipart key composed of two Key of different or equal types.
func PairPrefix ¶
PairPrefix is used to provide only the K1 part of the Pair. Usually used in Range.Prefix where Key is Pair.
func PairSuffix ¶
PairSuffix is used to provide only the K2 part of the Pair. Usually used in Range.Start or Range.End where Key is Pair.
func (Pair[K1, K2]) K1 ¶
func (t Pair[K1, K2]) K1() K1
K1 returns the first part of the key, if present. If the key is not present the zero value is returned.
type PairRange ¶
type PairRange[K1, K2 Key] struct { // contains filtered or unexported fields }
PairRange implements the Range interface to provide an easier way to range over Pair keys.
func (PairRange[K1, K2]) Descending ¶
func (PairRange[K1, K2]) EndExclusive ¶
func (PairRange[K1, K2]) EndInclusive ¶
func (PairRange[K1, K2]) RangeValues ¶
func (PairRange[K1, K2]) StartExclusive ¶
func (PairRange[K1, K2]) StartInclusive ¶
type Range ¶
type Range[K Key] interface { // RangeValues returns the range instructions. RangeValues() (prefix *K, start *Bound[K], end *Bound[K], order Order) }
Range defines an interface which instructs on how to iterate over keys.
type RawRange ¶
type RawRange[K Key] struct { // contains filtered or unexported fields }
RawRange is a Range implementer.
func (RawRange[K]) Descending ¶
Descending sets the key range to be inverse.
func (RawRange[K]) RangeValues ¶
type StringKey ¶
type StringKey string