forge_value

package
v0.51.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownValueType indicates the value type was not known.
	ErrUnknownValueType = errors.New("unknown value type")
	// ErrEmptyValueName indicates the value name was empty.
	ErrEmptyValueName = errors.New("value name cannot be empty")
	// ErrDuplicateValueName indicates the value name was duplicated.
	ErrDuplicateValueName = errors.New("duplicate value name")
	// ErrUnsetValue indicates the value was not set.
	ErrUnsetValue = errors.New("value was required but not set")
	// ErrUnexpectedPeerID is returned if the peer id was incorrect.
	ErrUnexpectedPeerID = errors.New("unexpected peer id")
	// ErrUnknownState is returned if the state was unknown/unhandled.
	ErrUnknownState = errors.New("unexpected or unhandled state")
)
View Source
var (
	ValueType_name = map[int32]string{
		0: "ValueType_UNKNOWN",
		1: "ValueType_BLOCK_REF",
		2: "ValueType_BUCKET_REF",
		3: "ValueType_WORLD_OBJECT_SNAPSHOT",
	}
	ValueType_value = map[string]int32{
		"ValueType_UNKNOWN":               0,
		"ValueType_BLOCK_REF":             1,
		"ValueType_BUCKET_REF":            2,
		"ValueType_WORLD_OBJECT_SNAPSHOT": 3,
	}
)

Enum value maps for ValueType.

Functions

func GetValuesNames

func GetValuesNames(values ...ValueSlice) []string

GetValuesNames returns a sorted slice of all value names.

func NewResultSubBlockCtor

func NewResultSubBlockCtor(r **Result) block.SubBlockCtor

NewResultSubBlockCtor returns the sub-block constructor.

func NewValueSubBlockSet

func NewValueSubBlockSet(v *[]*Value, bcs *block.Cursor) *sbset.NamedSubBlockSet

NewValueSubBlockSet builds a new value set container.

bcs should be located at the sub-block

Types

type Result

type Result struct {

	// Success indicates the pass succeeded, if false, it failed.
	Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	// FailError contains the error if the pass failed.
	FailError string `protobuf:"bytes,2,opt,name=fail_error,json=failError,proto3" json:"failError,omitempty"`
	// Canceled is set if the step was canceled.
	Canceled bool `protobuf:"varint,3,opt,name=canceled,proto3" json:"canceled,omitempty"`
	// contains filtered or unexported fields
}

Result is information about a step in COMPLETE state.

func NewResultWithCanceled

func NewResultWithCanceled(err error) *Result

NewResultWithCanceled creates a new result with the canceled flag.

func NewResultWithError

func NewResultWithError(err error) *Result

NewResultWithError constructs a new result with an error. If err == nil, returns NewResultWithSuccess.

func NewResultWithSuccess

func NewResultWithSuccess() *Result

NewResultWithSuccess constructs a new result.

func (*Result) Clone

func (r *Result) Clone() *Result

Clone copies the result.

func (*Result) CloneMessageVT

func (m *Result) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Result) CloneVT

func (m *Result) CloneVT() *Result

func (*Result) EqualMessageVT

func (this *Result) EqualMessageVT(thatMsg any) bool

func (*Result) EqualVT

func (this *Result) EqualVT(that *Result) bool

func (*Result) Equals

func (r *Result) Equals(ot *Result) bool

Equals checks if the result equals another result.

func (*Result) FillFailError

func (r *Result) FillFailError()

FillFailError fills the fail error with a default if it was unset.

func (*Result) GetCanceled

func (x *Result) GetCanceled() bool

func (*Result) GetFailError

func (x *Result) GetFailError() string

func (*Result) GetSuccess

func (x *Result) GetSuccess() bool

func (*Result) IsEmpty

func (r *Result) IsEmpty() bool

IsEmpty checks if the result is empty.

func (*Result) IsNil

func (r *Result) IsNil() bool

IsNil checks if the object is nil.

func (*Result) IsSuccessful

func (r *Result) IsSuccessful() bool

