Documentation ¶
Index ¶
- type ListMapper
- type Mapper
- func (m Mapper) Delete(ctx sdk.Context, index uint64)
- func (m Mapper) ElemKey(i uint64) []byte
- func (m Mapper) Flush(ctx sdk.Context, ptr interface{}, fn func(sdk.Context) bool)
- func (m Mapper) Get(ctx sdk.Context, index uint64, ptr interface{}) error
- func (m Mapper) IsEmpty(ctx sdk.Context) bool
- func (m Mapper) IterateRead(ctx sdk.Context, ptr interface{}, fn func(sdk.Context, uint64) bool)
- func (m Mapper) IterateWrite(ctx sdk.Context, ptr interface{}, fn func(sdk.Context, uint64) bool)
- func (m Mapper) Len(ctx sdk.Context) uint64
- func (m Mapper) LengthKey() []byte
- func (m Mapper) Peek(ctx sdk.Context, ptr interface{}) error
- func (m Mapper) Pop(ctx sdk.Context)
- func (m Mapper) Push(ctx sdk.Context, value interface{})
- func (m Mapper) Set(ctx sdk.Context, index uint64, value interface{})
- func (m Mapper) TopKey() []byte
- type QueueMapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ListMapper ¶
type ListMapper interface { // Len() returns the length of the list // The length is only increased by Push() and not decreased // ListMapper dosen't check if an index is in bounds // The user should check Len() before doing any actions Len(sdk.Context) uint64 // Get() returns the element by its index Get(sdk.Context, uint64, interface{}) error // Set() stores the element to the given position // Setting element out of range will break length counting // Use Push() instead of Set() to append a new element Set(sdk.Context, uint64, interface{}) // Delete() deletes the element in the given position // Other elements' indices are preserved after deletion // Panics when the index is out of range Delete(sdk.Context, uint64) // Push() inserts the element to the end of the list // It will increase the length when it is called Push(sdk.Context, interface{}) // CONTRACT: No writes may happen within a domain while iterating over it. IterateRead(sdk.Context, interface{}, func(sdk.Context, uint64) bool) // IterateWrite() is safe to write over the domain IterateWrite(sdk.Context, interface{}, func(sdk.Context, uint64) bool) // Key for the length of the list LengthKey() []byte // Key for getting elements ElemKey(uint64) []byte }
ListMapper is a Mapper interface that provides list-like functions It panics when the element type cannot be (un/)marshalled by the codec
func NewListMapper ¶
NewListMapper constructs new ListMapper
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
Mapper defines a primitive mapper type
func (Mapper) IterateRead ¶
IterateRead implements ListMapper
func (Mapper) IterateWrite ¶
IterateWrite implements ListMapper
type QueueMapper ¶
type QueueMapper interface { // Push() inserts the elements to the rear of the queue Push(sdk.Context, interface{}) // Peek() returns the element at the front of the queue without removing it Peek(sdk.Context, interface{}) error // Pop() returns the element at the front of the queue and removes it Pop(sdk.Context) // IsEmpty() checks if the queue is empty IsEmpty(sdk.Context) bool // Flush() removes elements it processed // Return true in the continuation to break // The interface{} is unmarshalled before the continuation is called // Starts from the top(head) of the queue // CONTRACT: Pop() or Push() should not be performed while flushing Flush(sdk.Context, interface{}, func(sdk.Context) bool) // Key for the index of top element TopKey() []byte }
QueueMapper is a Mapper interface that provides queue-like functions It panics when the element type cannot be (un/)marshalled by the codec
func NewQueueMapper ¶
NewQueueMapper constructs new QueueMapper
Click to show internal directories.
Click to hide internal directories.