model_reflect

package module
v0.0.0-...-e1e4463 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: MIT Imports: 9 Imported by: 0

README

model_reflect

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultHasher is the default hasher.
	DefaultHasher = HashInfo{
		Time:    1,
		Memory:  8,
		Threads: 1,
	}

	// DefaultInterfaces is the default list of interfaces to check.
	DefaultInterfaces = []reflect.Type{
		reflect.TypeOf((*encoding.BinaryMarshaler)(nil)).Elem(),
		reflect.TypeOf((*encoding.BinaryUnmarshaler)(nil)).Elem(),
		reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem(),
		reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem(),
	}

	// ErrLoopDetected is returned when a loop is detected.
	ErrLoopDetected = errors.New("loop detected")
	// ErrEmptyStruct is returned when a struct has no exported fields.
	ErrEmptyStruct = errors.New("empty struct")
	// ErrDuplicate is returned when a struct has duplicate fields.
	ErrDuplicate = errors.New("duplicate fields")

	DefaultNameTags = []string{
		"json",
		"msgpack",
		"cbor",
	}
)

Functions

This section is empty.

Types

type HashInfo

type HashInfo struct {
	Salt    []byte
	Time    uint32
	Memory  uint32
	Threads uint8
}

HashInfo contains information about the hasher.

type ModelInfo

type ModelInfo struct {
	Errs   []error
	Hasher HashInfo
	// contains filtered or unexported fields
}

ModelInfo contains information about a model.

func New

func New(v any) (m ModelInfo, err error)

New returns a new ModelInfo.

func (ModelInfo) Hash

func (m ModelInfo) Hash() uint64

Hash returns a hash of the model.

func (ModelInfo) String

func (m ModelInfo) String() string

String returns a string representation of the model.

Jump to

Keyboard shortcuts

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