Documentation
¶
Index ¶
- type TypeMapper
- func (db *TypeMapper) Deserialize(data []byte) (any, error)
- func (db *TypeMapper) Lookup(id uint) reflect.Type
- func (db *TypeMapper) LookupId(componentType reflect.Type) uint
- func (db *TypeMapper) Register(id uint, component any) error
- func (db *TypeMapper) RegisterType(id uint, componentType reflect.Type) error
- func (db *TypeMapper) Serialize(component any) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TypeMapper ¶
type TypeMapper struct {
// contains filtered or unexported fields
}
TypeMapper is used to map between registered IDs and components and translates between server and client components, Note: Unexported members are supported, however embedded members will not be populated if also unexported.
func NewMapper ¶
func NewMapper(components map[uint]any) TypeMapper
NewMapper initializes a type mapper. This is responsible for serialization/deserialization.
func (*TypeMapper) Deserialize ¶
func (db *TypeMapper) Deserialize(data []byte) (any, error)
Deserialize a component by decoding its ID, and then the actual struct.
func (*TypeMapper) Lookup ¶
func (db *TypeMapper) Lookup(id uint) reflect.Type
Lookup finds the Type based on a component ID.
func (*TypeMapper) LookupId ¶
func (db *TypeMapper) LookupId(componentType reflect.Type) uint
LookupId finds the component ID from a Type.
func (*TypeMapper) Register ¶
func (db *TypeMapper) Register(id uint, component any) error
Register registers a mapping based on ID and an instance of the type.
func (*TypeMapper) RegisterType ¶
func (db *TypeMapper) RegisterType(id uint, componentType reflect.Type) error
RegisterType registers a mapping based on ID and reflect.Type.
Click to show internal directories.
Click to hide internal directories.