IsSuccessful checks if the result was successful.

func (*Result) MarshalBlock

func (r *Result) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*Result) MarshalJSON

func (x *Result) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Result to JSON.

func (*Result) MarshalProtoJSON

func (x *Result) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Result message to JSON.

func (*Result) MarshalProtoText

func (x *Result) MarshalProtoText() string

func (*Result) MarshalToSizedBufferVT

func (m *Result) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Result) MarshalToVT

func (m *Result) MarshalToVT(dAtA []byte) (int, error)

func (*Result) MarshalVT

func (m *Result) MarshalVT() (dAtA []byte, err error)

func (*Result) ProtoMessage

func (*Result) ProtoMessage()

func (*Result) Reset

func (x *Result) Reset()

func (*Result) SizeVT

func (m *Result) SizeVT() (n int)

func (*Result) String

func (x *Result) String() string

func (*Result) UnmarshalBlock

func (r *Result) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*Result) UnmarshalJSON

func (x *Result) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Result from JSON.

func (*Result) UnmarshalProtoJSON

func (x *Result) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Result message from JSON.

func (*Result) UnmarshalVT

func (m *Result) UnmarshalVT(dAtA []byte) error

func (*Result) Validate

func (r *Result) Validate() error

Validate performs cursory checks of the Result.

type Value

type Value struct {

	// Name is the unique name of the value in the parent set.
	// Note: for in-line values, this may be empty.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// ValueType is the type of value.
	// 0: indicates empty value.
	ValueType ValueType `protobuf:"varint,2,opt,name=value_type,json=valueType,proto3" json:"valueType,omitempty"`
	// BlockRef is the value for the block ref type.
	// ValueType: BLOCK_REF
	BlockRef *block.BlockRef `protobuf:"bytes,3,opt,name=block_ref,json=blockRef,proto3" json:"blockRef,omitempty"`
	// BucketRef is a cross-bucket block reference w/ transform config.
	// Note: the target block DAG may be copied into other buckets.
	// ValueType: BUCKET_REF
	BucketRef *bucket.ObjectRef `protobuf:"bytes,4,opt,name=bucket_ref,json=bucketRef,proto3" json:"bucketRef,omitempty"`
	// WorldObjectSnapshot is the snapshot of the world object.
	// ValueType: WORLD_OBJECT_SNAPSHOT.
	WorldObjectSnapshot *WorldObjectSnapshot `protobuf:"bytes,5,opt,name=world_object_snapshot,json=worldObjectSnapshot,proto3" json:"worldObjectSnapshot,omitempty"`
	// contains filtered or unexported fields
}

Value contains a input/output value.

func NewValue

func NewValue(name string) *Value

NewValue constructs a new empty Value.

func NewValueWithBlockRef

func NewValueWithBlockRef(name string, br *block.BlockRef) *Value

NewValueWithBlockRef constructs a new value with a block ref.

func NewValueWithBucketRef

func NewValueWithBucketRef(name string, br *bucket.ObjectRef) *Value

NewValueWithBucketRef constructs a new value with a object ref.

func NewValueWithWorldObjectSnapshot

func NewValueWithWorldObjectSnapshot(name string, snapshot *WorldObjectSnapshot) *Value

NewValueWithWorldObjectSnapshot constructs a new value with a WorldObjectSnapshot.

func (*Value) ApplyBlockRef

func (v *Value) ApplyBlockRef(id uint32, ptr *block.BlockRef) error

ApplyBlockRef applies a ref change with a field id. The reference may be nil if the child block is nil.

func (*Value) ApplySubBlock

func (v *Value) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*Value) Clone

func (v *Value) Clone() *Value

Clone deep copies the Value.

func (*Value) CloneMessageVT

func (m *Value) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Value) CloneVT

func (m *Value) CloneVT() *Value

func (*Value) EqualMessageVT

func (this *Value) EqualMessageVT(thatMsg any) bool

func (*Value) EqualVT

func (this *Value) EqualVT(that *Value) bool

