decode

package
v0.24.8 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeMessage

func DecodeMessage(msg map[string]any) (ret compact.Message, err error)

unpack a map of plain values into a description of a tapestry command. doesn't operate recursively, and doesn't check to see if the command is one that exists.

func DecodeSignature

func DecodeSignature(key string) (ret []string, err error)

given a key such as "Command noun:trait:change choice:" separate out the command name and parameter labels

func Hash

func Hash(slot, fullsig string) uint64

Hash helper for generating signatures lookups. ex: bool_eval=Not: the sig includes all of the colon separated labels used to indicate a given type. the slot specifies the typename a command fits into.

func ParseMessage

func ParseMessage(v any) (ret compact.Message, err error)

same as decode; errors if the passed value is something other than a map of plain values.

Types

type CustomDecoder

type CustomDecoder func(dec *Decoder, slot *typeinfo.Slot, plainData any) (typeinfo.Instance, error)

create an arbitrary command from arbitrary data ex. boolean literals are stored as actual bool values.

type Decoder

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

func (*Decoder) Customize

func (dec *Decoder) Customize(c CustomDecoder) *Decoder

customize the handling of specific slots.

func (*Decoder) Decode

func (dec *Decoder) Decode(out typeinfo.Instance, plainData any) (err error)

given a desired output structure, read the passed plain data note: since plainData can be a primitive value, it's difficult to provide a line offset in error messages here.

func (*Decoder) Patternize

func (dec *Decoder) Patternize(p PatternDecoder) *Decoder

handle conversion of unknown commands to scripted function calls.

func (*Decoder) Signatures

func (dec *Decoder) Signatures(t ...map[uint64]typeinfo.Instance) *Decoder

provide translation from command signatures to actual commands. ex. "Tapestry:" to *story.StoryFile

type PatternDecoder

type PatternDecoder func(dec *Decoder, slot *typeinfo.Slot, msg compact.Message) (typeinfo.Instance, error)

handle pattern parsing.

type SignatureTable

type SignatureTable []map[uint64]typeinfo.Instance

hash to pointer to a nil value of the type ex. 15485098871275255450: (*Comparison)(nil)

func (SignatureTable) Create

func (fac SignatureTable) Create(slot, fullsig string) (ret typeinfo.Instance, okay bool)

create a new instance of the type and return its pointer

func (SignatureTable) FindType

func (fac SignatureTable) FindType(hash uint64) (ret any, okay bool)

return the nil pointer to the type.

Jump to

Keyboard shortcuts

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