types

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: LGPL-3.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrComponentSchemaMismatch = errors.New("component schema does not match target schema")

Functions

func GetFieldInformation

func GetFieldInformation(t reflect.Type) map[string]any

GetFieldInformation returns a map of the fields of a struct and their types.

func IsComponentValid

func IsComponentValid(component Component, jsonSchemaBytes []byte) (bool, error)

func SerializeComponentSchema

func SerializeComponentSchema(component Component) ([]byte, error)

Types

type ArchetypeID

type ArchetypeID int

type Component

type Component interface {
	// Name returns the name of the component.
	Name() string
}

Component is the interface that the user needs to implement to create a new component type.

func ConvertComponentMetadatasToComponents

func ConvertComponentMetadatasToComponents(comps []ComponentMetadata) []Component

ConvertComponentMetadatasToComponents Cast an array of ComponentMetadata into an array of Component

type ComponentID

type ComponentID int

type ComponentMetadata

type ComponentMetadata interface {
	// SetID sets the ArchetypeID of this component. It must only be set once
	SetID(ComponentID) error
	// ArchetypeID returns the ArchetypeID of the component.
	ID() ComponentID
	// New returns the marshaled bytes of the default value for the component struct.
	New() ([]byte, error)
	Encode(any) ([]byte, error)
	Decode([]byte) (Component, error)
	GetSchema() []byte
	ValidateAgainstSchema(targetSchema []byte) error

	Component
}

ComponentMetadata wraps the user-defined Component struct and provides functionalities that is used internally in the engine.

type EntityID

type EntityID uint64

type Message

type Message interface {
	SetID(MessageID) error
	Name() string
	// Group returns the group of the message.
	Group() string
	// FullName returns the fully qualified name of the message. It is formed by <group_name>.<message_name>.
	// example: persona.create-persona
	FullName() string
	ID() MessageID
	Encode(any) ([]byte, error)
	Decode([]byte) (any, error)
	// DecodeEVMBytes decodes ABI encoded bytes into the message's input type.
	DecodeEVMBytes([]byte) (any, error)
	// ABIEncode encodes the given type in ABI encoding, given that the input is the message type's input or output
	// type.
	ABIEncode(any) ([]byte, error)
	// IsEVMCompatible reports if this message can be sent from the EVM.
	IsEVMCompatible() bool

	// GetInFieldInformation returns a map of the fields of the message's "In" type and it's field types.
	GetInFieldInformation() map[string]any
}

type MessageID

type MessageID int

MessageID represents a message's id. They are assigned to messages when they are registered in a World object.

type TxHash

type TxHash string

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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