func (*Value) Equals

func (v *Value) Equals(ot block.ComparableNamedSubBlock) bool

Equals compares the two values.

func (*Value) GetBlockRef

func (x *Value) GetBlockRef() *block.BlockRef

func (*Value) GetBlockRefCtor

func (v *Value) GetBlockRefCtor(id uint32) block.Ctor

GetBlockRefCtor returns the constructor for the block at the ref id. Return nil to indicate invalid ref ID or unknown.

func (*Value) GetBlockRefs

func (v *Value) GetBlockRefs() (map[uint32]*block.BlockRef, error)

GetBlockRefs returns all block references by ID. May return nil, and values may also be nil. Note: this does not include pending references (in a cursor)

func (*Value) GetBucketRef

func (x *Value) GetBucketRef() *bucket.ObjectRef

func (*Value) GetName

func (x *Value) GetName() string

func (*Value) GetSubBlockCtor

func (v *Value) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*Value) GetSubBlocks

func (v *Value) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*Value) GetValueType

func (x *Value) GetValueType() ValueType

func (*Value) GetWorldObjectSnapshot

func (x *Value) GetWorldObjectSnapshot() *WorldObjectSnapshot

func (*Value) IsEmpty

func (v *Value) IsEmpty() bool

IsEmpty checks if the configuration is empty.

func (*Value) IsNil

func (v *Value) IsNil() bool

IsNil checks if the object is nil.

func (*Value) MarshalBlock

func (v *Value) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*Value) MarshalJSON

func (x *Value) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Value to JSON.

func (*Value) MarshalProtoJSON

func (x *Value) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Value message to JSON.

func (*Value) MarshalProtoText

func (x *Value) MarshalProtoText() string

func (*Value) MarshalToSizedBufferVT

func (m *Value) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Value) MarshalToVT

func (m *Value) MarshalToVT(dAtA []byte) (int, error)

func (*Value) MarshalVT

func (m *Value) MarshalVT() (dAtA []byte, err error)

func (*Value) ProtoMessage

func (*Value) ProtoMessage()

func (*Value) Reset

func (x *Value) Reset()

func (*Value) SizeVT

func (m *Value) SizeVT() (n int)

func (*Value) String

func (x *Value) String() string

func (*Value) ToBucketRef

func (v *Value) ToBucketRef() (*bucket.ObjectRef, error)

ToBucketRef converts any value type into an ObjectRef. Returns nil if the block ref or bucket ref was empty.

func (*Value) UnmarshalBlock

func (v *Value) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*Value) UnmarshalJSON

func (x *Value) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Value from JSON.

func (*Value) UnmarshalProtoJSON

func (x *Value) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Value message from JSON.

func (*Value) UnmarshalVT

func (m *Value) UnmarshalVT(dAtA []byte) error

func (*Value) Validate

func (v *Value) Validate(allowEmptyName bool) error

Validate performs cursory validation of the value.

type ValueMap

type ValueMap map[string]*Value

ValueMap is a map of named values. The key must match the Name field.

func (ValueMap) Validate

func (v ValueMap) Validate(allowNameKeyMismatch bool) error

Validate checks all values in the map.

type ValueSlice

type ValueSlice []*Value

ValueSlice is a slice of values.

func (ValueSlice) BuildValueMap

func (v ValueSlice) BuildValueMap(checkDupe, cloneObjs bool) (ValueMap, error)

BuildValueMap constructs a ValueMap from the ValueSlice.

func (ValueSlice) Clone

func (v ValueSlice) Clone() ValueSlice

Clone clones the slice of values.

func (ValueSlice) Compare

func (v ValueSlice) Compare(b ValueSlice) (added []*Value, removed []*Value, changed []*Value)

Compare returns the added, removed, and changed values.

func (ValueSlice) Equals

func (v ValueSlice) Equals(ot ValueSlice) bool

Equals compares two sets of values for equality.

func (ValueSlice) IsSorted

func (v ValueSlice) IsSorted() bool

IsSorted checks if the value slice is sorted.

