flect

package
v0.0.0-...-6bb5737 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Instantiate

func Instantiate[T any](model Model[T], params ...Param) T

Types

type BaseType

type BaseType uint8
const (
	Unknown BaseType = iota
	String
	Bool
	Array
	U8
	U16
	U32
	U64
	Uint
	I8
	I16
	I32
	I64
	Int
)

func (BaseType) String

func (i BaseType) String() string

type Deserializer

type Deserializer interface {
	Descend(field reflect.StructField)
	Ascend()
	Visit(field reflect.StructField) string
}

type Field

type Field[T any] struct {
	Type BaseType
	// contains filtered or unexported fields
}

func (Field[T]) Size

func (f Field[T]) Size() uint

func (Field[T]) WriteBool

func (f Field[T]) WriteBool(into T, b bool) T

func (Field[T]) WriteInt

func (f Field[T]) WriteInt(into T, num int) T

func (Field[T]) WriteInt16

func (f Field[T]) WriteInt16(into T, num int16) T

func (Field[T]) WriteInt32

func (f Field[T]) WriteInt32(into T, num int32) T

func (Field[T]) WriteInt64

func (f Field[T]) WriteInt64(into T, num int64) T

func (Field[T]) WriteInt8

func (f Field[T]) WriteInt8(into T, num int8) T

func (Field[T]) WriteString

func (f Field[T]) WriteString(into T, value string) T

func (Field[T]) WriteUInt

func (f Field[T]) WriteUInt(into T, num uint) T

func (Field[T]) WriteUInt16

func (f Field[T]) WriteUInt16(into T, num uint16) T

func (Field[T]) WriteUInt32

func (f Field[T]) WriteUInt32(into T, num uint32) T

func (Field[T]) WriteUInt64

func (f Field[T]) WriteUInt64(into T, num uint64) T

func (Field[T]) WriteUInt8

func (f Field[T]) WriteUInt8(into T, num uint8) T

func (Field[T]) WriteUPtr

func (f Field[T]) WriteUPtr(into T, src unsafe.Pointer) T

WriteUPtr takes unsafe pointer and writes as much data from it, as the type consumes

type Model

type Model[T any] struct {
	// contains filtered or unexported fields
}

func NewModel

func NewModel[T any](deserializer Deserializer) Model[T]

func (Model[T]) Field

func (m Model[T]) Field(key string) (Field[T], bool)

func (Model[T]) String

func (m Model[T]) String() string

type NameDeserializer

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

func (*NameDeserializer) Ascend

func (n *NameDeserializer) Ascend()

func (*NameDeserializer) Descend

func (n *NameDeserializer) Descend(field reflect.StructField)

func (*NameDeserializer) Visit

func (n *NameDeserializer) Visit(field reflect.StructField) (name string)

type Param

type Param struct {
	Key   string
	Value unsafe.Pointer
}

Jump to

Keyboard shortcuts

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