types

package
v0.0.0-...-b8140f3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	EventTypeStateChange = "state_change"

	AttributeKeyStoreName     = "store"
	AttributeKeyStoreSubkey   = "key"
	AttributeKeyAnchoredKey   = "anckey"
	AttributeKeyUnprovedValue = "value"

	// We chose \1 so that it is not a valid character in a vstorage path.
	AnchoredKeyStart = "\x01"
	AnchoredKeyEnd   = AnchoredKeyStart
)

Variables

This section is empty.

Functions

func EncodeKVEntryReaderToJsonl

func EncodeKVEntryReaderToJsonl(reader KVEntryReader, bytesWriter io.Writer) (err error)

EncodeKVEntryReaderToJsonl consumes a KVEntryReader and JSON encodes each KVEntry, terminating by new lines. It will not Close the Reader when done

func NewStateChangeEvent

func NewStateChangeEvent(storeName string, subkey, value []byte) sdk.Event

Types

type KVEntry

type KVEntry struct {
	// contains filtered or unexported fields
}

KVEntry represents a string key / string value pair, where the value may be missing, which is different from an empty value. The semantics of a missing value are purpose-dependent rather than specified here, but frequently correspond with deletion/incompleteness/etc. A KVEntry with an empty key is considered invalid.

func NewKVEntry

func NewKVEntry(key string, value string) KVEntry

NewKVEntry creates a KVEntry with the provided key and value

func NewKVEntryWithNoValue

func NewKVEntryWithNoValue(key string) KVEntry

NewKVEntryWithNoValue creates a KVEntry with the provided key and no value

func (KVEntry) HasValue

func (entry KVEntry) HasValue() bool

HasValue returns whether the KVEntry has a value or not.

func (KVEntry) IsValidKey

func (entry KVEntry) IsValidKey() bool

IsValidKey returns whether the KVEntry has a non-empty key.

func (KVEntry) Key

func (entry KVEntry) Key() string

Key returns the string key.

func (KVEntry) MarshalJSON

func (entry KVEntry) MarshalJSON() ([]byte, error)

MarshalJSON encodes the KVEntry into a JSON array of [key: string, value?: string], with the value missing (array length of 1) if the entry has no value.

Implements json.Marshaler

func (KVEntry) StringValue

func (entry KVEntry) StringValue() string

StringValue returns the string value, or the empty string if the entry has no value. Note that the result therefore does not differentiate an empty string value from no value.

func (*KVEntry) UnmarshalJSON

func (entry *KVEntry) UnmarshalJSON(input []byte) (err error)

UnmarshalJSON updates a KVEntry from JSON text corresponding with a [key: string, value?: string | null] shape, or returns an error indicating invalid input. The key must be a non-empty string, and the value (if present) must be a string or null.

Implements json.Unmarshaler Note: unlike other methods, this accepts a pointer to satisfy the Unmarshaler semantics.

func (KVEntry) Value

func (entry KVEntry) Value() *string

Value returns a pointer to the string value or nil if the entry has no value.

type KVEntryReader

type KVEntryReader interface {
	// Read returns the next KVEntry, or an error.
	// An `io.EOF` error indicates that the previous Read() returned the final KVEntry.
	Read() (KVEntry, error)
	// Close frees the underlying resource (such as a slice or file descriptor).
	Close() error
}

KVEntryReader is an abstraction for iteratively reading KVEntry data.

func NewJsonRawMessageKVEntriesReader

func NewJsonRawMessageKVEntriesReader(jsonEntries []json.RawMessage) KVEntryReader

NewJsonRawMessageKVEntriesReader creates a KVEntryReader backed by a json.RawMessage slice

func NewJsonlKVEntryDecoderReader

func NewJsonlKVEntryDecoderReader(byteReader io.ReadCloser) KVEntryReader

NewJsonlKVEntryDecoderReader creates a KVEntryReader over a byte stream reader that decodes each line as a json encoded KVEntry. The entries are yielded in order they're present in the stream.

func NewKVIteratorReader

func NewKVIteratorReader(iter sdk.Iterator) KVEntryReader

NewKVIteratorReader returns a KVEntryReader backed by an sdk.Iterator.

func NewSwingStoreExportDataEntriesReader

func NewSwingStoreExportDataEntriesReader(exportDataEntries []*swingsettypes.SwingStoreExportDataEntry) KVEntryReader

NewSwingStoreExportDataEntriesReader creates a KVEntryReader backed by a SwingStoreExportDataEntry slice

func NewVstorageDataEntriesReader

func NewVstorageDataEntriesReader(vstorageDataEntries []*vstoragetypes.DataEntry) KVEntryReader

NewVstorageDataEntriesReader creates a KVEntryReader backed by a vstorage DataEntry slice

Jump to

Keyboard shortcuts

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