func (ValueSlice) Merge

func (v ValueSlice) Merge(vals ValueSlice) ValueSlice

Merge applies a second set of values while overwriting existing. Note: we do not expect large value pointer sets. Any large data-set should be held under a block DAG structure.

func (ValueSlice) RemoveUnknown

func (v ValueSlice) RemoveUnknown() ValueSlice

RemoveUnknown filters any values with an empty name or type.

func (ValueSlice) SortByName

func (v ValueSlice) SortByName()

SortByName sorts the value slice by name.

func (ValueSlice) Validate

func (v ValueSlice) Validate(allowEmptyName, checkDupe, checkSort bool) error

Validate checks all values in the slice.

type ValueType

type ValueType int32

ValueType is the set of possible value types.

const (
	// ValueType_UNKNOWN is the unknown value type.
	ValueType_ValueType_UNKNOWN ValueType = 0
	// ValueType_BLOCK_REF is a block reference in the same bucket.
	ValueType_ValueType_BLOCK_REF ValueType = 1
	// ValueType_BUCKET_REF is a cross-bucket block reference w/ transform config.
	ValueType_ValueType_BUCKET_REF ValueType = 2
	// ValueType_WORLD_OBJECT_SNAPSHOT is a snapshot of a WorldObject state.
	ValueType_ValueType_WORLD_OBJECT_SNAPSHOT ValueType = 3
)

func (ValueType) Enum

func (x ValueType) Enum() *ValueType

func (ValueType) MarshalJSON

func (x ValueType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ValueType to JSON.

func (ValueType) MarshalProtoJSON

func (x ValueType) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the ValueType to JSON.

func (ValueType) MarshalProtoText

func (x ValueType) MarshalProtoText() string

func (ValueType) MarshalText

func (x ValueType) MarshalText() ([]byte, error)

MarshalText marshals the ValueType to text.

func (ValueType) String

func (x ValueType) String() string

func (*ValueType) UnmarshalJSON

func (x *ValueType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the ValueType from JSON.

func (*ValueType) UnmarshalProtoJSON

func (x *ValueType) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the ValueType from JSON.

func (*ValueType) UnmarshalText

func (x *ValueType) UnmarshalText(b []byte) error

UnmarshalText unmarshals the ValueType from text.

func (ValueType) Validate

func (v ValueType) Validate() error

Validate checks the value type is in range.

type WorldObjectSnapshot

type WorldObjectSnapshot struct {

	// Key is the unique Object key.
	Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// RootRef is the block ref to the root of the object structure.
	// Note: Object type is not stored. Type data is stored in the Graph, inline, or not at all.
	RootRef *bucket.ObjectRef `protobuf:"bytes,2,opt,name=root_ref,json=rootRef,proto3" json:"rootRef,omitempty"`
	// Rev is the rev nonce of the object.
	// Incremented when a transaction is applied to the object.
	// Incremented when root_ref is changed (SetRootRef).
	// Incremented when adding or removing a graph quad referencing Object.
	Rev uint64 `protobuf:"varint,3,opt,name=rev,proto3" json:"rev,omitempty"`
	// ObjectType is the object type determined by the world_types system.
	// May be empty if the object has no <type> defined.
	ObjectType string `protobuf:"bytes,4,opt,name=object_type,json=objectType,proto3" json:"objectType,omitempty"`
	// ObjectParent is the object key of the parent of this object.
	// May be empty if the object has no <parent> defined.
	ObjectParent string `protobuf:"bytes,5,opt,name=object_parent,json=objectParent,proto3" json:"objectParent,omitempty"`
	// contains filtered or unexported fields
}

WorldObjectSnapshot is a snapshot of a WorldObject state.

func NewWorldObjectSnapshot

func NewWorldObjectSnapshot(ctx context.Context, obj world.ObjectState, ws world.WorldState) (*WorldObjectSnapshot, error)

NewWorldObjectSnapshot converts a ObjectState into a WorldObjectSnapshot.

ws: can be nil, if unset, type and parents will be empty.

func (*WorldObjectSnapshot) ApplySubBlock

func (s *WorldObjectSnapshot) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*WorldObjectSnapshot) CloneMessageVT

func (*WorldObjectSnapshot) CloneVT

func (*WorldObjectSnapshot) EqualMessageVT

func (this *WorldObjectSnapshot) EqualMessageVT(thatMsg any) bool

func (*WorldObjectSnapshot) EqualVT

func (this *WorldObjectSnapshot) EqualVT(that *WorldObjectSnapshot) bool

func (*WorldObjectSnapshot) GetEmpty

func (s *WorldObjectSnapshot) GetEmpty() bool

GetEmpty checks if the WorldObjectSnapshot is empty.

func (*WorldObjectSnapshot) GetKey

func (x *WorldObjectSnapshot) GetKey() string

func (*WorldObjectSnapshot) GetObjectParent

func (x *WorldObjectSnapshot) GetObjectParent() string

func (*WorldObjectSnapshot) GetObjectType

func (x *WorldObjectSnapshot) GetObjectType() string

func (*WorldObjectSnapshot) GetRev

func (x *WorldObjectSnapshot) GetRev() uint64

func (*WorldObjectSnapshot) GetRootRef

func (x *WorldObjectSnapshot) GetRootRef() *bucket.ObjectRef

func (*WorldObjectSnapshot) GetSubBlockCtor

func (s *WorldObjectSnapshot) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*WorldObjectSnapshot) GetSubBlocks

