{"modulePath":"github.com/tomgray/structlua","version":"v1.0.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package structlua\n\n## Functions\n\n```go\nfunc TypeName(v Value) string\n```\nTypeName returns the Lua type name for v (e.g. \"nil\", \"boolean\", \"number\", \"string\", \"table\").\n\n```go\nfunc Unmarshal(val Value, target any) error\n```\nUnmarshal is a package-level helper that unmarshals using the default Unmarshaler.\n\n## Types\n\n```go\ntype LuaUnmarshaler interface {\n\tUnmarshalLua(v Value) error\n}\n```\nLuaUnmarshaler is the interface implemented by types that can unmarshal a Lua description of themselves.\n\n```go\ntype Option interface {\n\tApply(*Unmarshaler)\n}\n```\nOption configures an Unmarshaler.\n\n```go\nfunc WithHandler[T any](handler func(v Value) (T, error)) Option\n```\nWithHandler registers a custom handler for type T (interfaces or concrete types) during NewUnmarshaler.\n\n```go\ntype PolymorphicBuilder[T any] struct {\n\t// contains filtered or unexported fields\n}\n```\nPolymorphicBuilder builds a polymorphic handler for type T based on a discriminator field. It implements the Option interface for NewUnmarshaler.\n\n```go\nfunc Polymorphic[T any](field string) *PolymorphicBuilder[T]\n```\nPolymorphic creates a PolymorphicBuilder for type T using the specified discriminator field. It implements Option and lazily registers the polymorphic handler when passed to NewUnmarshaler.\n\n```go\nfunc (b *PolymorphicBuilder[T]) Add[C any](discriminator string, fn func(C) (T, error)) *PolymorphicBuilder[T]\n```\nAdd registers a strongly-typed mapping function for a discriminator value. structlua creates the zero value of C (value or pointer), unmarshals the Lua table into it, and invokes fn to produce the domain type T.\n\n```go\nfunc (b *PolymorphicBuilder[T]) AddType[C any](discriminator string) *PolymorphicBuilder[T]\n```\nAddType registers a concrete implementation type C that implements T, without requiring a mapping function. structlua creates the zero value of C (by value or pointer) and unmarshals the Lua table directly into it.\n\n```go\nfunc (b *PolymorphicBuilder[T]) Apply(u *Unmarshaler)\n```\nApply registers the polymorphic handler onto the Unmarshaler.\n\n```go\ntype Table iter.Seq2[Value, Value]\n```\nTable is a standard Go range-over-func iterator yielding key-value pairs of a Lua table.\n\n```go\ntype Unmarshaler struct {\n\t// contains filtered or unexported fields\n}\n```\nUnmarshaler unmarshals Lua values into Go values and manages custom type handlers.\n\n```go\nfunc NewUnmarshaler(opts ...Option) *Unmarshaler\n```\nNewUnmarshaler creates a new Unmarshaler instance with optional configuration options.\n\n```go\nfunc (u *Unmarshaler) RegisterHandler[T any](handler func(v Value) (T, error)) error\n```\nRegisterHandler registers a custom handler for type T (interfaces or concrete types).\n\n```go\nfunc (u *Unmarshaler) Unmarshal(val Value, target any) error\n```\nUnmarshal extracts a Lua value into target pointer v.\n\n```go\ntype UnsupportedType string\n```\nUnsupportedType represents a Lua value type that cannot be unmarshaled as data (e.g. \"function\", \"userdata\", \"thread\", \"none\").\n\n```go\ntype Value struct {\n\t// contains filtered or unexported fields\n}\n```\nValue holds a Lua value constrained at compile time to nil, bool, float64, string, or Table. The zero Value{} represents Lua nil.\n\n```go\nfunc NewValue[T ~bool | ~float64 | ~string | Table](v T) Value\n```\nNewValue constructs a Value from any valid Lua primitive or Table.\n\n```go\nfunc (v Value) Any() any\n```\nAny returns the underlying Go value (nil, bool, float64, string, Table, or UnsupportedType) for standard Go type assertions and type switches.\n\n","path":"github.com/tomgray/structlua","name":"structlua","synopsis":"","isRedistributable":true}
