repo

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidID = fmt.Errorf("invalid ID")
)

Functions

This section is empty.

Types

type SeqCollection

type SeqCollection[V any] struct {
	collections.Map[uint64, V]
	// contains filtered or unexported fields
}

SeqCollection is an opinionated collection built on top of Cosmos SDK's Collections that uses a Sequence as ID for the Map.

The sequence will start from 1 to avoid using 0 as an ID which prevents unexpected behaviours, for example when marshalling data as JSON default values are omitted by default.

func NewSeqCollection

func NewSeqCollection[V any](
	seq collections.Sequence,
	m collections.Map[uint64, V],
	setId func(*V, uint64),
) SeqCollection[V]

func (SeqCollection[V]) Append

func (c SeqCollection[V]) Append(ctx context.Context, obj *V) (uint64, error)

func (SeqCollection[V]) Export added in v0.1.1

func (c SeqCollection[V]) Export(ctx context.Context) ([]V, error)

func (SeqCollection[V]) Get

func (c SeqCollection[V]) Get(ctx context.Context, id uint64) (V, error)

func (SeqCollection[V]) Import added in v0.1.1

func (c SeqCollection[V]) Import(ctx context.Context, values []V, getIDFn func(V) uint64) error

func (SeqCollection[V]) Set

func (c SeqCollection[V]) Set(ctx context.Context, id uint64, obj V) error

Jump to

Keyboard shortcuts

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