cosmos-sdk/schema/view/object.go

28 lines
1.4 KiB
Go

package view
import "cosmossdk.io/schema"
// ObjectCollection is the interface for viewing the state of a collection of objects in a module
// represented by ObjectUpdate's for an ObjectType. ObjectUpdates must not include
// ValueUpdates in the Value field. When ValueUpdates are applied they must be
// converted to individual value or array format depending on the number of fields in
// the value. For collections which retain deletions, ObjectUpdate's with the Delete
// field set to true should be returned with the latest Value still intact.
type ObjectCollection interface {
// ObjectType returns the object type for the collection.
ObjectType() schema.ObjectType
// GetObject returns the object update for the given key if it exists. And error should only be returned
// if there was an error getting the object update. If the object does not exist but there was no error,
// then found should be false and the error should be nil.
GetObject(key interface{}) (update schema.ObjectUpdate, found bool, err error)
// AllState iterates over the state of the collection by calling the given function with each item in
// state represented as an object update. If there is an error getting an object update, the error will be
// non-nil and the object update should be empty.
AllState(f func(schema.ObjectUpdate, error) bool)
// Len returns the number of objects in the collection.
Len() (int, error)
}