func (s *WorldObjectSnapshot) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*WorldObjectSnapshot) IsNil

func (s *WorldObjectSnapshot) IsNil() bool

IsNil checks if the object is nil.

func (*WorldObjectSnapshot) MarshalBlock

func (s *WorldObjectSnapshot) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*WorldObjectSnapshot) MarshalJSON

func (x *WorldObjectSnapshot) MarshalJSON() ([]byte, error)

MarshalJSON marshals the WorldObjectSnapshot to JSON.

func (*WorldObjectSnapshot) MarshalProtoJSON

func (x *WorldObjectSnapshot) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the WorldObjectSnapshot message to JSON.

func (*WorldObjectSnapshot) MarshalProtoText

func (x *WorldObjectSnapshot) MarshalProtoText() string

func (*WorldObjectSnapshot) MarshalToSizedBufferVT

func (m *WorldObjectSnapshot) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*WorldObjectSnapshot) MarshalToVT

func (m *WorldObjectSnapshot) MarshalToVT(dAtA []byte) (int, error)

func (*WorldObjectSnapshot) MarshalVT

func (m *WorldObjectSnapshot) MarshalVT() (dAtA []byte, err error)

func (*WorldObjectSnapshot) ProtoMessage

func (*WorldObjectSnapshot) ProtoMessage()

func (*WorldObjectSnapshot) Reset

func (x *WorldObjectSnapshot) Reset()

func (*WorldObjectSnapshot) SizeVT

func (m *WorldObjectSnapshot) SizeVT() (n int)

func (*WorldObjectSnapshot) String

func (x *WorldObjectSnapshot) String() string

func (*WorldObjectSnapshot) ToBucketRef

func (s *WorldObjectSnapshot) ToBucketRef() (*bucket.ObjectRef, error)

ToBucketRef converts the snapshot into a ObjectRef. Returns nil if the block ref or bucket ref was empty.

func (*WorldObjectSnapshot) UnmarshalBlock

func (s *WorldObjectSnapshot) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*WorldObjectSnapshot) UnmarshalJSON

func (x *WorldObjectSnapshot) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the WorldObjectSnapshot from JSON.

func (*WorldObjectSnapshot) UnmarshalProtoJSON

func (x *WorldObjectSnapshot) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the WorldObjectSnapshot message from JSON.

func (*WorldObjectSnapshot) UnmarshalVT

func (m *WorldObjectSnapshot) UnmarshalVT(dAtA []byte) error

Jump to

Keyboard shortcuts

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